aboutsummaryrefslogblamecommitdiff
path: root/server/routes/api.js
blob: c48e169dd69eff686b10a6b6fa9f0bdb65d944b4 (plain) (tree)
1
2
3
4
5
6
7
8
9


                                   
                                                      
                                                              
                                                                    
 
                                                               
 

                                                  
 


                                                     

                                                                                                  

                                                                            


                                                                       
                        
const express = require('express');
const router = express.Router();

const userController = require('../controllers/user');
const productsController = require('../controllers/products');
const transactionController = require('../controllers/transaction');

const {isAuth, isAdmin, upload} = require('../lib/middleware');

router.post('/register', userController.register);
router.post('/login', userController.login);

router.get('/products', productsController.index);
router.get('/products/:id', productsController.show);

router.post('/products', isAuth, isAdmin, upload.single('image'), productsController.store);
router.patch('/products/:id', isAuth, isAdmin, upload.single('image'), productsController.update);
router.delete('/products/:id', isAuth, isAdmin, productsController.destroy);

router.post('/transaction/setup', isAuth, transactionController.setup);
router.get('/transaction/capture', transactionController.capture);

module.exports = router;