Skip to content

Commit

Permalink
chore: Drop redundant API endpoints (#2289)
Browse files Browse the repository at this point in the history
* chore: Drop redundant endpoints

* test: Drop redundant tests
  • Loading branch information
DafyddLlyr authored Oct 10, 2023
1 parent 396e20e commit 330006e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 64 deletions.
17 changes: 0 additions & 17 deletions api.planx.uk/server.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
import supertest from "supertest";

import { queryMock } from "./tests/graphqlQueryMock";
import app from "./server";

it("mocks hasura", async () => {
queryMock.mockQuery({
name: "GetTeams",
data: {
teams: [{ id: 1 }],
},
});

await supertest(app)
.get("/hasura")
.expect(200)
.then((res) => {
expect(res.body).toEqual({ teams: [{ id: 1 }] });
});
});

describe("authentication", () => {
test("Failed login endpoint", async () => {
await supertest(app)
Expand Down
29 changes: 0 additions & 29 deletions api.planx.uk/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,6 @@ app.use("/webhooks", webhookRoutes);

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

app.get("/hasura", async function (_req, res, next) {
try {
const data = await adminClient.request(gql`
query GetTeams {
teams {
id
}
}
`);
res.json(data);
} catch (err) {
next(err);
}
});

app.get("/gis", (_req, _res, next) => {
next({
status: 400,
Expand All @@ -227,12 +212,6 @@ app.get("/admin/session/:sessionId/html-redacted", getRedactedHTMLExport);
app.get("/admin/session/:sessionId/zip", generateZip);
app.get("/admin/session/:sessionId/summary", getSessionSummary);

// XXX: leaving this in temporarily as a testing endpoint to ensure it
// works correctly in staging and production
app.get("/throw-error", () => {
throw new Error("custom error");
});

app.post("/flows/:flowId/copy", useTeamEditorAuth, copyFlow);

app.post("/flows/:flowId/diff", useTeamEditorAuth, validateAndDiffFlow);
Expand Down Expand Up @@ -448,14 +427,6 @@ app.post("/invite-to-pay/:sessionId", inviteToPay);

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

app.get("/error", async (res, req, next) => {
try {
throw Error("This is a test error");
} catch (error) {
next(error);
}
});

const errorHandler: ErrorRequestHandler = (errorObject, _req, res, _next) => {
const { status = 500, message = "Something went wrong" } = (() => {
if (
Expand Down
18 changes: 0 additions & 18 deletions api.planx.uk/tests/serverErrorHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ describe("bad requests", () => {
await get("/pay/wrong/1").expect(400);
});

test(`app.get("/hasura")`, async () => {
await get("/hasura").expect(500);
});

test(`app.get("/me")`, async () => {
await get("/me")
.expect(401)
.then((response) => {
expect(response.body).toEqual({
error: "No authorization token was found",
});
});
});

test(`app.get("/gis")`, async () => {
await get("/gis").expect(400);
});
Expand All @@ -58,10 +44,6 @@ describe("bad requests", () => {
});
});

test(`app.get("/throw-error")`, async () => {
await get("/throw-error").expect(500);
});

test(`app.post("/flows/:flowId/publish")`, async () => {
await post("/flows/WRONG/publish").expect(401);
});
Expand Down

0 comments on commit 330006e

Please sign in to comment.