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: Small tidy ups of API folder structure #2379

Merged
merged 2 commits into from
Nov 6, 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
4 changes: 2 additions & 2 deletions api.planx.uk/inviteToPay/createPaymentSendEvents.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import supertest from "supertest";
import app from "../server";
import { createScheduledEvent } from "../hasura/metadata";
import { createScheduledEvent } from "../lib/hasura/metadata";
import { queryMock } from "../tests/graphqlQueryMock";
import { flowWithInviteToPay } from "../tests/mocks/inviteToPayData";

jest.mock("../hasura/metadata");
jest.mock("../lib/hasura/metadata");
const mockedCreateScheduledEvent = createScheduledEvent as jest.MockedFunction<
typeof createScheduledEvent
>;
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/inviteToPay/createPaymentSendEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { $api, $public } from "../client";
import {
ScheduledEventResponse,
createScheduledEvent,
} from "../hasura/metadata";
} from "../lib/hasura/metadata";
import { getMostRecentPublishedFlow } from "../helpers";
import { Flow, Node, Team } from "../types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import supertest from "supertest";
import app from "../../../../server";
import { createScheduledEvent } from "../../../../hasura/metadata";
import { createScheduledEvent } from "../../../../lib/hasura/metadata";

const { post } = supertest(app);

jest.mock("../../../../hasura/metadata");
jest.mock("../../../../lib/hasura/metadata");
const mockedCreateScheduledEvent = createScheduledEvent as jest.MockedFunction<
typeof createScheduledEvent
>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addDays } from "date-fns";

import { createScheduledEvent } from "../../../../hasura/metadata";
import { createScheduledEvent } from "../../../../lib/hasura/metadata";
import {
DAYS_UNTIL_EXPIRY,
REMINDER_DAYS_FROM_EXPIRY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";
import { ValidatedRequestHandler } from "../../../../shared/middleware/validate";
import { ScheduledEventResponse } from "../../../../hasura/metadata";
import { ScheduledEventResponse } from "../../../../lib/hasura/metadata";

export const createSessionEventSchema = z.object({
body: z.object({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import supertest from "supertest";
import app from "../../../../server";
import { createScheduledEvent } from "../../../../hasura/metadata";
import { createScheduledEvent } from "../../../../lib/hasura/metadata";
import { CreatePaymentEvent } from "./schema";

const { post } = supertest(app);

jest.mock("../../../../hasura/metadata");
jest.mock("../../../../lib/hasura/metadata");
const mockedCreateScheduledEvent = createScheduledEvent as jest.MockedFunction<
typeof createScheduledEvent
>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addDays } from "date-fns";

import { createScheduledEvent } from "../../../../hasura/metadata";
import { createScheduledEvent } from "../../../../lib/hasura/metadata";
import {
DAYS_UNTIL_EXPIRY,
REMINDER_DAYS_FROM_EXPIRY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";
import { ValidatedRequestHandler } from "../../../../shared/middleware/validate";
import { ScheduledEventResponse } from "../../../../hasura/metadata";
import { ScheduledEventResponse } from "../../../../lib/hasura/metadata";

export const createPaymentEventSchema = z.object({
body: z.object({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { runSQL } from "../../../../hasura/schema";
import { runSQL } from "../../../../lib/hasura/schema";
import { queryMock } from "../../../../tests/graphqlQueryMock";
import {
mockIds,
Expand All @@ -25,7 +25,7 @@ import {
deleteHasuraScheduledEventsForSubmittedSessions,
} from "./operations";

jest.mock("../../../../hasura/schema");
jest.mock("../../../../lib/hasura/schema");
const mockRunSQL = runSQL as jest.MockedFunction<typeof runSQL>;

const mockFindSession = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { gql } from "graphql-request";
import { subMonths } from "date-fns";

import { Operation, OperationResult, QueryResult } from "./types";
import { runSQL } from "../../../../hasura/schema";
import { getFilesForSession } from "../../../../session/files";
import { runSQL } from "../../../../lib/hasura/schema";
import { deleteFilesByURL } from "../../../../s3/deleteFile";
import { $api } from "../../../../client";
import { Passport } from "@opensystemslab/planx-core";

const RETENTION_PERIOD_MONTHS = 6;
export const getRetentionPeriod = () =>
Expand Down Expand Up @@ -97,7 +97,11 @@ export const deleteApplicationFiles: Operation = async () => {

const sessionIds = await getExpiredSessionIds();
for (const sessionId of sessionIds) {
const files = await getFilesForSession(sessionId);
const session = await $api.session.find(sessionId);
if (!session) {
throw Error(`Unable to find session matching id ${sessionId}`);
}
const files = new Passport(session.data.passport).files();
if (files.length) {
const deleted = await deleteFilesByURL(files);
deletedFiles.push(...deleted);
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/send/createSendEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from "express";
import {
ScheduledEventResponse,
createScheduledEvent,
} from "../hasura/metadata";
} from "../lib/hasura/metadata";

interface CombinedResponse {
bops?: ScheduledEventResponse;
Expand Down
41 changes: 0 additions & 41 deletions api.planx.uk/session/files.test.ts

This file was deleted.

12 changes: 0 additions & 12 deletions api.planx.uk/session/files.ts

This file was deleted.

Loading