Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Drop redundant API endpoints #2289

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading