Skip to content

Commit 8eb8650

Browse files
committed
flush changes
1 parent d26251e commit 8eb8650

File tree

5 files changed

+457
-3
lines changed

5 files changed

+457
-3
lines changed

nodejs/expressintro/index.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const express = require('express')
2+
3+
const app = express()
4+
5+
app.use(function (req, res, next) {
6+
console.log("At Middleware 1")
7+
next()
8+
})
9+
10+
11+
/// Request was for /a/b/c/d
12+
// This will also match because prefix match
13+
app.use('/a', function (req, res, next) {
14+
console.log("Middleware /a")
15+
next()
16+
})
17+
18+
app.use('/a/b', function (req, res, next) {
19+
console.log("Middleware /a/b")
20+
next()
21+
})
22+
23+
// will this match /a/b ?
24+
app.get('/a', function (req, res) {
25+
console.log("GET /a")
26+
})
27+
28+
app.get('/a/b', function (req, res, next) {
29+
console.log("GET /a/b")
30+
})
31+
32+
// Middleware
33+
app.get('/', (req, res, next) => {
34+
console.log("At GET /")
35+
res.send('Hello from Server Side')
36+
})
37+
38+
39+
app.listen(8080, function () {
40+
console.log("Running on 8080")
41+
})

0 commit comments

Comments
 (0)