Skip to content

Instantly share code, notes, and snippets.

@Rooarii
Created December 14, 2020 08:54
Show Gist options
  • Save Rooarii/fc0dc3a8fa817ad971900ae31ff4af7f to your computer and use it in GitHub Desktop.
Save Rooarii/fc0dc3a8fa817ad971900ae31ff4af7f to your computer and use it in GitHub Desktop.
Middlewares dans Express
const express =require('express');
const router = express.Router();
router.get('/', (req, res)=>{
res.send('Hello 🌎, welcome on Aliens 👽 API!')
});
let helloMiddleware = (req, res, next) =>{
console.log('hello middleware');
next();
}
let helloWorld = (req, res) =>{
res.send('hello world');
}
router.use(helloMiddleware, helloWorld);
router.get('/superMiddleware', (req,res)=>{
// console.log('hello middleware')
})
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment