-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (23 loc) · 887 Bytes
/
app.js
File metadata and controls
29 lines (23 loc) · 887 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
26
27
28
29
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
//const logger = require('morgan');
const jsonFile = require('jsonfile');
const appConfig = jsonFile.readFileSync('./config.json'); // конфиг
process.env.PORT = appConfig.port;
console.log("Running on port:", process.env.PORT);
const apiRouter = require('./routes/v2/api');
const app = express();
app.disable('x-powered-by');
//app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
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");
next();
});
app.use('/v2/api', apiRouter);
module.exports = app;