Guest User

Untitled

a guest
Jul 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. const express = require('express');
  2. const router = express.Router();
  3.  
  4. /* GET users listing. */
  5. router.get('/', function(req, res, next) {
  6. res.send('Hey ! It\'s a GET');
  7. });
  8.  
  9. /* GET user with ID. */
  10. router.get('/:id(\\d+)', function(req, res, next) {
  11. res.send('Hey ! It\'s a GET with ID ' + req.params.id);
  12. });
  13.  
  14. /* POST user creation. */
  15. router.post('/', function(req, res, next) {
  16. res.send('Hey ! It\'s a POST');
  17. });
  18.  
  19. // PUT user
  20. router.put('/:prenom', function(req, res, next) {
  21. res.send('Hey my name is ' + req.params.prenom);
  22. });
  23.  
  24. // DELETE user
  25. router.delete('/:id(\\d+)', function(req, res, next) {
  26. res.send('Hey it\'s a DELETE ID ' + req.params.id);
  27. });
  28.  
  29. module.exports = router;
Add Comment
Please, Sign In to add comment