web/index.js

36 lines
914 B
JavaScript
Raw Normal View History

2021-11-15 09:29:10 +01:00
var express = require("express");
var cookieParser = require("cookie-parser");
var logger = require("morgan");
var bodyParser = require("body-parser");
2021-11-15 11:25:07 +01:00
2021-11-15 09:29:10 +01:00
const app = express();
2021-11-02 06:20:20 +01:00
2021-11-15 11:25:07 +01:00
const indexRouter = require('./routes/index');
const api = require('./routes/api');
app.use(express.static("public"));
app.set("view engine", "ejs");
2021-11-15 09:29:10 +01:00
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
2021-11-02 06:20:20 +01:00
app.use('/', indexRouter);
2021-11-15 10:59:21 +01:00
app.use('/api', api);
2021-11-02 06:20:20 +01:00
2021-11-15 09:29:10 +01:00
app.use(function (req, res, next) {
2021-11-15 11:25:07 +01:00
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
next();
2021-11-15 09:29:10 +01:00
});
2021-11-21 11:43:02 +01:00
app.listen("9286", () => {
console.log("Server is running on port : 9286");
2021-11-15 09:29:10 +01:00
});
module.exports = app;