chore: initial api

This commit is contained in:
redglow
2026-06-20 14:35:09 +02:00
parent 676b043ff5
commit e3b0ea0384
3 changed files with 246 additions and 3 deletions
+10
View File
@@ -1,5 +1,6 @@
import express from "express";
import ViteExpress from "vite-express";
import { db } from "./db/database.js";
const app = express();
@@ -7,6 +8,15 @@ app.get("/hello", (_, res) => {
res.send("Hello Vite + React + TypeScript!");
});
app.get("/api/announcements", async (_, res) => {
const announcements = await db
.selectFrom("announcements")
.select(["id", "title", "text", "publication_date", "image"])
.orderBy("announcements.publication_date", "desc")
.execute();
res.json(announcements);
});
ViteExpress.listen(app, 3000, () =>
console.log("Server is listening on port 3000..."),
);