paf-api
Version:
HTTP service that parses Postcode Address File records into a correctly formatted address
32 lines • 1.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = void 0;
var uk_clear_addressing_1 = require("uk-clear-addressing");
exports.parse = function (body) {
var _a = body.building_name, building_name = _a === void 0 ? "" : _a, _b = body.building_number, building_number = _b === void 0 ? "" : _b, _c = body.sub_building_name, sub_building_name = _c === void 0 ? "" : _c, _d = body.dependant_locality, dependant_locality = _d === void 0 ? "" : _d, _e = body.double_dependant_locality, double_dependant_locality = _e === void 0 ? "" : _e, _f = body.thoroughfare, thoroughfare = _f === void 0 ? "" : _f, _g = body.dependant_thoroughfare, dependant_thoroughfare = _g === void 0 ? "" : _g, _h = body.po_box, po_box = _h === void 0 ? "" : _h, _j = body.post_town, post_town = _j === void 0 ? "" : _j, _k = body.postcode, postcode = _k === void 0 ? "" : _k, _l = body.department_name, department_name = _l === void 0 ? "" : _l, _m = body.organisation_name, organisation_name = _m === void 0 ? "" : _m;
var query = {
building_name: building_name,
building_number: building_number,
sub_building_name: sub_building_name,
dependant_locality: dependant_locality,
double_dependant_locality: double_dependant_locality,
thoroughfare: thoroughfare,
dependant_thoroughfare: dependant_thoroughfare,
po_box: po_box,
post_town: post_town,
postcode: postcode,
department_name: department_name,
organisation_name: organisation_name,
};
var address = new uk_clear_addressing_1.Address(query);
var formatted = {
line_1: address.line_1,
line_2: address.line_2,
line_3: address.line_3,
post_town: address.post_town,
postcode: address.postcode,
premise: address.premise,
};
return { query: query, formatted: formatted };
};
//# sourceMappingURL=parse.js.map