Skip to content

Instantly share code, notes, and snippets.

@justlaputa
Last active June 7, 2018 23:33
Show Gist options
  • Save justlaputa/2a064bf1ff4afb468b8eb39b0616e917 to your computer and use it in GitHub Desktop.
Save justlaputa/2a064bf1ff4afb468b8eb39b0616e917 to your computer and use it in GitHub Desktop.
example express application code for my blog post
const express = require('express')
const app = express()
app.use(function middlewareWithoutPath(req, res, next) {
console.log('use middleware without path')
next()
})
app.use('/foo', function middlewareWithPath(req, res, next) {
console.log('use middleware with path')
next()
})
app.route('/bar')
.get(function routeBarGet(req, res) {
res.send('ok')
})
.post(function routeBarPost(req, res) {
res.send('ok')
})
app.get('/zoo', function getZoo(req, res) {
res.send('ok')
})
app.listen(3000, () => {
console.log('listen on 3000...')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment