import { makeError, replies, logs } from '@oyst/utils' import CatalogAPI from '../../apis/catalog' import authorizeHandler from '../../handlers/authorize' import { fullSession as headers } from '../../validators/headers' import { merge } from 'ramda' import sessionHandler from '../../handlers/session' const { error, success } = replies export default { config: { pre: [sessionHandler, authorizeHandler], validate: { headers } }, handler: async (req, reply) => { try { const merchantId = req.pre.authorization.merchant.id const shipments = await CatalogAPI.findShipments(merchantId) success({ shipments }, reply) } catch (err) { logs.error({ errFindShipments: err }) error(makeError(err), reply) } }, method: 'GET', path: '/v1/shipments' }