39 lines
1006 B
JavaScript
39 lines
1006 B
JavaScript
const express = require('express');
|
|
|
|
const PosService = require('../services/pos');
|
|
const wrapAsync = require('../helpers').wrapAsync;
|
|
const { checkPermissions } = require('../middlewares/check-permissions');
|
|
|
|
const router = express.Router();
|
|
|
|
router.get(
|
|
'/workspace',
|
|
checkPermissions('READ_PRODUCTS'),
|
|
wrapAsync(async (req, res) => {
|
|
const payload = await PosService.getWorkspace(req.currentUser, req.query.shopId);
|
|
res.status(200).send(payload);
|
|
}),
|
|
);
|
|
|
|
router.post(
|
|
'/checkout',
|
|
checkPermissions('CREATE_SALES_INVOICES'),
|
|
wrapAsync(async (req, res) => {
|
|
const payload = await PosService.checkout(req.currentUser, req.body);
|
|
res.status(200).send(payload);
|
|
}),
|
|
);
|
|
|
|
router.post(
|
|
'/pricing',
|
|
checkPermissions('UPDATE_SHOPS'),
|
|
wrapAsync(async (req, res) => {
|
|
const payload = await PosService.updatePricing(req.currentUser, req.body);
|
|
res.status(200).send(payload);
|
|
}),
|
|
);
|
|
|
|
router.use('/', require('../helpers').commonErrorHandler);
|
|
|
|
module.exports = router;
|