aboutsummaryrefslogtreecommitdiff
path: root/src/server.ts
blob: 67d649c66a761fd4593e8adc12b163e3c2a1a4f2 (plain)
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
import morgan from "morgan";
import env from "./config/env";
import express, { Application } from "express";

import animeRouter from "./routes";
import { homePage } from "./controllers";
import { ratelimit } from "./config/ratelimit";
import errorHandler from "./config/errorHandler";
import notFoundHandler from "./config/notFoundHandler";

const app: Application = express();
const PORT: number = env.PORT || 4000;

app.use(morgan("dev"));

app.use(ratelimit);
app.get("/", homePage);
app.use("/anime", animeRouter);

app.use(notFoundHandler);
app.use(errorHandler);

app.listen(PORT, () => {
  console.log(`⚔️  api @ http://localhost:${PORT}`);
});