forked from snatic/shift-hydra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.mjs
37 lines (27 loc) · 1.01 KB
/
app.mjs
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
35
36
37
import express from 'express';
import bodyParser from 'body-parser';
import router from './resources/assets/js/components/main/backend/controllers/routes.mjs';
import config from './config.mjs';
const app = express();
app.use(bodyParser.json({limit: '5mb'})); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true,
limit: '5mb'
}));
app.set('view engine', 'ejs');
const port = process.env.PORT || config.port;
// Add headers
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:' + config.port);
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
// Pass to next layer of middleware
next();
});
app.use(express.static(process.env.PWD));
app.use('/', router);
const server = app.listen(port, function () {
console.log('Listening on port ' + port);
});
export default app;