Last active
March 25, 2017 01:12
-
-
Save Gattermeier/5fb54ced03b4d6e4004f15b00d988246 to your computer and use it in GitHub Desktop.
Default Express Router File for APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
My routing starter template for api endpoints when using Express.js | |
app.use('/api/endpoint', require('./endpoint.js')) | |
*/ | |
const express = require('express') | |
const router = express.Router() | |
router.use((req, res, next) => next()) | |
router.route('/:id') | |
.all((req, res, next) => next()) | |
.get((req, res) => res.json({})) | |
.put((req, res) => res.json({})) | |
.post((req, res) => res.json({})) | |
.delete((req, res) => res.json({})) | |
module.exports = router |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment