-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
27 lines (21 loc) · 806 Bytes
/
app.js
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
import cookieParser from "cookie-parser";
import express, { json, urlencoded } from "express";
import logger from "morgan";
import { fileURLToPath } from "node:url";
import path from "path";
import config from "./config.js";
import { apiRouter } from "./routes/api/index.js";
import indexRouter from "./routes/home.js";
const { basePath } = config;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/** @type {import('express').Express} */
const app = express();
app.use(logger("dev"));
app.use(json());
app.use(urlencoded({ extended: false }));
app.use(cookieParser());
app.use(basePath, express.static(path.join(__dirname, "public")));
app.use(path.join(basePath, "/"), indexRouter);
app.use(path.join(basePath, "/api"), apiRouter);
export default app;