-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.ts
35 lines (28 loc) · 813 Bytes
/
app.ts
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
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
// routes
// App usages
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use((req: any, res: any, next: any) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET,POST,Delete,PUT,PATCH");
res.setHeader("Access-Control-Allow-Headers", "Content-Type,Authorization");
next();
});
// routes usages
//this route is optional
app.get("/", (req: any, res: any, next: any) => {
res.json({
status: 400,
msg: "Web Socket Launcher!"
});
});
app.use((req: any, res: any, next: any) => {
res.json({
status: 404,
msg: "Request Not Found!"
});
});
module.exports = app;