-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
43 lines (34 loc) · 965 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
35
36
37
38
39
40
41
42
43
require('dotenv').config();
const express = require("express");
const cors = require("cors");
const config = require('./app/lib/config.js');
// prefixing the multi routes
express.application.prefix = express.Router.prefix = function (path, configure) {
var router = express.Router();
this.use(path, router);
configure(router);
return router;
};
// end prefixing the multi routes
const app = express();
var corsOptions = {
origin: config.Origin.allowFrom
};
app.use(cors(corsOptions));
// Parse URL-encoded bodies (as sent by HTML forms)
app.use(
express.urlencoded({
extended: true
})
)
app.use(express.json())
// simple route
app.post("/test", function(req,res) {
console.log(req.body);
res.json({ message: "This is testing route" });
});
require("./app/routes/index.routes.js")(app);
const PORT = process.env.SVR_PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});