-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (25 loc) · 1.16 KB
/
Copy pathserver.js
File metadata and controls
31 lines (25 loc) · 1.16 KB
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
var express = require('express');
var app = express();
var path = require('path');
var serveStatic = require('serve-static');
var bodyParser = require("body-parser");
// handle cors
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, Authorization");
res.header( "Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,PATCH,OPTIONS" );
res.header("Access-Control-Allow-Credentials", false);
next();
});
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json({limit: "50mb",extended: true,type: "application/json"}));
app.use(bodyParser.urlencoded({limit: "50mb",extended: true,type: "application/x-www-form-urlencoding"}));
app.use(bodyParser.json({type: "application/json"}));
app.use(bodyParser.raw({limit: "50mb" }));
app.use('/', express.static(__dirname + '/www'));
app.use('/docs', express.static(__dirname + '/apidoc'));
app.use('/assets', express.static(__dirname + '/assets'));
global.appRoot = path.resolve(__dirname);
app.listen(5000);
console.log('server is started at port: 5000');
//module.exports = app