|
|
|
@ -6,6 +6,7 @@ const easypost = new (require('@easypost/api'))(process.env.EASYPOST_API_KEY);
|
|
|
|
|
const ensureAdmin = require('./middleware/ensureAdmin')
|
|
|
|
|
const ensureCart = require('./middleware/ensureCart')
|
|
|
|
|
const ensureUser = require('./middleware/ensureUser')
|
|
|
|
|
const email = require('../utils/email')
|
|
|
|
|
|
|
|
|
|
const validate = require('./middleware/validators')
|
|
|
|
|
|
|
|
|
@ -191,6 +192,10 @@ router.post('/current/checkout/verify', ensureCart, parseJSON, async (req, res)
|
|
|
|
|
|
|
|
|
|
router.post('/:uuid/ship/tracking', ensureAdmin, parseJSON, async (req, res) => {
|
|
|
|
|
const order = await db.order.setTracking(req.params.uuid, req.body.code, req.body.date || null, req.body.price_cents)
|
|
|
|
|
|
|
|
|
|
const user = await db.order.getUser(order.uuid)
|
|
|
|
|
await email.sendShippingNotification(user, order)
|
|
|
|
|
|
|
|
|
|
res.json(order)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -208,5 +213,8 @@ router.post('/:uuid/ship/easypost', ensureAdmin, parseJSON, async (req, res) =>
|
|
|
|
|
req.body.weight
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const user = await db.order.getUser(order.uuid)
|
|
|
|
|
await email.sendShippingNotification(user, order)
|
|
|
|
|
|
|
|
|
|
res.json(order)
|
|
|
|
|
})
|
|
|
|
|