Advertisement
OSRSMargins

Untitled

Aug 14th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. # Your snippets
  2. #
  3. # Atom snippets allow you to enter a simple prefix in the editor and hit tab to
  4. # expand the prefix into a larger code block with templated values.
  5. #
  6. # You can create a new snippet in this file by typing "snip" and then hitting
  7. # tab.
  8. #
  9. # An example CoffeeScript snippet to expand log to console.log:
  10. #
  11. # '.source.coffee':
  12. # 'Console log':
  13. # 'prefix': 'log'
  14. # 'body': 'console.log $1'
  15. #
  16. # Each scope (e.g. '.source.coffee' above) can only be declared once.
  17. #
  18. # This file uses CoffeeScript Object Notation (CSON).
  19. # If you are unfamiliar with CSON, you can read more about it in the
  20. # Atom Flight Manual:
  21. # http://flight-manual.atom.io/using-atom/sections/basic-customization/#_cson
  22.  
  23. '.source.js':
  24. 'Express CRUD Template':
  25. 'prefix': 'crud'
  26. 'body': """
  27. const express = require('express');
  28. const router = express.Router();
  29.  
  30. // Applying middleware to all routes in the router
  31. router.use((req, res, next) => {
  32. next()
  33. })
  34.  
  35. //Return all items
  36. router.get("/", (req, res, err) => {
  37. res.send("In /");
  38. });
  39.  
  40. //Displays form to create new
  41. router.get("/new", (req, res, err) => {
  42. res.send("In /new");
  43. });
  44.  
  45. //Create new item
  46. router.post("/", (req, res, err) => {
  47. res.send("In /");
  48. });
  49.  
  50. //Return item for id
  51. router.get("/:id", (req, res, err) => {
  52. res.send("In /:id");
  53. });
  54.  
  55. //Shows edit form for item with id
  56. router.get("/:id/edit", (req, res, err) => {
  57. res.send("In /:id/edit");
  58. });
  59.  
  60. //Update item for id
  61. router.put("/:id", (req, res, err) => {
  62. res.send("In /id");
  63. });
  64.  
  65. //Deletes item with id
  66. router.delete("/:id", (req, res, err) => {
  67. res.send("In /:id");
  68. });
  69.  
  70. module.exports = router
  71. """
  72.  
  73. '.source.js':
  74. 'Express app template':
  75. 'prefix': 'express'
  76. 'body': """
  77. const port = process.env.PORT || 3000;
  78.  
  79. const express = require("express");
  80. const app = express();
  81.  
  82. app.use(require("./controllers"));
  83.  
  84. app.listen(port, () => {
  85. console.log(`Starting server on port ${ port }`);
  86. });
  87. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement