feat(api): ✨ add news fetching api handler
This commit is contained in:
parent
5365f11ec6
commit
f2c8b145e6
14
routes/api/news/fetchAll.ts
Normal file
14
routes/api/news/fetchAll.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { fetchNewsList } from ':src/blog/mod.ts'
|
||||
import { SessionHandlers } from ':src/session/mod.ts'
|
||||
import { respondApi, respondApiStream } from ':src/utils.ts'
|
||||
|
||||
export const handler: SessionHandlers = {
|
||||
GET() {
|
||||
try {
|
||||
const newsList = fetchNewsList('cohabit')
|
||||
return respondApiStream(newsList)
|
||||
} catch (error) {
|
||||
return respondApi('error', error)
|
||||
}
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue