chore: initialized repository
This commit is contained in:
@@ -21,6 +21,24 @@ const client = postgres(process.env.DATABASE_URL);
|
||||
const db = drizzle(client, { schema });
|
||||
app.use((_, __, next) => DatabaseContext.run(db, next));
|
||||
|
||||
// API endpoint to record castration
|
||||
app.post("/api/castration", express.json(), async (req, res) => {
|
||||
try {
|
||||
const { gender } = req.body;
|
||||
|
||||
if (!gender || !["male", "female"].includes(gender)) {
|
||||
return res.status(400).json({ error: "Invalid gender" });
|
||||
}
|
||||
|
||||
const result = await db.insert(schema.castrations).values({ gender });
|
||||
|
||||
return res.json({ success: true, result });
|
||||
} catch (error) {
|
||||
console.error("Error recording castration:", error);
|
||||
return res.status(500).json({ error: "Failed to record castration" });
|
||||
}
|
||||
});
|
||||
|
||||
app.use(
|
||||
createRequestHandler({
|
||||
build: () => import("virtual:react-router/server-build"),
|
||||
|
||||
Reference in New Issue
Block a user