mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
more hacking
This commit is contained in:
@@ -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
14
pages/api/booking.js
Normal 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
18
pages/api/daysbooked.js
Normal 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`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user