Skip to content

Instantly share code, notes, and snippets.

@chrisdel101
Last active September 6, 2018 03:41
Show Gist options
  • Select an option

  • Save chrisdel101/da579c77a4bcbe03629d65c158bda0fd to your computer and use it in GitHub Desktop.

Select an option

Save chrisdel101/da579c77a4bcbe03629d65c158bda0fd to your computer and use it in GitHub Desktop.
Data passing
// controller.js
module.exports = {
extractDims: (inputUrl) => {
//this gets the nums form the URL
return stuff
},
resize: (path, format, width, height) => {
//this does some image processing
return stuff
},
showImage: (req,res) => {
//call both above funcs
let dims = extractDims(req.url
let src = `${__dirname}/image.jpeg}`
resize(src,'jpg', , x)
.pipe(res)
return stuff
}
}
// browser route
// localhost:3000/100x100
// route.js
// I want to get the req.path from the url into route to use in the function, but how since req is called in the controller.js and I need it in the route.js
const imageController = require('./controller.js')
router.get('need-path-here' imageController.showImage)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment