-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.ts
40 lines (35 loc) · 971 Bytes
/
server.ts
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
39
40
import express, { Request, Response, Application } from "express";
import animeIndo from "./src/routes/animeindoRoute";
import cors from "cors";
import limiter from "./src/middleware/rateLimit";
import "dotenv/config";
import morgan from "morgan";
const app: Application = express();
const port = process.env.PORT || 8000;
app.use(express.json());
app.use(limiter);
app.use(morgan("combined"));
app.use(
cors({
origin: process.env.CORS_ORIGIN,
credentials: true,
allowedHeaders: [
"Origin",
"X-Requested-With",
"Content-Type",
"Authorization",
],
exposedHeaders: ["Authorization"],
methods: ["GET"],
})
);
app.get("/", (req: Request, res: Response) => {
res.json({
message: "Welcome to LuckyAnime Indo V2 & TypeScript Server",
route: "Go to our route /api/v2/anime",
});
});
app.use("/api/v2/anime", animeIndo);
app.listen(port, () => {
console.log(`Server is Fire at http://localhost:${port}`);
});