24 lines
649 B
TypeScript
24 lines
649 B
TypeScript
import express from "express";
|
|
import ViteExpress from "vite-express";
|
|
import { db } from "./db/database.js";
|
|
|
|
const app = express();
|
|
|
|
app.get("/hello", (_, res) => {
|
|
res.send("Hello Vite + React + TypeScript!");
|
|
});
|
|
|
|
app.get("/api/announcements", async (_, res) => {
|
|
// await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
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..."),
|
|
);
|