import { defineHTTPRoutes, wireHTTPRoutes } from '#pikku'
import { listCards } from '../functions/list-cards.function.js'
import { createCard } from '../functions/create-card.function.js'
import { getCardFileUploadUrl } from '../functions/get-card-file-upload-url.function.js'
import { signCardFile } from '../functions/sign-card-file.function.js'

export const kanbanRoutes = defineHTTPRoutes({
  auth: false,
  routes: {
    listCards: { method: 'get', route: '/cards', func: listCards },
    createCard: { method: 'post', route: '/cards', func: createCard },
    getCardFileUploadUrl: {
      method: 'post',
      route: '/cards/:cardId/attachments/upload-url',
      func: getCardFileUploadUrl,
    },
    signCardFile: {
      method: 'get',
      route: '/cards/:cardId/attachments/:fileName/signed-url',
      func: signCardFile,
    },
  },
})

wireHTTPRoutes({ routes: { kanban: kanbanRoutes } })
