16 lines
706 B
TypeScript
16 lines
706 B
TypeScript
|
|
import type { Settings } from '../utils/store'
|
||
|
|
|
||
|
|
export default defineEventHandler(async (event) => {
|
||
|
|
const body = await readBody<Partial<Settings>>(event)
|
||
|
|
const s = db.settings
|
||
|
|
if (typeof body.open === 'boolean') s.open = body.open
|
||
|
|
if (typeof body.wait === 'number') s.wait = body.wait
|
||
|
|
if (typeof body.deliveryFee === 'number') s.deliveryFee = body.deliveryFee
|
||
|
|
if (typeof body.freeFrom === 'number') s.freeFrom = body.freeFrom
|
||
|
|
if (typeof body.minOrder === 'number') s.minOrder = body.minOrder
|
||
|
|
if (typeof body.radiusKm === 'number') s.radiusKm = body.radiusKm
|
||
|
|
if (Array.isArray(body.hours)) s.hours = body.hours
|
||
|
|
if (Array.isArray(body.closures)) s.closures = body.closures
|
||
|
|
return s
|
||
|
|
})
|