Reputation: 11
The application that I'm currently working on has been a bit difficult to apply information I've gotten from tutorials to. This app uses Express, but also features a lot of proprietary middleware that I don't quite fully understand.
My question relates to a particular way of utilizing app.get and app.post in our application. There isn't really a single point anywhere in the app that we use either of those things in that particular way, instead, each controller that we use features a module.export with GET and POST as the keys, which then contains all the code you would want to use for each request. All of this is wrapped up in a middleware that's based off of Tower.js (basically links the controllers to the views based on file path and name).
This has proved to be a bit troubling with trying to interpret tutorials where the code uses something like
router.post('/s3', multer({ dest: './uploads/'}).single('upl'), function(req, res, next){
client.putFile(req.file.path, '/user.jpg', function(err, response){
if (err) console.log(err)
res.status(200).send({url: response.req.url})
});
Is there any way to re-interpret this if the POST function in my controller for my route is used like this?
module.exports = {
get: function(req, callback){},
post: function(req, callback){}
}
(P.S. Yes, I'm having trouble using multer to upload images to S3 within this application)
Upvotes: 1
Views: 89