stacker.news/pages/api/daily.js

18 lines
494 B
JavaScript
Raw Permalink Normal View History

import models from '@/api/models'
2023-06-19 19:40:24 +00:00
export default async (_, res) => {
// get the latest daily discussion thread
// this should probably be made more generic
// eg if the title changes this will break
// ... but this will need to change when we have more subs anyway
2023-07-26 16:01:31 +00:00
const [{ id }] = await models.$queryRawUnsafe(`
2023-06-19 19:40:24 +00:00
SELECT id
FROM "Item"
WHERE "pinId" IS NOT NULL
2023-09-13 01:21:16 +00:00
AND title = 'Stacker Saloon'
2023-06-19 19:40:24 +00:00
ORDER BY created_at DESC
LIMIT 1`)
res.redirect(`/items/${id}`)
}