cityssm/parking-ticket-system

View on GitHub
handlers/tickets-get/byTicketNumber.js

Summary

Maintainability
A
0 mins
Test Coverage
F
30%
import getParkingTicketId from '../../database/parkingDB/getParkingTicketId.js';
import { getConfigProperty } from '../../helpers/functions.config.js';
const urlPrefix = getConfigProperty('reverseProxy.urlPrefix');
export default function handler(request, response) {
    const ticketNumber = request.params.ticketNumber;
    const ticketId = getParkingTicketId(ticketNumber);
    if (ticketId === undefined) {
        response.redirect(`${urlPrefix}/tickets/?error=ticketNotFound`);
    }
    else {
        response.redirect(`${urlPrefix}/tickets/${ticketId.toString()}`);
    }
}