-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
33 lines (27 loc) · 943 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
const express = require("express");
require("dotenv").config();
const app = express();
const messagesocket = require("./src/socket");
app.use(express.urlencoded({ extended: true })); // for taking body paramaters
app.use(express.json()); //parsing json like query
const http = require("http");
const server = http.createServer(app);
const routes = require("./src/routes");
routes.forEach((route) => {
app.use(`/${route.prefix}`, route.route);
});
app.route("/").post((req, res) => {
const shell = require("shelljs");
shell.exec("./updateproject.sh");
return res.send({ msg: "GUNCELLENDİ" });
});
app.use("/*", function (req, res, next) {
res.status(404);
res.json({ status: 404, title: "Not Found", msg: "Route not found" });
next();
});
messagesocket.messagesocket(server);
server.listen(process.env.PORT, () => {
console.log(`🚀 Server listening to http://localhost:${process.env.PORT} `);
});
module.exports = app;