-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
29 lines (23 loc) · 784 Bytes
/
app.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
27
28
29
// Require packages and set the port
const bodyParser = require('body-parser');
const express = require('express');
const cors = require('cors');
const routes = require('./routes/routes');
const port = 3002;
const app = express();
// Use Node.js body parsing middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true,
}));
app.use(cors());
// app.get('/', (request, response) => {
// console.log(`URL: ${request.url}`);
// response.send({message: 'Node.js and Express REST API'});
// });
routes(app);
// Start the server
const server = app.listen(port, (error) => {
if (error) return console.log(`Error: ${error}`);
console.log(`Server listening on port ${server.address().port}, http://localhost:${server.address().port}/`);
});