25 lines
685 B
TypeScript
25 lines
685 B
TypeScript
import { FreshContext } from '$fresh/server.ts'
|
|
import { isTable } from '@lyrics/db.ts'
|
|
import { crudHandlerFor } from '@lyrics/api.ts'
|
|
import { Display, Playlist, Song } from '@lyrics/models.ts'
|
|
|
|
export const subHandlers = {
|
|
song: crudHandlerFor(Song, 'song'),
|
|
playlist: crudHandlerFor(Playlist, 'playlist'),
|
|
display: crudHandlerFor(Display, 'display'),
|
|
}
|
|
|
|
export const handler = (req: Request, ctx: FreshContext): Response => {
|
|
const table = ctx.params.table
|
|
req.method
|
|
if (isTable(table)) {
|
|
console.log({ table })
|
|
return new Response('yo')
|
|
} else {
|
|
return new Response(
|
|
JSON.stringify({ message: `invalid table: ${ctx.params.table}` }),
|
|
{ status: 401 },
|
|
)
|
|
}
|
|
}
|