Last active
September 6, 2018 03:41
-
-
Save chrisdel101/da579c77a4bcbe03629d65c158bda0fd to your computer and use it in GitHub Desktop.
Data passing
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
| // 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