-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.ts
More file actions
38 lines (31 loc) · 958 Bytes
/
app.ts
File metadata and controls
38 lines (31 loc) · 958 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
35
36
37
38
import { config } from "dotenv";
import express from "express";
import cookieParser from "cookie-parser";
import cors from "cors";
import path from "path";
import morgan from "morgan";
import { fileURLToPath } from "url";
import router from "./src/routes/indexRouter.js";
import errorHandler from "./src/utils/errorHandler.js";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
config();
const app = express();
app.use(
cors({
origin: process.env.ALLOW_ORIGINS?.split(",") || "*",
credentials: true,
}),
);
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs");
app.use(express.static("src/static"));
app.set("views", path.join(__dirname, "src/views"));
app.set("view engine", "ejs");
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(morgan("tiny"));
app.use(router);
app.use(errorHandler);
export default app;