cityssm/parking-ticket-system

View on GitHub
handlers/plates-post/doGetLicencePlates.js

Summary

Maintainability
A
0 mins
Test Coverage
D
68%
import getLicencePlates from '../../database/parkingDB/getLicencePlates.js';
export default function handler(request, response) {
    const queryOptions = {
        limit: Number.parseInt(request.body.limit, 10),
        offset: Number.parseInt(request.body.offset, 10),
        licencePlateNumber: request.body.licencePlateNumber
    };
    if (request.body.hasOwnerRecord !== '') {
        queryOptions.hasOwnerRecord = request.body.hasOwnerRecord === '1';
    }
    if (request.body.hasUnresolvedTickets !== '') {
        queryOptions.hasUnresolvedTickets =
            request.body.hasUnresolvedTickets === '1';
    }
    response.json(getLicencePlates(queryOptions));
}