app.ts 668 Bytes
Newer Older
Yoon, Daeki's avatar
Yoon, Daeki committed
1
2
3
import cookieParser from "cookie-parser";
import express, { Request, Response, NextFunction } from "express";
import router from "./routes";
Yoon, Daeki's avatar
Yoon, Daeki committed
4
5
6

const app = express();

Yoon, Daeki's avatar
Yoon, Daeki committed
7
8
9
10
11
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());

app.use("/api", router);
12
13
14

app.use(express.static(__dirname + "/upload"));

Yoon, Daeki's avatar
Yoon, Daeki committed
15
16
17
18
19
20
21
22
23
app.use((err: any, req: Request, res: Response, next: NextFunction) => {
  console.log("익스프레스 에러: ", err);
  res.status(err.statusCode || 500).send(err.message || "서버 에러");
});

app.use(function (req, res, next) {
  res.status(404).send("잘못된 경로를 요청했습니다");
});

Yoon, Daeki's avatar
Yoon, Daeki committed
24
export default app;