Skip to content

Instantly share code, notes, and snippets.

@jlozovei
Created April 29, 2018 06:17
Show Gist options
  • Save jlozovei/4c6df6e2787552dd9e8de3842cee9acd to your computer and use it in GitHub Desktop.
Save jlozovei/4c6df6e2787552dd9e8de3842cee9acd to your computer and use it in GitHub Desktop.
server routing with Express
'use strict'
const express = require('express')
const router = express.Router()
// @GET at http://localhost:XXXX/
router.get('/', (request, response) => {
response.send({ status: 'OK', message: 'Your request was successfully received' })
})
// @POST at http://localhost:XXXX/
router.post('/', (request, response) => {
response.send({ status: 'OK', message: 'Your request was successfully received' })
})
// @PUT at http://localhost:XXXX/
router.put('/', (request, response) => {
response.send({ status: 'OK', message: 'Your request was successfully received' })
})
// @DELETE at http://localhost:XXXX/
router.delete('/', (request, response) => {
response.send({ status: 'OK', message: 'Your request was successfully received' })
})
module.exports = router
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment