-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quick API endpoint to check if council has A4 schema set
- Loading branch information
1 parent
19570b9
commit 58cb7ce
Showing
4 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { Router } from "express"; | ||
import { locationSearch } from "./service"; | ||
import { hasArticle4Schema } from "./service/article4Schema"; | ||
import { classifiedRoadsSearch } from "./service/classifiedRoads"; | ||
|
||
const router = Router(); | ||
|
||
router.get("/gis/:localAuthority", locationSearch); | ||
router.get("/gis/:localAuthority/article4-schema", hasArticle4Schema); | ||
router.get("/roads", classifiedRoadsSearch); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
|
||
import { localAuthorityMetadata } from "./digitalLand"; | ||
|
||
/** | ||
* @swagger | ||
* /gis/{localAuthority}/article4-schema: | ||
* get: | ||
* summary: Returns whether Article 4 schema variables are configured for this local authority | ||
* description: Returns whether Article 4 schema variables are configured for this local authority. A positive "status" from this endpoint is a proxy for marking this PlanX onboarding step "complete". | ||
* tags: | ||
* - gis | ||
* parameters: | ||
* - $ref: '#/components/parameters/localAuthority' | ||
* description: Name of the Local Authority, usually the same as Planx `team`. Required until Planning Data is available for any council o article 4 variables are generalised based on permitted development rights removed rather than council | ||
*/ | ||
export async function hasArticle4Schema( | ||
req: Request, | ||
res: Response, | ||
next: NextFunction, | ||
) { | ||
try { | ||
if (!req.params.localAuthority) { | ||
return next({ | ||
status: 401, | ||
message: "Missing param local authority", | ||
}); | ||
} | ||
|
||
const status = Object.keys(localAuthorityMetadata).includes( | ||
req.params.localAuthority, | ||
); | ||
res.status(200).send({ | ||
message: `${status ? "Found" : "Did not find"} Article 4 schema for ${req.params.localAuthority}`, | ||
status: status, | ||
}); | ||
} catch (error) { | ||
next({ | ||
status: 500, | ||
message: `Error getting Article 4 schema for ${req.params.localAuthority}: ${error}`, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters