app.js 840 Bytes
Newer Older
KangMin An's avatar
KangMin An committed
1
import cookieParser from "cookie-parser";
2
import cors from "cors";
KangMin An's avatar
KangMin An committed
3
4
5
6
7
import express from "express";
import morgan from "morgan";
import helmet from "helmet";
import path from "path";

8
9
import routes from "./routes";

KangMin An's avatar
KangMin An committed
10
import globalRouter from "./routers/globalRouter";
11
import dataRouter from "./routers/dataRouter";
KangMin An's avatar
KangMin An committed
12

13
import { localmiddleware } from "./middlewares";
KangMin An's avatar
KangMin An committed
14
15
16

const app = express();

17
// Page Views for Development test.
KangMin An's avatar
KangMin An committed
18
19
20
app.set("view engine", "pug");
app.set("views", path.join(__dirname, "views"));

21
app.use(cors());
KangMin An's avatar
KangMin An committed
22
23
app.use(helmet());
app.use(cookieParser());
24
25
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
KangMin An's avatar
KangMin An committed
26
27
app.use(morgan("dev"));

28
29
30
31
// local middleware 사용
app.use(localmiddleware);

// router 사용
32
33
app.use(routes.base, globalRouter);
app.use(routes.base + routes.data, dataRouter);
KangMin An's avatar
KangMin An committed
34
35

export default app;