1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-31 06:18:07 +00:00
_/frourio/server/api/tasks/controller.ts

16 lines
472 B
TypeScript

import { defineController } from './$relay'
import { getTasks, createTask } from '$/service/tasks'
const print = (text: string) => console.log(text)
export default defineController({ getTasks, print }, ({ getTasks, print }) => ({
get: async ({ query }) => {
if (query?.message) print(query.message)
return { status: 200, body: await getTasks(query?.limit) }
},
post: async ({ body }) => ({
status: 201,
body: await createTask(body.label)
})
}))