-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
22 lines (18 loc) · 714 Bytes
/
Copy pathindex.js
File metadata and controls
22 lines (18 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import express from 'express';
import bodyParser from 'body-parser';
import TodosRouter from './todos/routes.config';
// Set up the Express App
const app = express();
// Parse incoming requests data
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: false })); // for NOT parsing application/x-www-form-urlencoded
// Inject todos Routes middleware
app.use(TodosRouter);
const PORT = 5000;
// `app.listen` creates a web server, takes 2 params:
// 1st: port of the server will be running on
// 2nd: optional callback function fires when server is created
app.listen(PORT, err => {
if (err) throw err;
console.log(`> Ready on http://localhost:${PORT}`);
});