Skip to content

Commit

Permalink
feat: OS Proxy docs (#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr authored Nov 14, 2023
1 parent dfb9d5f commit c7be4d5
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useProxy } from "./index";
import { useProxy } from "../../shared/middleware/proxy";
import { NextFunction, Request, Response } from "express";
import { IncomingMessage } from "http";

Expand Down
62 changes: 62 additions & 0 deletions api.planx.uk/modules/ordnanceSurvey/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
openapi: 3.1.0
info:
title: Plan✕ API
version: 0.1.0
tags:
- name: ordnance survey
description: Proxy authenticated requests to the OS Data Hub APIs
externalDocs:
url: https://osdatahub.os.uk/docs
components:
schemas:
AnyParams:
description: Any query parameters accepted by OS Data Hub APIs
name: queryParams
in: query
schema:
type: object
example:
key1: value1
key2: value2
AnyBody:
description: Any JSON body accepted by OS Data Hub APIs
required: false
content:
application/json:
schema:
type: object
example:
key1: value1
key2: value2
paths:
/proxy/ordnance-survey:
get:
tags: [ordnance survey]
parameters:
- $ref: "#/components/schemas/AnyParams"
requestBody:
$ref: "#/components/schemas/AnyBody"
put:
tags: [ordnance survey]
parameters:
- $ref: "#/components/schemas/AnyParams"
requestBody:
$ref: "#/components/schemas/AnyBody"
post:
tags: [ordnance survey]
parameters:
- $ref: "#/components/schemas/AnyParams"
requestBody:
$ref: "#/components/schemas/AnyBody"
delete:
tags: [ordnance survey]
parameters:
- $ref: "#/components/schemas/AnyParams"
requestBody:
$ref: "#/components/schemas/AnyBody"
patch:
tags: [ordnance survey]
parameters:
- $ref: "#/components/schemas/AnyParams"
requestBody:
$ref: "#/components/schemas/AnyBody"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Request } from "express";
import nock from "nock";
import supertest from "supertest";
import app from "../server";
import { appendAPIKey, OS_DOMAIN } from "./ordnanceSurvey";
import app from "../../server";
import { appendAPIKey, OS_DOMAIN } from "./controller";

const { get } = supertest(app);

Expand Down
8 changes: 8 additions & 0 deletions api.planx.uk/modules/ordnanceSurvey/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Router } from "express";
import { useOrdnanceSurveyProxy } from "./controller";

const router = Router();

router.use("/proxy/ordnance-survey", useOrdnanceSurveyProxy);

export default router;
2 changes: 1 addition & 1 deletion api.planx.uk/pay/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Request } from "express";
import { fixRequestBody, Options } from "http-proxy-middleware";
import { useProxy } from "../proxy";
import { useProxy } from "../shared/middleware/proxy";

export const usePayProxy = (options: Partial<Options>, req: Request) => {
return useProxy({
Expand Down
5 changes: 2 additions & 3 deletions api.planx.uk/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import { downloadApplicationFiles, sendToEmail } from "./send/email";
import { sendToUniform } from "./send/uniform";
import { copyFlow } from "./editor/copyFlow";
import { moveFlow } from "./editor/moveFlow";
import { useOrdnanceSurveyProxy } from "./proxy/ordnanceSurvey";
import { gql } from "graphql-request";
import { classifiedRoadsSearch } from "./gis/classifiedRoads";
import { googleStrategy } from "./modules/auth/strategy/google";
Expand All @@ -64,6 +63,7 @@ import userRoutes from "./modules/user/routes";
import webhookRoutes from "./modules/webhooks/routes";
import analyticsRoutes from "./modules/analytics/routes";
import adminRoutes from "./modules/admin/routes";
import ordnanceSurveyRoutes from "./modules/ordnanceSurvey/routes";
import { useSwaggerDocs } from "./docs";
import { Role } from "@opensystemslab/planx-core/types";
import { $public } from "./client";
Expand Down Expand Up @@ -184,6 +184,7 @@ app.use("/team", teamRoutes);
app.use("/webhooks", webhookRoutes);
app.use("/analytics", analyticsRoutes);
app.use("/admin", adminRoutes);
app.use(ordnanceSurveyRoutes);

app.use("/gis", router);

Expand Down Expand Up @@ -358,8 +359,6 @@ app.post("/validate-session", validateSession);

app.post("/invite-to-pay/:sessionId", inviteToPay);

app.use("/proxy/ordnance-survey", useOrdnanceSurveyProxy);

const errorHandler: ErrorRequestHandler = (errorObject, _req, res, _next) => {
const { status = 500, message = "Something went wrong" } = (() => {
if (
Expand Down
File renamed without changes.

0 comments on commit c7be4d5

Please sign in to comment.