Skip to content

Commit

Permalink
Merge pull request #386 from ideal-postcodes/onspd_aug_2019
Browse files Browse the repository at this point in the history
ONSPD Aug 2019 Update
  • Loading branch information
cblanc committed Aug 28, 2019
2 parents d6c7134 + d80d451 commit 61c96d4
Show file tree
Hide file tree
Showing 28 changed files with 2,108 additions and 1,053 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

Any changes, including backwards incompatible changes will be listed here

## 10.2.0 (27/8/2019)

- Update ONSPD to August 2019
- Update OS Open Names to July 2019
- Updated GSS codes for missing wards
- Integrated Scotland Postcode Directory (SPD) dataset
- Added Scotland postcode lookup (for Scottish Constituencies) `/scotland/postcodes/:postcode`

## 10.1.4 (5/7/2019)

- CI testing on node 12 (instead of 11)
Expand Down
24 changes: 24 additions & 0 deletions app/controllers/scottish_postcodes_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

const ScottishPostcode = require("../models/scottish_postcode");
const Postcode = require("postcode");
const {
InvalidPostcodeError,
PostcodeNotFoundError,
} = require("../lib/errors.js");

exports.show = (request, response, next) => {
const { postcode } = request.params;
if (!Postcode.isValid(postcode.trim()))
return next(new InvalidPostcodeError());

ScottishPostcode.find(postcode, (error, result) => {
if (error) return next(error);
if (!result) return next(new PostcodeNotFoundError());
response.jsonApiResponse = {
status: 200,
result: ScottishPostcode.toJson(result),
};
return next();
});
};
4 changes: 2 additions & 2 deletions app/lib/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const SUPPORT_TABLES = [
"Nuts",
"Parish",
"Ward",
"ScottishConstituency",
].map(name => models[name]);

/**
Expand Down Expand Up @@ -44,9 +45,8 @@ const setupOutcodeTable = () => {
});
};

module.exports = {
module.exports = {
setupSupportTables,
setupOutcodeTable,
SUPPORT_TABLES,
};

Loading

0 comments on commit 61c96d4

Please sign in to comment.