begin integrating frontend and backend

This commit is contained in:
2025-12-26 22:35:53 -06:00
parent 80733193a2
commit c5e8faf9ed
6 changed files with 29 additions and 5 deletions
+10 -1
View File
@@ -6,7 +6,7 @@ import express, { Request, Response } from "express";
const db = drizzle(process.env.DATABASE_URL!);
export const articlesRouter = express.Router();
articlesRouter.get("/getAllArticles", async (req: Request, res: Response) => {
articlesRouter.get("/getAllArticles", async (_, res: Response) => {
const resp = await db.select().from(articles);
res.json({ resp });
});
@@ -20,6 +20,15 @@ articlesRouter.get("/getArticle/:articleId", async (req: Request, res: Response)
res.json({ resp });
});
articlesRouter.get("/getArticleBySlug/:slug", async (req: Request, res: Response) => {
const { slug } = req.params;
const resp = await db.select()
.from(articles)
.where(eq(articles.slug, slug));
res.json({ resp });
});
articlesRouter.post("/postArticle", async (req: Request, res: Response) => {
const resp = await db
.insert(articles)
+2
View File
@@ -5,3 +5,5 @@ import express, { Request, Response } from "express";
const db = drizzle(process.env.DATABASE_URL!);
export const blocksRouter = express.Router();
// TODO: implement
+2
View File
@@ -5,3 +5,5 @@ import express, { Request, Response } from "express";
const db = drizzle(process.env.DATABASE_URL!);
export const imagesRouter = express.Router();
// TODO: Implement