Created
January 19, 2019 17:21
-
-
Save Xkill119966/2f33b3aa05a29648e1bccc04c9d5a4e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const router = express.Router(); | |
| const multer = require('multer'); | |
| const restaurants = require('./../modules/restaurants.js'); | |
| const booking = require('./../modules/bookings'); | |
| const AWS = require('aws-sdk'); | |
| const multerS3 = require('multer-s3') | |
| const s3 = new AWS.S3({ | |
| secretAccessKey: '', | |
| accessKeyId: '', | |
| }); | |
| const backetId = ''; | |
| const bucketName = 'node-sdk-sample-' + backetId; | |
| var upload = multer({ | |
| storage: multerS3({ | |
| s3: s3, | |
| bucket: bucketName, | |
| key: function (req, file, cb) { | |
| console.log(file); | |
| cb(null, file.originalname); //use Date.now() for unique file keys | |
| } | |
| }) | |
| }); | |
| const cpUpload = upload.fields( | |
| [ | |
| { name: 'background', maxCount: 1 }, | |
| { name: 'lowBackground', maxCount: 1 }, | |
| { name: 'logo', maxCount: 1 }, | |
| { name: 'sliderOne', maxCount: 1 }, | |
| { name: 'sliderTwo', maxCount: 1 }, | |
| { name: 'sliderThree', maxCount: 1 }, | |
| ] | |
| ); | |
| //Get Restaurant List | |
| router.get('/', restaurants.get_all_restaurants); | |
| //Get One Detail Restaurant | |
| router.get('/detail/:id', restaurants.get_detail_restaurants); | |
| //Delete Restaurant | |
| router.delete('/delete/:id', restaurants.delete_restaurant); | |
| //Create Restaurant | |
| router.post('/create', restaurants.validate_create_restaurant, restaurants.create_restaurant); | |
| //Update One Restaurant With Specific Image | |
| router.put('/imageupload', cpUpload, restaurants.image_upload); | |
| //Create Booking | |
| router.post('/booking', booking.create_booking); | |
| //Soft Update | |
| // router.put('/booking/cancel', booking.soft_cancel); | |
| module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment