Advertisement
Sora952

Middleware quest wild

Jun 12th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const app = express();
  3. const port = 1000;
  4. const router = express.Router();
  5.  
  6. router.use('/superMiddleware', function(req, res, next) {
  7.   console.log('hello middleware');
  8.   next();
  9. }, function (req, res, next) {
  10.   res.send('hello world');
  11.   next();
  12. });
  13.  
  14. app.listen(port, (err) => {
  15.   if (err) {
  16.   throw new Error('Something bad happened...');
  17. }
  18. console.log(`Server is listening on ${port}`);
  19. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement