-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
44 lines (33 loc) · 1.21 KB
/
index.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
36
37
38
39
40
41
42
43
44
import dotenv from "dotenv";
dotenv.config();
if (process.env.NODE_ENV !== "test") {
import("./src/common/config/db-connect");
}
import express, { Express } from "express";
import * as swaggerUi from "swagger-ui-express";
import * as swaggerDocument from "./swagger.json";
import timeout from "connect-timeout";
const app: Express = express();
import morgan from "morgan";
import cors from "cors";
import { errorLogger, errorResponder } from "./src/common/middlewares/errors";
import { stream } from "./src/common/config/winston";
app.enable("trust proxy");
app.use(timeout("2.5s"));
app.use(cors());
app.use(
morgan(
// Standard Apache combined log output plus response time
':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent" - :response-time ms',
{ stream }
)
);
app.use(express.json());
import userRouter from "./src/users/users.route";
import addressRouter from "./src/addresses/addresses.route";
app.use("/api/v1/users", userRouter);
app.use("/api/v1/addresses", addressRouter);
app.use("/api/v1/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
app.use(errorLogger);
app.use(errorResponder);
export default app;