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

17 lines
472 B
TypeScript
Raw Normal View History

2020-10-12 13:35:33 +09:00
import { defineController } from './$relay'
import { getTasks, createTask } from '$/service/tasks'
2020-11-19 16:16:33 +09:00
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) }
},
2020-10-12 13:35:33 +09:00
post: async ({ body }) => ({
status: 201,
body: await createTask(body.label)
})
}))