diff --git a/api.planx.uk/modules/gis/routes.ts b/api.planx.uk/modules/gis/routes.ts new file mode 100644 index 0000000000..057a812bb6 --- /dev/null +++ b/api.planx.uk/modules/gis/routes.ts @@ -0,0 +1,10 @@ +import { Router } from "express"; +import { locationSearch } from "./service"; +import { classifiedRoadsSearch } from "./service/classifiedRoads"; + +const router = Router(); + +router.get("/gis/:localAuthority", locationSearch); +router.get("/roads", classifiedRoadsSearch); + +export default router; diff --git a/api.planx.uk/gis/classifiedRoads.test.ts b/api.planx.uk/modules/gis/service/classifiedRoads.test.ts similarity index 93% rename from api.planx.uk/gis/classifiedRoads.test.ts rename to api.planx.uk/modules/gis/service/classifiedRoads.test.ts index 22ce2a4b2c..169062176e 100644 --- a/api.planx.uk/gis/classifiedRoads.test.ts +++ b/api.planx.uk/modules/gis/service/classifiedRoads.test.ts @@ -1,7 +1,7 @@ import supertest from "supertest"; -import loadOrRecordNockRequests from "../tests/loadOrRecordNockRequests"; -import app from "../server"; +import loadOrRecordNockRequests from "../../../tests/loadOrRecordNockRequests"; +import app from "../../../server"; import { PASSPORT_FN } from "./classifiedRoads"; it("returns an error if required query param is missing", async () => { diff --git a/api.planx.uk/gis/classifiedRoads.ts b/api.planx.uk/modules/gis/service/classifiedRoads.ts similarity index 100% rename from api.planx.uk/gis/classifiedRoads.ts rename to api.planx.uk/modules/gis/service/classifiedRoads.ts diff --git a/api.planx.uk/gis/digitalLand.ts b/api.planx.uk/modules/gis/service/digitalLand.ts similarity index 99% rename from api.planx.uk/gis/digitalLand.ts rename to api.planx.uk/modules/gis/service/digitalLand.ts index 908bef56a7..13c31566fb 100644 --- a/api.planx.uk/gis/digitalLand.ts +++ b/api.planx.uk/modules/gis/service/digitalLand.ts @@ -7,7 +7,7 @@ import { gql } from "graphql-request"; import fetch from "isomorphic-fetch"; import { addDesignatedVariable, omitGeometry } from "./helpers"; import { baseSchema } from "./local_authorities/metadata/base"; -import { $api } from "../client"; +import { $api } from "../../../client"; export interface LocalAuthorityMetadata { planningConstraints: { diff --git a/api.planx.uk/gis/helpers.js b/api.planx.uk/modules/gis/service/helpers.js similarity index 100% rename from api.planx.uk/gis/helpers.js rename to api.planx.uk/modules/gis/service/helpers.js diff --git a/api.planx.uk/gis/helpers.test.js b/api.planx.uk/modules/gis/service/helpers.test.js similarity index 100% rename from api.planx.uk/gis/helpers.test.js rename to api.planx.uk/modules/gis/service/helpers.test.js diff --git a/api.planx.uk/gis/index.js b/api.planx.uk/modules/gis/service/index.js similarity index 100% rename from api.planx.uk/gis/index.js rename to api.planx.uk/modules/gis/service/index.js diff --git a/api.planx.uk/gis/index.test.ts b/api.planx.uk/modules/gis/service/index.test.ts similarity index 94% rename from api.planx.uk/gis/index.test.ts rename to api.planx.uk/modules/gis/service/index.test.ts index 091f6eced5..533454979d 100644 --- a/api.planx.uk/gis/index.test.ts +++ b/api.planx.uk/modules/gis/service/index.test.ts @@ -1,8 +1,8 @@ import supertest from "supertest"; -import { locationSearchWithTimeout } from "../gis"; -import loadOrRecordNockRequests from "../tests/loadOrRecordNockRequests"; -import app from "../server"; +import loadOrRecordNockRequests from "../../../tests/loadOrRecordNockRequests"; +import app from "../../../server"; +import { locationSearchWithTimeout } from "."; // Tests commented out due to reliance on external API calls and fallibility of nocks // Please comment in and run locally if making changes to /gis functionality diff --git a/api.planx.uk/gis/local_authorities/braintree.js b/api.planx.uk/modules/gis/service/local_authorities/braintree.js similarity index 100% rename from api.planx.uk/gis/local_authorities/braintree.js rename to api.planx.uk/modules/gis/service/local_authorities/braintree.js diff --git a/api.planx.uk/gis/local_authorities/metadata/base.ts b/api.planx.uk/modules/gis/service/local_authorities/metadata/base.ts similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/base.ts rename to api.planx.uk/modules/gis/service/local_authorities/metadata/base.ts diff --git a/api.planx.uk/gis/local_authorities/metadata/braintree.js b/api.planx.uk/modules/gis/service/local_authorities/metadata/braintree.js similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/braintree.js rename to api.planx.uk/modules/gis/service/local_authorities/metadata/braintree.js diff --git a/api.planx.uk/gis/local_authorities/metadata/buckinghamshire.ts b/api.planx.uk/modules/gis/service/local_authorities/metadata/buckinghamshire.ts similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/buckinghamshire.ts rename to api.planx.uk/modules/gis/service/local_authorities/metadata/buckinghamshire.ts diff --git a/api.planx.uk/gis/local_authorities/metadata/camden.ts b/api.planx.uk/modules/gis/service/local_authorities/metadata/camden.ts similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/camden.ts rename to api.planx.uk/modules/gis/service/local_authorities/metadata/camden.ts diff --git a/api.planx.uk/gis/local_authorities/metadata/canterbury.ts b/api.planx.uk/modules/gis/service/local_authorities/metadata/canterbury.ts similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/canterbury.ts rename to api.planx.uk/modules/gis/service/local_authorities/metadata/canterbury.ts diff --git a/api.planx.uk/gis/local_authorities/metadata/doncaster.ts b/api.planx.uk/modules/gis/service/local_authorities/metadata/doncaster.ts similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/doncaster.ts rename to api.planx.uk/modules/gis/service/local_authorities/metadata/doncaster.ts diff --git a/api.planx.uk/gis/local_authorities/metadata/lambeth.ts b/api.planx.uk/modules/gis/service/local_authorities/metadata/lambeth.ts similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/lambeth.ts rename to api.planx.uk/modules/gis/service/local_authorities/metadata/lambeth.ts diff --git a/api.planx.uk/gis/local_authorities/metadata/medway.ts b/api.planx.uk/modules/gis/service/local_authorities/metadata/medway.ts similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/medway.ts rename to api.planx.uk/modules/gis/service/local_authorities/metadata/medway.ts diff --git a/api.planx.uk/gis/local_authorities/metadata/newcastle.ts b/api.planx.uk/modules/gis/service/local_authorities/metadata/newcastle.ts similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/newcastle.ts rename to api.planx.uk/modules/gis/service/local_authorities/metadata/newcastle.ts diff --git a/api.planx.uk/gis/local_authorities/metadata/scotland.js b/api.planx.uk/modules/gis/service/local_authorities/metadata/scotland.js similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/scotland.js rename to api.planx.uk/modules/gis/service/local_authorities/metadata/scotland.js diff --git a/api.planx.uk/gis/local_authorities/metadata/southwark.ts b/api.planx.uk/modules/gis/service/local_authorities/metadata/southwark.ts similarity index 100% rename from api.planx.uk/gis/local_authorities/metadata/southwark.ts rename to api.planx.uk/modules/gis/service/local_authorities/metadata/southwark.ts diff --git a/api.planx.uk/gis/local_authorities/scotland.js b/api.planx.uk/modules/gis/service/local_authorities/scotland.js similarity index 97% rename from api.planx.uk/gis/local_authorities/scotland.js rename to api.planx.uk/modules/gis/service/local_authorities/scotland.js index fcb899a931..eef564475e 100644 --- a/api.planx.uk/gis/local_authorities/scotland.js +++ b/api.planx.uk/modules/gis/service/local_authorities/scotland.js @@ -7,7 +7,7 @@ import { rollupResultLayers, addDesignatedVariable, } from "../helpers.js"; -import { planningConstraints } from "./metadata/scotland"; +import { planningConstraints } from "./metadata/scotland.js"; // Process local authority metadata const gisLayers = getQueryableConstraints(planningConstraints); diff --git a/api.planx.uk/server.ts b/api.planx.uk/server.ts index 38cdf5ed54..75a50208f5 100644 --- a/api.planx.uk/server.ts +++ b/api.planx.uk/server.ts @@ -13,7 +13,6 @@ import passport from "passport"; import helmet from "helmet"; import { ServerError } from "./errors"; -import { locationSearch } from "./gis/index"; import { makePaymentViaProxy, fetchPaymentViaProxy, @@ -33,7 +32,6 @@ import { sendToBOPS } from "./send/bops"; import { createSendEvents } from "./send/createSendEvents"; import { downloadApplicationFiles, sendToEmail } from "./send/email"; import { sendToUniform } from "./send/uniform"; -import { classifiedRoadsSearch } from "./gis/classifiedRoads"; import { googleStrategy } from "./modules/auth/strategy/google"; import authRoutes from "./modules/auth/routes"; import teamRoutes from "./modules/team/routes"; @@ -47,11 +45,10 @@ import ordnanceSurveyRoutes from "./modules/ordnanceSurvey/routes"; import saveAndReturnRoutes from "./modules/saveAndReturn/routes"; import sendEmailRoutes from "./modules/sendEmail/routes"; import fileRoutes from "./modules/file/routes"; +import gisRoutes from "./modules/gis/routes"; import { useSwaggerDocs } from "./docs"; import { Role } from "@opensystemslab/planx-core/types"; -const router = express.Router(); - const app = express(); useSwaggerDocs(app); @@ -172,19 +169,7 @@ app.use("/file", fileRoutes); app.use(saveAndReturnRoutes); app.use(sendEmailRoutes); app.use("/flows", flowRoutes); - -app.use("/gis", router); - -app.get("/gis", (_req, _res, next) => { - next({ - status: 400, - message: "Please specify a local authority", - }); -}); - -app.get("/gis/:localAuthority", locationSearch); - -app.get("/roads", classifiedRoadsSearch); +app.use(gisRoutes); // allows an applicant to download their application data on the Confirmation page app.post("/download-application", async (req, res, next) => {