Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Your snippets
- #
- # Atom snippets allow you to enter a simple prefix in the editor and hit tab to
- # expand the prefix into a larger code block with templated values.
- #
- # You can create a new snippet in this file by typing "snip" and then hitting
- # tab.
- #
- # An example CoffeeScript snippet to expand log to console.log:
- #
- # '.source.coffee':
- # 'Console log':
- # 'prefix': 'log'
- # 'body': 'console.log $1'
- #
- # Each scope (e.g. '.source.coffee' above) can only be declared once.
- #
- # This file uses CoffeeScript Object Notation (CSON).
- # If you are unfamiliar with CSON, you can read more about it in the
- # Atom Flight Manual:
- # http://flight-manual.atom.io/using-atom/sections/basic-customization/#_cson
- '.source.js':
- 'Express CRUD Template':
- 'prefix': 'crud'
- 'body': """
- const express = require('express');
- const router = express.Router();
- // Applying middleware to all routes in the router
- router.use((req, res, next) => {
- next()
- })
- //Return all items
- router.get("/", (req, res, err) => {
- res.send("In /");
- });
- //Displays form to create new
- router.get("/new", (req, res, err) => {
- res.send("In /new");
- });
- //Create new item
- router.post("/", (req, res, err) => {
- res.send("In /");
- });
- //Return item for id
- router.get("/:id", (req, res, err) => {
- res.send("In /:id");
- });
- //Shows edit form for item with id
- router.get("/:id/edit", (req, res, err) => {
- res.send("In /:id/edit");
- });
- //Update item for id
- router.put("/:id", (req, res, err) => {
- res.send("In /id");
- });
- //Deletes item with id
- router.delete("/:id", (req, res, err) => {
- res.send("In /:id");
- });
- module.exports = router
- """
- '.source.js':
- 'Express app template':
- 'prefix': 'express'
- 'body': """
- const port = process.env.PORT || 3000;
- const express = require("express");
- const app = express();
- app.use(require("./controllers"));
- app.listen(port, () => {
- console.log(`Starting server on port ${ port }`);
- });
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement