orders.js 904 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const express = require('express');
  2. const router = express.Router();
  3. const bodyParser = require('body-parser');
  4. const knex = require('../models/database');
  5. var OrderService = require('../services/OrderService.js');
  6. var UserService = require('../services/UserService.js');
  7. var Constants = require('../helpers/Constants.js');
  8. const RoutingService = require('../services/RoutingService')(router, 'orders', true);
  9. RoutingService.crud([1,1,1,1]);
  10. RoutingService.search(10,OrderService.present);
  11. router.post('/verify', function(req,res) {
  12. //console.log(req);
  13. //console.log(req.user);
  14. if(req.user.role != Constants.Roles.USER){
  15. res.status(403).send();
  16. return;
  17. }
  18. let order = req.body;
  19. let user = req.user;
  20. OrderService.submit(order,user)
  21. .then(() => res.sendStatus(200))
  22. .catch((err) => {
  23. console.log(err);
  24. res.sendStatus(400);
  25. });
  26. });
  27. module.exports = router;