Last active
June 7, 2018 23:33
-
-
Save justlaputa/2a064bf1ff4afb468b8eb39b0616e917 to your computer and use it in GitHub Desktop.
example express application code for my blog post
This file contains hidden or 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
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