mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 15:07:13 +01:00
switch to prisma
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { Error } from 'mongoose'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { Booking } from '../../../db/booking'
|
||||
import { Booking, Prisma } from '@prisma/client';
|
||||
import { createBooking } from '../../../db/index'
|
||||
import { log } from '../../../helpers/log'
|
||||
import {
|
||||
@@ -14,17 +13,14 @@ export default async function userHandler(
|
||||
): Promise<void> {
|
||||
const { method } = req
|
||||
|
||||
let booking: Booking
|
||||
let booking: Booking;
|
||||
|
||||
switch (method) {
|
||||
case 'POST':
|
||||
try {
|
||||
booking = await createBooking(req.body)
|
||||
} catch (e) {
|
||||
if (e instanceof Error.ValidationError) {
|
||||
res.status(400).json({ message: e.message, errors: e.errors })
|
||||
return
|
||||
}
|
||||
// TODO: add validation for booking on same day
|
||||
log.error('Failed to store booking', e)
|
||||
res.status(500).end(`Internal Server Error...Guru is meditating...`)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user