-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
25 lines (20 loc) · 820 Bytes
/
app.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
import { Application } from "oak";
import { DATABASE_URL, DENO_ENV, PORT } from "./common/config.ts";
import { userRouter } from "./resources/user/user.router.ts";
import { authRouter } from "./resources/auth/auth.router.ts";
import { connect } from "./database/connect.ts";
import { timing } from "./middleware/timing.ts";
import { errorHandler } from "./middleware/errorHandler.ts";
import { rateLimit } from "./middleware/rateLimit.ts";
import { cors } from "./middleware/cors.ts";
await connect(DATABASE_URL);
const app = new Application();
if (DENO_ENV === "development") {
app.use(timing);
}
app.use(errorHandler);
app.use(cors);
app.use(rateLimit({ max: 100, windowMS: 1000 * 60 * 60, headers: true }));
app.use(userRouter.routes());
app.use(authRouter.routes());
await app.listen({ port: Number(PORT) });