sanjay555

server.js

Feb 8th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const PORT = 5000;
  3.  
  4.  
  5. const app = express();
  6.  
  7. // Rules for routes comming up next only for the /table path(route) // Middleware
  8. app.use('/table', (req, res, next) => {
  9.   let shirt = req.shirt;
  10.   let shoes = req.shoes;
  11.   if (shirt && shoes) {
  12.     next();
  13.   }
  14.   console.log(`Request: ${req} Response: ${res}`);  
  15. })
  16.  
  17. // Get retrive information based on specific acction
  18. app.get('/', (req, res) => {
  19.   res.send('Hello World');
  20. })
  21.  
  22. app.get('/table/:amount', (req, res, next) => {
  23.   let party = req.params.amount;
  24.   res.end(`We're searching for your table for ${party}!`)
  25. })
  26.  
  27. app.listen(PORT, () => {
  28.  console.log(`We're live on PORT: ${PORT}`);  
  29. })
Add Comment
Please, Sign In to add comment