Connect frontend to API and display events
This commit is contained in:
+10
-6
@@ -1,21 +1,25 @@
|
||||
import Fastify from "fastify";
|
||||
import { pool } from "./db/index.js";
|
||||
import { calendarRoutes } from "./modules/calendar/routes.js";
|
||||
import cors from "@fastify/cors";
|
||||
import { pool } from "./db";
|
||||
import { calendarRoutes } from "./modules/calendar/routes";
|
||||
|
||||
const app = Fastify();
|
||||
|
||||
await app.register(cors, {
|
||||
origin: true,
|
||||
});
|
||||
|
||||
pool
|
||||
.query("SELECT NOW()")
|
||||
.then((res) => console.log("DB connected:", res.rows[0]))
|
||||
.catch((err) => console.error("DB connection failed:", err));
|
||||
|
||||
app.register(calendarRoutes);
|
||||
|
||||
app.get("/health", async () => {
|
||||
return { ok: true };
|
||||
});
|
||||
|
||||
app.register(calendarRoutes);
|
||||
|
||||
app.listen({ port: 3000, host: "0.0.0.0" }).then(() => {
|
||||
console.log("API running on port 3000");
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user