-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathapp.js
34 lines (32 loc) · 980 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
30
31
32
33
34
/* Express App for resolving stream vdeos by API
* @lscofield
* GNU
*/
// app.js
let express = require('express');
// Import Body parser
let bodyParser = require('body-parser');
// Initialize the app
let app = express();
// Import routes
// Important incrase this limit
app.use(bodyParser.urlencoded(
{ limit: '5mb', extended: true }));
app.use(bodyParser.json({ limit: '5mb' }));
let routes = require("./routes");
// Setup server port
const port = 80;
// Send message for default URL
app.get('/', (req, res) => res.send('Not found'));
// Use Api routes in the App
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.set({ 'content-type': 'application/json; charset=utf-8' });
next();
});
app.use('/api/v1', routes);
// Launch app to listen to specified port
app.listen(port, function () {
console.log("Running on port " + port);
});