-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
34 lines (27 loc) · 972 Bytes
/
index.ts
File metadata and controls
34 lines (27 loc) · 972 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
30
31
32
33
34
import express from "express";
import cors from "cors";
import router from "./routes";
import helmet from "helmet";
import cookieParser from "cookie-parser";
const app = express();
const origins = (process.env.ORIGIN as string).split(",");
app.use(cors({ credentials: true, origin: origins }));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(helmet());
app.use(cookieParser());
// app.disable("x-powered-by");
// Routes
router(app);
app.get('*', (req: express.Request, res: express.Response) => {
res.status(404).json({ message: 'not found' });
});
// app.use((err: Error, req: express.Request, res: express.Response, next: express.NextFunction) => {
// if (err instanceof SyntaxError && err.status === 400 && 'body' in err) {
// console.error(err);
// return res.sendStatus(400); // Bad request
// }
// next();
// });
console.log(`App is listening on port ${process.env.PORT || 9000}.`);
module.exports = app;