Skip to content

Commit

Permalink
feat(be): infotexts
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed Dec 5, 2024
1 parent 666e485 commit 5c36243
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { configModuleConfig } from "src/config/config-module.config";
import { GRAPHQL_PATH } from "src/constants/api";
import { DepartureModule } from "src/modules/departure/departure.module";
import { ImportModule } from "src/modules/import/import.module";
import { InfotextsModule } from "src/modules/infotexts/infotexts.module";
import { LoggerModule } from "src/modules/logger/logger.module";
import { PlatformModule } from "src/modules/platform/platform.module";
import { PrismaModule } from "src/modules/prisma/prisma.module";
Expand All @@ -24,6 +25,7 @@ import { StopModule } from "src/modules/stop/stop.module";
StopModule,
PrismaModule,
LoggerModule,
InfotextsModule,
StatusModule,
ConfigModule.forRoot(configModuleConfig),
ScheduleModule.forRoot(),
Expand Down
25 changes: 25 additions & 0 deletions apps/backend/src/modules/infotexts/infotexts.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { CacheInterceptor } from "@nestjs/cache-manager";
import { Controller, Get, UseInterceptors, Version } from "@nestjs/common";
import { ApiQuery, ApiTags } from "@nestjs/swagger";

import { ApiDescription } from "src/decorators/swagger.decorator";
import { EndpointVersion } from "src/enums/endpoint-version";
import { InfotextsService } from "src/modules/infotexts/infotexts.service";
import { metroOnlyQuery } from "src/swagger/query.swagger";

@ApiTags("infotexts")
@Controller("infotexts")
@UseInterceptors(CacheInterceptor)
export class InfotextsController {
constructor(private readonly infotextsService: InfotextsService) {}

@Get("/all")
@Version([EndpointVersion.v1])
@ApiDescription({
summary: "PID Infotexts",
})
@ApiQuery(metroOnlyQuery)
async getAllInfotexts() {
return await this.infotextsService.getInfotexts();
}
}
12 changes: 12 additions & 0 deletions apps/backend/src/modules/infotexts/infotexts.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Module } from "@nestjs/common";

import { GolemioService } from "src/modules/golemio/golemio.service";
import { InfotextsController } from "src/modules/infotexts/infotexts.controller";
import { InfotextsService } from "src/modules/infotexts/infotexts.service";

@Module({
controllers: [InfotextsController],
providers: [InfotextsService, GolemioService],
imports: [],
})
export class InfotextsModule {}
12 changes: 12 additions & 0 deletions apps/backend/src/modules/infotexts/infotexts.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Injectable } from "@nestjs/common";

import { GolemioService } from "src/modules/golemio/golemio.service";

@Injectable()
export class InfotextsService {
constructor(private golemioService: GolemioService) {}

async getInfotexts() {
return await this.golemioService.getGolemioData("/v3/pid/infotexts");
}
}

0 comments on commit 5c36243

Please sign in to comment.