-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
38 lines (31 loc) · 993 Bytes
/
index.ts
File metadata and controls
38 lines (31 loc) · 993 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
31
32
33
34
35
36
37
38
import express, {
type Request,
type Response,
type NextFunction,
} from "express";
import walletRouter from "./src/routes/Wallet.route.ts";
import transactionRouter from "./src/routes/Transaction.route.ts";
import userRouter from "./src/routes/User.route.ts";
const app = express();
app.disable("x-powered-by");
app.use(express.json());
app.use("/api/wallet", walletRouter);
app.use("/api/transaction", transactionRouter);
app.use("/api/user", userRouter);
app.get("/", (req: Request, res: Response) => {
res.send("Hello World!");
});
app.use((req, res) => {
res.status(404).json({ message: "Not Found" });
});
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
console.error(err.stack);
res.status(500).json({ message: "Something broke!" });
});
const PORT = process.env.PORT || 3000;
if (process.env.NODE_ENV !== 'test') {
app.listen(PORT, () => {
console.log(`Server running on port http://localhost:${PORT}`);
});
}
export default app;