Skip to content

Instantly share code, notes, and snippets.

@Gattermeier
Last active March 25, 2017 01:12
Show Gist options
  • Save Gattermeier/5fb54ced03b4d6e4004f15b00d988246 to your computer and use it in GitHub Desktop.
Save Gattermeier/5fb54ced03b4d6e4004f15b00d988246 to your computer and use it in GitHub Desktop.
Default Express Router File for APIs
/*
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