const router = module.exports = require('express-promise-router')() const parseJSON = require('body-parser').json() const db = require('../db') const ensureAdmin = require('./middleware/ensureAdmin') router.get('/', ensureAdmin, async (req, res) => { const shipments = await db.shipment.findAll() res.json(shipments) }) router.get('/:uuid', ensureAdmin, async (req, res) => { const shipment = await db.shipment.findByUUID(req.params.uuid) res.json(shipment) }) router.post('/', ensureAdmin, parseJSON, async (req, res) => { const shipment = await db.shipment.createShipment(req.body.description, req.body.items) res.json(shipment) })