chore: initial api
This commit is contained in:
@@ -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..."),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user