sunrise-cms/handlers/lots-post/doCreateLot.ts

23 lines
495 B
TypeScript

import type { Request, Response } from 'express'
import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'
import { addLot } from '../../helpers/lotOccupancyDB/addLot.js'
export async function handler(
request: Request,
response: Response
): Promise<void> {
const lotId = await addLot(request.body, request.session)
response.json({
success: true,
lotId
})
response.on('finish', () => {
clearNextPreviousLotIdCache()
})
}
export default handler