-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (20 loc) · 730 Bytes
/
server.js
File metadata and controls
25 lines (20 loc) · 730 Bytes
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
const express = require('express');
const bodyParser = require('body-parser');
const router = require('./routes/router.js');
const app = express();
// Port setting
var port = process.env.PORT || 3000;
// Allows nested object
app.use(bodyParser.urlencoded({ extended: true }));
// Parses incoming request bodies in a middleware
app.use(bodyParser.json());
// Middlewares
// Ensures that all requests starting with /testmiddlewares/* will be checked
// for the token
app.all('/homecomix/testmiddlewares/*', [require('./middlewares/token')]);
// Mounts the router as middleware at path "/"
app.use('/', router);
// Starts the server
app.listen(port, function() {
console.log('HomeComix server listening on port ' + port);
});