From 353db9f1460818c5b6736013872d0e36c954d512 Mon Sep 17 00:00:00 2001 From: Victor Klomp Date: Thu, 28 Nov 2024 00:50:10 +0100 Subject: [PATCH] refactor(poster): Restructure the files --- openapi-ts.config.ts | 2 +- src/modules/handlers/screen/index.ts | 4 ++-- .../poster/base-poster-screen-controller.ts | 10 ++++++++ .../gewis-poster-screen-controller.ts | 24 +++++++++---------- .../gewis-poster-screen-handler.ts | 2 +- .../{ => gewis}/gewis-poster-service.ts | 2 +- .../hubble-poster-screen-controller.ts | 14 +++++------ .../hubble-poster-screen-handler.ts | 2 +- 8 files changed, 35 insertions(+), 25 deletions(-) rename src/modules/handlers/screen/poster/{ => gewis}/gewis-poster-screen-controller.ts (82%) rename src/modules/handlers/screen/poster/{ => gewis}/gewis-poster-screen-handler.ts (73%) rename src/modules/handlers/screen/poster/{ => gewis}/gewis-poster-service.ts (93%) rename src/modules/handlers/screen/poster/{ => hubble}/hubble-poster-screen-controller.ts (66%) rename src/modules/handlers/screen/poster/{ => hubble}/hubble-poster-screen-handler.ts (73%) diff --git a/openapi-ts.config.ts b/openapi-ts.config.ts index 556051f..b1b3ba8 100644 --- a/openapi-ts.config.ts +++ b/openapi-ts.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from '@hey-api/openapi-ts'; export default defineConfig({ client: '@hey-api/client-fetch', input: './build/swagger.json', - output: `../narrowcasting-client/src/api/`, + output: `../aurora-client/src/api/`, plugins: [ '@hey-api/schemas', '@hey-api/services', diff --git a/src/modules/handlers/screen/index.ts b/src/modules/handlers/screen/index.ts index c692dc6..0e08312 100644 --- a/src/modules/handlers/screen/index.ts +++ b/src/modules/handlers/screen/index.ts @@ -1,7 +1,7 @@ export { default as CurrentlyPlayingTrackHandler } from './curently-playing-track-handler'; export { default as CenturionScreenHandler } from './centurion-screen-handler'; -export { default as GewisPosterScreenHandler } from './poster/gewis-poster-screen-handler'; -export { default as HubblePosterScreenHandler } from './poster/hubble-poster-screen-handler'; +export { default as GewisPosterScreenHandler } from './poster/gewis/gewis-poster-screen-handler'; +export { default as HubblePosterScreenHandler } from './poster/hubble/hubble-poster-screen-handler'; export { default as RoomResponsibleLegacyHandler } from './room-responsible-legacy-handler'; export { default as StageEffectsHandler } from './stage-effects-handler'; export { default as TimeTrailRaceScreenHandler } from './time-trail-race-screen-handler'; diff --git a/src/modules/handlers/screen/poster/base-poster-screen-controller.ts b/src/modules/handlers/screen/poster/base-poster-screen-controller.ts index 522df42..a23e9d5 100644 --- a/src/modules/handlers/screen/poster/base-poster-screen-controller.ts +++ b/src/modules/handlers/screen/poster/base-poster-screen-controller.ts @@ -4,6 +4,8 @@ import { Request as ExpressRequest } from 'express'; import BasePosterScreenHandler from './base-poster-screen-handler'; import { Poster } from './poster'; import logger from '../../../../logger'; +import OlympicsService from "./olympics-service"; +import NsTrainsService, {TrainResponse} from "./ns-trains-service"; export interface BorrelModeParams { enabled: boolean; @@ -39,4 +41,12 @@ export class BasePosterScreenController extends Controller { await this.screenHandler.posterManager.fetchPosters(); this.screenHandler.forceUpdate(); } + + public async getTrains(): Promise { + return new NsTrainsService().getTrains(); + } + + public async getOlympicsMedalTable() { + return new OlympicsService().getMedalTable(); + } } diff --git a/src/modules/handlers/screen/poster/gewis-poster-screen-controller.ts b/src/modules/handlers/screen/poster/gewis/gewis-poster-screen-controller.ts similarity index 82% rename from src/modules/handlers/screen/poster/gewis-poster-screen-controller.ts rename to src/modules/handlers/screen/poster/gewis/gewis-poster-screen-controller.ts index 12fb0ae..0dcad5a 100644 --- a/src/modules/handlers/screen/poster/gewis-poster-screen-controller.ts +++ b/src/modules/handlers/screen/poster/gewis/gewis-poster-screen-controller.ts @@ -1,16 +1,16 @@ -import {BasePosterResponse, BasePosterScreenController, BorrelModeParams} from "./base-poster-screen-controller"; -import HandlerManager from "../../../root/handler-manager"; -import {Screen} from "../../../root/entities"; -import BasePosterScreenHandler from "./base-poster-screen-handler"; -import {GewisPosterScreenHandler} from "../index"; +import {BasePosterResponse, BasePosterScreenController, BorrelModeParams} from "../base-poster-screen-controller"; +import HandlerManager from "../../../../root/handler-manager"; +import {Screen} from "../../../../root/entities"; +import BasePosterScreenHandler from "../base-poster-screen-handler"; +import {GewisPosterScreenHandler} from "../../index"; import {Body, Get, Post, Put, Query, Request, Route, Security, Tags} from "tsoa"; -import {SecurityNames} from "../../../../helpers/security"; -import {securityGroups} from "../../../../helpers/security-groups"; -import logger from "../../../../logger"; +import {SecurityNames} from "../../../../../helpers/security"; +import {securityGroups} from "../../../../../helpers/security-groups"; +import logger from "../../../../../logger"; import {Request as ExpressRequest} from "express"; -import NsTrainsService, {TrainResponse} from "./ns-trains-service"; +import {TrainResponse} from "../ns-trains-service"; import GEWISPosterService, {GEWISPhotoAlbumParams} from "./gewis-poster-service"; -import OlympicsService from "./olympics-service"; +import OlympicsService from "../olympics-service"; interface GewisPosterResponse extends BasePosterResponse { borrelMode: boolean; @@ -77,7 +77,7 @@ export class GewisPosterScreenController extends BasePosterScreenController { @Security(SecurityNames.LOCAL, securityGroups.poster.base) @Get('train-departures') public async getTrains(): Promise { - return new NsTrainsService().getTrains(); + return super.getTrains(); } @Security(SecurityNames.LOCAL, securityGroups.poster.base) @@ -89,7 +89,7 @@ export class GewisPosterScreenController extends BasePosterScreenController { @Security(SecurityNames.LOCAL, securityGroups.poster.base) @Get('olympics/medal-table') public async getOlympicsMedalTable() { - return new OlympicsService().getMedalTable(); + return super.getOlympicsMedalTable(); } @Security(SecurityNames.LOCAL, securityGroups.poster.base) diff --git a/src/modules/handlers/screen/poster/gewis-poster-screen-handler.ts b/src/modules/handlers/screen/poster/gewis/gewis-poster-screen-handler.ts similarity index 73% rename from src/modules/handlers/screen/poster/gewis-poster-screen-handler.ts rename to src/modules/handlers/screen/poster/gewis/gewis-poster-screen-handler.ts index ff5aafa..97af0fb 100644 --- a/src/modules/handlers/screen/poster/gewis-poster-screen-handler.ts +++ b/src/modules/handlers/screen/poster/gewis/gewis-poster-screen-handler.ts @@ -1,4 +1,4 @@ -import BasePosterScreenHandler from "./base-poster-screen-handler"; +import BasePosterScreenHandler from "../base-poster-screen-handler"; import { Namespace } from "socket.io"; diff --git a/src/modules/handlers/screen/poster/gewis-poster-service.ts b/src/modules/handlers/screen/poster/gewis/gewis-poster-service.ts similarity index 93% rename from src/modules/handlers/screen/poster/gewis-poster-service.ts rename to src/modules/handlers/screen/poster/gewis/gewis-poster-service.ts index 5cc3644..b868744 100644 --- a/src/modules/handlers/screen/poster/gewis-poster-service.ts +++ b/src/modules/handlers/screen/poster/gewis/gewis-poster-service.ts @@ -1,5 +1,5 @@ import axios, { AxiosError } from 'axios'; -import { HttpApiException } from '../../../../helpers/custom-error'; +import { HttpApiException } from '../../../../../helpers/custom-error'; export interface GEWISPhotoAlbumParams { albumIds: number[]; diff --git a/src/modules/handlers/screen/poster/hubble-poster-screen-controller.ts b/src/modules/handlers/screen/poster/hubble/hubble-poster-screen-controller.ts similarity index 66% rename from src/modules/handlers/screen/poster/hubble-poster-screen-controller.ts rename to src/modules/handlers/screen/poster/hubble/hubble-poster-screen-controller.ts index d1bf798..8dff46e 100644 --- a/src/modules/handlers/screen/poster/hubble-poster-screen-controller.ts +++ b/src/modules/handlers/screen/poster/hubble/hubble-poster-screen-controller.ts @@ -1,11 +1,11 @@ -import {BasePosterResponse, BasePosterScreenController} from "./base-poster-screen-controller"; -import HandlerManager from "../../../root/handler-manager"; -import {Screen} from "../../../root/entities"; -import BasePosterScreenHandler from "./base-poster-screen-handler"; -import {HubblePosterScreenHandler} from "../index"; +import {BasePosterResponse, BasePosterScreenController} from "../base-poster-screen-controller"; +import HandlerManager from "../../../../root/handler-manager"; +import {Screen} from "../../../../root/entities"; +import BasePosterScreenHandler from "../base-poster-screen-handler"; +import {HubblePosterScreenHandler} from "../../index"; import {Get, Post, Request, Route, Security, Tags} from "tsoa"; -import {SecurityNames} from "../../../../helpers/security"; -import {securityGroups} from "../../../../helpers/security-groups"; +import {SecurityNames} from "../../../../../helpers/security"; +import {securityGroups} from "../../../../../helpers/security-groups"; import {Request as ExpressRequest} from "express"; @Route('handler/screen/hubble-poster') diff --git a/src/modules/handlers/screen/poster/hubble-poster-screen-handler.ts b/src/modules/handlers/screen/poster/hubble/hubble-poster-screen-handler.ts similarity index 73% rename from src/modules/handlers/screen/poster/hubble-poster-screen-handler.ts rename to src/modules/handlers/screen/poster/hubble/hubble-poster-screen-handler.ts index 350cffc..6dc34ec 100644 --- a/src/modules/handlers/screen/poster/hubble-poster-screen-handler.ts +++ b/src/modules/handlers/screen/poster/hubble/hubble-poster-screen-handler.ts @@ -1,4 +1,4 @@ -import BasePosterScreenHandler from "./base-poster-screen-handler"; +import BasePosterScreenHandler from "../base-poster-screen-handler"; import { Namespace } from "socket.io"; export default class HubblePosterScreenHandler extends BasePosterScreenHandler {