cityssm/parking-ticket-system

View on GitHub
handlers/admin-post/doAddLocation.ts

Summary

Maintainability
A
2 hrs
Test Coverage
import type { Request, Response } from 'express'

import addParkingLocation from '../../database/parkingDB/addParkingLocation.js'
import { getParkingLocations } from '../../helpers/functions.cache.js'
import type { ParkingLocation } from '../../types/recordTypes.js'

export default function handler(request: Request, response: Response): void {
  const results = addParkingLocation(request.body as ParkingLocation)

  if (results.success) {
    results.locations = getParkingLocations()
  }

  response.json(results)
}