fixed GET article route

This commit is contained in:
Omer Sabic 2024-05-07 18:54:45 +02:00
parent 561404faf1
commit 02278a99d9

View File

@ -59,11 +59,14 @@ export const blogRoutes = (fastify, _, done) => {
querystring: { querystring: {
id: { id: {
type: "string" type: "string"
},
slug: {
type: "string"
} }
} }
} }
}, async (req, reply) => { }, async (req, reply) => {
const [result] = await db.select().from(articlesTable).where(or(eq(articlesTable.seo_slug, req.query.id), eq(articlesTable.id, req.query.id))); const [result] = await db.select().from(articlesTable).where((req.query.id ? eq(articlesTable.id, req.query.id) : eq(articlesTable.seo_slug, req.query.slug)));
reply.send({ reply.send({
success: true, success: true,