@MikeShi42/

BouncyJaggedZip

Express

No description

fork
loading
Files
  • index.js
  • db.js
  • db.sqlite3
  • package-lock.json
  • package.json
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const express = require('express');
const bodyParser = require('body-parser');
const db = require('./db');

const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(express.static('public'));

app.get('/:id/:nid', (req, res, next) => {
  console.log('handled first!');
  if (req.params.nid == 4) {
    console.log('error');
    throw new Error('noo!!');
  }
  next();
});

app.get('/:id/3', (req, res) => {
  console.log('handled second!');
	res.send('Hello Express app');
});

app.listen(3000, () => console.log('server started'));