From e5bfa8afa03b97c8ed99a6bb2ce34a422272b71d Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 4 Oct 2024 23:14:26 +0100 Subject: [PATCH] strip api prefix middleware --- .gitea/kubernetes/backend/ingress.yaml | 2 ++ .../backend/strip-api-prefix-middleware.yaml | 10 ++++++++++ .gitea/workflows/deploy-backend.yml | 1 + backend/src/controller/app.controller.ts | 2 +- backend/src/main.ts | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .gitea/kubernetes/backend/strip-api-prefix-middleware.yaml diff --git a/.gitea/kubernetes/backend/ingress.yaml b/.gitea/kubernetes/backend/ingress.yaml index 36563f2..2de160a 100644 --- a/.gitea/kubernetes/backend/ingress.yaml +++ b/.gitea/kubernetes/backend/ingress.yaml @@ -17,6 +17,8 @@ spec: namespace: traefik - name: compress namespace: traefik + - name: scoresaber-reloaded-backend-strip-api-prefix + namespace: public-services services: - name: scoresaber-reloaded-backend-service port: 8080 diff --git a/.gitea/kubernetes/backend/strip-api-prefix-middleware.yaml b/.gitea/kubernetes/backend/strip-api-prefix-middleware.yaml new file mode 100644 index 0000000..19f113b --- /dev/null +++ b/.gitea/kubernetes/backend/strip-api-prefix-middleware.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: traefik.io/v1alpha1 +kind: Middleware +metadata: + name: scoresaber-reloaded-backend-strip-api-prefix + namespace: public-services +spec: + stripPrefix: + prefixes: + - "/api" diff --git a/.gitea/workflows/deploy-backend.yml b/.gitea/workflows/deploy-backend.yml index d77a3ee..8b6a85f 100644 --- a/.gitea/workflows/deploy-backend.yml +++ b/.gitea/workflows/deploy-backend.yml @@ -58,6 +58,7 @@ jobs: manifests: | .gitea/kubernetes/backend/deployment.yaml .gitea/kubernetes/backend/service.yaml + .gitea/kubernetes/backend/strip-api-prefix-middleware.yaml .gitea/kubernetes/backend/ingress.yaml images: | git.fascinated.cc/fascinated/scoresaber-reloaded-backend:${{ github.sha }} diff --git a/backend/src/controller/app.controller.ts b/backend/src/controller/app.controller.ts index 8e8a071..6b01dc2 100644 --- a/backend/src/controller/app.controller.ts +++ b/backend/src/controller/app.controller.ts @@ -5,7 +5,7 @@ import { AppService } from "../service/app.service"; export class AppController { constructor(private readonly appService: AppService) {} - @Get() + @Get("/") getHello(): string { return this.appService.getHello(); } diff --git a/backend/src/main.ts b/backend/src/main.ts index c801e34..525b536 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -3,7 +3,7 @@ import { AppModule } from "./app.module"; async function bootstrap() { const app = await NestFactory.create(AppModule, { - logger: ["error", "warn"], + logger: ["error", "warn", "log", "fatal"], }); await app.listen(8080); }