import { CommerceAPI, GetAPISchema, createEndpoint } from '@commerce/api' import checkoutEndpoint from '@commerce/api/endpoints/checkout' import { CheckoutSchema } from '@commerce/types/checkout' export type CheckoutAPI = GetAPISchema export type CheckoutEndpoint = CheckoutAPI['endpoint'] const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({ req, res, config }) => { try { const html = ` Checkout

Checkout not yet implemented :(

See #64

` res.status(200) res.setHeader('Content-Type', 'text/html') res.write(html) res.end() } catch (error) { console.error(error) const message = 'An unexpected error ocurred' res.status(500).json({ data: null, errors: [{ message }] }) } } export const handlers: CheckoutEndpoint['handlers'] = { submitCheckout } const checkoutApi = createEndpoint({ handler: checkoutEndpoint, handlers, }) export default checkoutApi