switch to prisma

This commit is contained in:
Thomas Ruoff
2022-10-11 11:43:32 +02:00
parent 41342475ba
commit 1ef9b14e95
28 changed files with 764 additions and 780 deletions

View File

@@ -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