From eeed25ddcd3ff660c66e474d35dcc0aeb8486894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Tue, 3 Oct 2023 11:36:47 +0100 Subject: [PATCH] refactor: Move to /service folder --- api.planx.uk/modules/webhooks/controller.ts | 12 ++++++------ api.planx.uk/modules/webhooks/routes.ts | 6 +++--- .../{ => service}/lowcalSessionEvents/index.test.ts | 6 +++--- .../lowcalSessionEvents/index.ts} | 4 ++-- .../{ => service}/lowcalSessionEvents/schema.ts | 4 ++-- .../{ => service}/paymentRequestEvents/index.test.ts | 6 +++--- .../paymentRequestEvents/index.ts} | 4 ++-- .../{ => service}/paymentRequestEvents/schema.ts | 4 ++-- .../{ => service}/sendNotification/index.test.ts | 6 +++--- .../service.ts => service/sendNotification/index.ts} | 2 +- .../{ => service}/sendNotification/schema.ts | 0 .../webhooks/{ => service}/sendNotification/types.ts | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) rename api.planx.uk/modules/webhooks/{ => service}/lowcalSessionEvents/index.test.ts (97%) rename api.planx.uk/modules/webhooks/{lowcalSessionEvents/service.ts => service/lowcalSessionEvents/index.ts} (91%) rename api.planx.uk/modules/webhooks/{ => service}/lowcalSessionEvents/schema.ts (74%) rename api.planx.uk/modules/webhooks/{ => service}/paymentRequestEvents/index.test.ts (98%) rename api.planx.uk/modules/webhooks/{paymentRequestEvents/service.ts => service/paymentRequestEvents/index.ts} (96%) rename api.planx.uk/modules/webhooks/{ => service}/paymentRequestEvents/schema.ts (75%) rename api.planx.uk/modules/webhooks/{ => service}/sendNotification/index.test.ts (98%) rename api.planx.uk/modules/webhooks/{sendNotification/service.ts => service/sendNotification/index.ts} (97%) rename api.planx.uk/modules/webhooks/{ => service}/sendNotification/schema.ts (100%) rename api.planx.uk/modules/webhooks/{ => service}/sendNotification/types.ts (92%) diff --git a/api.planx.uk/modules/webhooks/controller.ts b/api.planx.uk/modules/webhooks/controller.ts index c4e8e33bc2..cfcb0b6ec8 100644 --- a/api.planx.uk/modules/webhooks/controller.ts +++ b/api.planx.uk/modules/webhooks/controller.ts @@ -1,17 +1,17 @@ import { ServerError } from "../../errors"; -import { CreateSessionEventController } from "./lowcalSessionEvents/schema"; +import { CreateSessionEventController } from "./service/lowcalSessionEvents/schema"; import { createSessionExpiryEvent, createSessionReminderEvent, -} from "./lowcalSessionEvents/service"; -import { CreatePaymentEventController } from "./paymentRequestEvents/schema"; +} from "./service/lowcalSessionEvents"; +import { SendSlackNotification } from "./service/sendNotification/types"; +import { sendSlackNotification } from "./service/sendNotification"; +import { CreatePaymentEventController } from "./service/paymentRequestEvents/schema"; import { createPaymentExpiryEvents, createPaymentInvitationEvents, createPaymentReminderEvents, -} from "./paymentRequestEvents/service"; -import { sendSlackNotification } from "./sendNotification/service"; -import { SendSlackNotification } from "./sendNotification/types"; +} from "./service/paymentRequestEvents"; export const sendSlackNotificationController: SendSlackNotification = async ( req, diff --git a/api.planx.uk/modules/webhooks/routes.ts b/api.planx.uk/modules/webhooks/routes.ts index dff88ba2ea..5e2535e359 100644 --- a/api.planx.uk/modules/webhooks/routes.ts +++ b/api.planx.uk/modules/webhooks/routes.ts @@ -11,9 +11,9 @@ import { createSessionReminderEventController, sendSlackNotificationController, } from "./controller"; -import { sendSlackNotificationSchema } from "./sendNotification/schema"; -import { createPaymentEventSchema } from "./paymentRequestEvents/schema"; -import { createSessionEventSchema } from "./lowcalSessionEvents/schema"; +import { sendSlackNotificationSchema } from "./service/sendNotification/schema"; +import { createPaymentEventSchema } from "./service//paymentRequestEvents/schema"; +import { createSessionEventSchema } from "./service/lowcalSessionEvents/schema"; const router = Router(); diff --git a/api.planx.uk/modules/webhooks/lowcalSessionEvents/index.test.ts b/api.planx.uk/modules/webhooks/service/lowcalSessionEvents/index.test.ts similarity index 97% rename from api.planx.uk/modules/webhooks/lowcalSessionEvents/index.test.ts rename to api.planx.uk/modules/webhooks/service/lowcalSessionEvents/index.test.ts index 86bfdadc4b..8f557a4686 100644 --- a/api.planx.uk/modules/webhooks/lowcalSessionEvents/index.test.ts +++ b/api.planx.uk/modules/webhooks/service/lowcalSessionEvents/index.test.ts @@ -1,10 +1,10 @@ import supertest from "supertest"; -import app from "../../../server"; -import { createScheduledEvent } from "../../../hasura/metadata"; +import app from "../../../../server"; +import { createScheduledEvent } from "../../../../hasura/metadata"; const { post } = supertest(app); -jest.mock("../../../hasura/metadata"); +jest.mock("../../../../hasura/metadata"); const mockedCreateScheduledEvent = createScheduledEvent as jest.MockedFunction< typeof createScheduledEvent >; diff --git a/api.planx.uk/modules/webhooks/lowcalSessionEvents/service.ts b/api.planx.uk/modules/webhooks/service/lowcalSessionEvents/index.ts similarity index 91% rename from api.planx.uk/modules/webhooks/lowcalSessionEvents/service.ts rename to api.planx.uk/modules/webhooks/service/lowcalSessionEvents/index.ts index 357655864a..b8ec4cf072 100644 --- a/api.planx.uk/modules/webhooks/lowcalSessionEvents/service.ts +++ b/api.planx.uk/modules/webhooks/service/lowcalSessionEvents/index.ts @@ -1,10 +1,10 @@ import { addDays } from "date-fns"; -import { createScheduledEvent } from "../../../hasura/metadata"; +import { createScheduledEvent } from "../../../../hasura/metadata"; import { DAYS_UNTIL_EXPIRY, REMINDER_DAYS_FROM_EXPIRY, -} from "../../../saveAndReturn/utils"; +} from "../../../../saveAndReturn/utils"; import { CreateSessionEvent } from "./schema"; /** diff --git a/api.planx.uk/modules/webhooks/lowcalSessionEvents/schema.ts b/api.planx.uk/modules/webhooks/service/lowcalSessionEvents/schema.ts similarity index 74% rename from api.planx.uk/modules/webhooks/lowcalSessionEvents/schema.ts rename to api.planx.uk/modules/webhooks/service/lowcalSessionEvents/schema.ts index deed195cf8..53e73f0b06 100644 --- a/api.planx.uk/modules/webhooks/lowcalSessionEvents/schema.ts +++ b/api.planx.uk/modules/webhooks/service/lowcalSessionEvents/schema.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -import { ValidatedRequestHandler } from "../../../shared/middleware/validate"; -import { ScheduledEventResponse } from "../../../hasura/metadata"; +import { ValidatedRequestHandler } from "../../../../shared/middleware/validate"; +import { ScheduledEventResponse } from "../../../../hasura/metadata"; export const createSessionEventSchema = z.object({ body: z.object({ diff --git a/api.planx.uk/modules/webhooks/paymentRequestEvents/index.test.ts b/api.planx.uk/modules/webhooks/service/paymentRequestEvents/index.test.ts similarity index 98% rename from api.planx.uk/modules/webhooks/paymentRequestEvents/index.test.ts rename to api.planx.uk/modules/webhooks/service/paymentRequestEvents/index.test.ts index e12216ea99..20beeefd98 100644 --- a/api.planx.uk/modules/webhooks/paymentRequestEvents/index.test.ts +++ b/api.planx.uk/modules/webhooks/service/paymentRequestEvents/index.test.ts @@ -1,11 +1,11 @@ import supertest from "supertest"; -import app from "../../../server"; -import { createScheduledEvent } from "../../../hasura/metadata"; +import app from "../../../../server"; +import { createScheduledEvent } from "../../../../hasura/metadata"; import { CreatePaymentEvent } from "./schema"; const { post } = supertest(app); -jest.mock("../../../hasura/metadata"); +jest.mock("../../../../hasura/metadata"); const mockedCreateScheduledEvent = createScheduledEvent as jest.MockedFunction< typeof createScheduledEvent >; diff --git a/api.planx.uk/modules/webhooks/paymentRequestEvents/service.ts b/api.planx.uk/modules/webhooks/service/paymentRequestEvents/index.ts similarity index 96% rename from api.planx.uk/modules/webhooks/paymentRequestEvents/service.ts rename to api.planx.uk/modules/webhooks/service/paymentRequestEvents/index.ts index d60822d036..9679c7931e 100644 --- a/api.planx.uk/modules/webhooks/paymentRequestEvents/service.ts +++ b/api.planx.uk/modules/webhooks/service/paymentRequestEvents/index.ts @@ -1,10 +1,10 @@ import { addDays } from "date-fns"; -import { createScheduledEvent } from "../../../hasura/metadata"; +import { createScheduledEvent } from "../../../../hasura/metadata"; import { DAYS_UNTIL_EXPIRY, REMINDER_DAYS_FROM_EXPIRY, -} from "../../../saveAndReturn/utils"; +} from "../../../../saveAndReturn/utils"; import { CreatePaymentEvent } from "./schema"; /** diff --git a/api.planx.uk/modules/webhooks/paymentRequestEvents/schema.ts b/api.planx.uk/modules/webhooks/service/paymentRequestEvents/schema.ts similarity index 75% rename from api.planx.uk/modules/webhooks/paymentRequestEvents/schema.ts rename to api.planx.uk/modules/webhooks/service/paymentRequestEvents/schema.ts index 293f64a541..5b7a48404c 100644 --- a/api.planx.uk/modules/webhooks/paymentRequestEvents/schema.ts +++ b/api.planx.uk/modules/webhooks/service/paymentRequestEvents/schema.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -import { ValidatedRequestHandler } from "../../../shared/middleware/validate"; -import { ScheduledEventResponse } from "../../../hasura/metadata"; +import { ValidatedRequestHandler } from "../../../../shared/middleware/validate"; +import { ScheduledEventResponse } from "../../../../hasura/metadata"; export const createPaymentEventSchema = z.object({ body: z.object({ diff --git a/api.planx.uk/modules/webhooks/sendNotification/index.test.ts b/api.planx.uk/modules/webhooks/service/sendNotification/index.test.ts similarity index 98% rename from api.planx.uk/modules/webhooks/sendNotification/index.test.ts rename to api.planx.uk/modules/webhooks/service/sendNotification/index.test.ts index 9ecf4244cd..d3a4d25a54 100644 --- a/api.planx.uk/modules/webhooks/sendNotification/index.test.ts +++ b/api.planx.uk/modules/webhooks/service/sendNotification/index.test.ts @@ -1,8 +1,8 @@ import supertest from "supertest"; -import app from "../../../server"; +import app from "../../../../server"; import SlackNotify from "slack-notify"; import { BOPSBody, EmailBody, UniformBody } from "./types"; -import { $admin } from "../../../client"; +import { $admin } from "../../../../client"; import { CoreDomainClient } from "@opensystemslab/planx-core"; const mockSessionWithFee = { @@ -35,7 +35,7 @@ const mockSessionWithResubmissionExemption = { }, }; -jest.mock("../../../client"); +jest.mock("../../../../client"); const mockAdmin = jest.mocked($admin); const mockSend = jest.fn(); diff --git a/api.planx.uk/modules/webhooks/sendNotification/service.ts b/api.planx.uk/modules/webhooks/service/sendNotification/index.ts similarity index 97% rename from api.planx.uk/modules/webhooks/sendNotification/service.ts rename to api.planx.uk/modules/webhooks/service/sendNotification/index.ts index be8678a0e9..e0dfd36947 100644 --- a/api.planx.uk/modules/webhooks/sendNotification/service.ts +++ b/api.planx.uk/modules/webhooks/service/sendNotification/index.ts @@ -7,7 +7,7 @@ import { EventType, UniformEventData, } from "./types"; -import { $admin } from "../../../client"; +import { $admin } from "../../../../client"; export const sendSlackNotification = async ( data: EventData, diff --git a/api.planx.uk/modules/webhooks/sendNotification/schema.ts b/api.planx.uk/modules/webhooks/service/sendNotification/schema.ts similarity index 100% rename from api.planx.uk/modules/webhooks/sendNotification/schema.ts rename to api.planx.uk/modules/webhooks/service/sendNotification/schema.ts diff --git a/api.planx.uk/modules/webhooks/sendNotification/types.ts b/api.planx.uk/modules/webhooks/service/sendNotification/types.ts similarity index 92% rename from api.planx.uk/modules/webhooks/sendNotification/types.ts rename to api.planx.uk/modules/webhooks/service/sendNotification/types.ts index cd1e293bf9..1575f45429 100644 --- a/api.planx.uk/modules/webhooks/sendNotification/types.ts +++ b/api.planx.uk/modules/webhooks/service/sendNotification/types.ts @@ -1,5 +1,5 @@ import { z } from "zod"; -import { ValidatedRequestHandler } from "../../../shared/middleware/validate"; +import { ValidatedRequestHandler } from "../../../../shared/middleware/validate"; import { bopsSubmissionSchema, emailSubmissionSchema,