more hacking

This commit is contained in:
Thomas Ruoff
2020-07-26 00:12:51 +02:00
parent 90a9288e84
commit 518b437d14
13 changed files with 166 additions and 54 deletions

View File

@@ -1,12 +0,0 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { getAllBookings } from './db/index'
export default async (req, res) => {
const bookings = await getAllBookings()
console.log(bookings)
res.statusCode = 200
res.json(['2020-07-23', '2020-07-24', '2020-07-25', '2020-08-01'])
}

14
pages/api/booking.js Normal file
View File

@@ -0,0 +1,14 @@
import { createBooking } from '../../db/index'
export default async function userHandler(req, res) {
const { method } = req
switch (method) {
case 'POST':
const data = await createBooking(req.body)
res.status(200).json(data)
break
default:
res.setHeader('Allow', ['POST'])
res.status(405).end(`Method ${method} Not Allowed`)
}
}

18
pages/api/daysbooked.js Normal file
View File

@@ -0,0 +1,18 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { getBookedDays } from '../../db/index'
export default async function useHandler(req, res) {
const { method } = req
switch (method) {
case 'GET':
const days = await getBookedDays()
res.statusCode = 200
res.json(days)
break
default:
res.setHeader('Allow', ['GET'])
res.status(405).end(`Method ${method} Not Allowed`)
}
}