-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathapp.ts
More file actions
30 lines (25 loc) · 788 Bytes
/
app.ts
File metadata and controls
30 lines (25 loc) · 788 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
import 'dotenv/config';
import express from "express";
import ProposalsRouter from "./routes/proposals";
import TopicsRouter from "./routes/topics";
import DraftsRouter from "./routes/drafts";
import WinnerRouter from "./routes/winner"
import cors from 'cors';
import { logRequest, clerkAuth } from "./middleware";
const app = express();
app.use(cors());
app.use(express.json());
app.use(logRequest);
app.use(clerkAuth);
app.use("/proposals", ProposalsRouter);
app.use("/topics", TopicsRouter);
app.use("/drafts", DraftsRouter);
app.use("/winner", WinnerRouter);
app.use("/health", (req, res) => {
res.status(200).json({ message: "Ok" });
});
// 404 handler
app.use((req, res, next) => {
res.status(404).json({ error: `route ${req.url} does not exist` });
})
export default app;