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

7
8
import routes from "./routes";

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

12
import { localmiddleware } from "./middlewares";
13
import locCodeRouter from "./routers/locCodeRouter";
KangMin An's avatar
KangMin An committed
14
15
16
17
18
19
20
21

const app = express();

app.set("view engine", "pug");
app.set("views", path.join(__dirname, "views"));

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

26
27
28
29
// local middleware 사용
app.use(localmiddleware);

// router 사용
KangMin An's avatar
KangMin An committed
30
app.use(routes.home, globalRouter);
31
app.use(routes.data, dataRouter);
32
app.use(routes.locCode, locCodeRouter);
KangMin An's avatar
KangMin An committed
33
34

export default app;