1 file changed
8
const app = express();
9
10
app.use(cors());
11
app.use(express.json({ limit: "1mb" }));
11
app.use(express.json({ limit: "10mb" }));
12
app.use(rateLimit({ window: 60, max: 100 }));
13
app.use(logger);
14
15
app.get("/health", (_req, res) => {
24
app.get("/api/users/:id", auth, async (req, res) => {
25
const user = await db.users.findUnique({
26
where: { id: req.params.id },
27
include: { posts: true },
28
});
29
if (!user) {
30
return res.status(404).json({ error: "User not found" });
71
72
const port = process.env.PORT ?? 3000;
73
app.listen(port, () => {
72
console.log("listening on " + port);
74
console.log(`server ready on http://localhost:${port}`);
75
console.log("press ctrl+c to stop");
76
});