diff --git a/.gitea/kubernetes/backend/ingress.yaml b/.gitea/kubernetes/backend/ingress.yaml index 2de160a..823ad7d 100644 --- a/.gitea/kubernetes/backend/ingress.yaml +++ b/.gitea/kubernetes/backend/ingress.yaml @@ -24,3 +24,29 @@ spec: port: 8080 tls: secretName: fascinated-cc +--- +apiVersion: traefik.io/v1alpha1 +kind: IngressRoute +metadata: + name: scoresaber-reloaded-backend-swagger-ingress + namespace: public-services + annotations: + kubernetes.io/ingress.class: traefik-external +spec: + entryPoints: + - websecure + routes: + - match: Host(`ssr.fascinated.cc`) && PathPrefix(`/swagger`) + kind: Rule + middlewares: + - name: default-headers + namespace: traefik + - name: compress + namespace: traefik + - name: scoresaber-reloaded-backend-strip-swagger-prefix + namespace: public-services + services: + - name: scoresaber-reloaded-backend-service + port: 8080 + tls: + secretName: fascinated-cc diff --git a/.gitea/kubernetes/backend/strip-swagger-prefix-middleware.yaml b/.gitea/kubernetes/backend/strip-swagger-prefix-middleware.yaml new file mode 100644 index 0000000..a6a54b1 --- /dev/null +++ b/.gitea/kubernetes/backend/strip-swagger-prefix-middleware.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: traefik.io/v1alpha1 +kind: Middleware +metadata: + name: scoresaber-reloaded-backend-strip-swagger-prefix + namespace: public-services +spec: + stripPrefix: + prefixes: + - "/swagger" diff --git a/.gitea/workflows/deploy-backend.yml b/.gitea/workflows/deploy-backend.yml index 005cd67..ac7c123 100644 --- a/.gitea/workflows/deploy-backend.yml +++ b/.gitea/workflows/deploy-backend.yml @@ -59,6 +59,7 @@ jobs: .gitea/kubernetes/backend/deployment.yaml .gitea/kubernetes/backend/service.yaml .gitea/kubernetes/backend/strip-api-prefix-middleware.yaml + .gitea/kubernetes/backend/strip-swagger-prefix-middleware.yaml .gitea/kubernetes/backend/ingress.yaml images: | git.fascinated.cc/fascinated/scoresaber-reloaded-backend:${{ github.sha }} diff --git a/projects/backend/src/index.ts b/projects/backend/src/index.ts index 1417faf..a81e23b 100644 --- a/projects/backend/src/index.ts +++ b/projects/backend/src/index.ts @@ -24,6 +24,7 @@ import ScoresController from "./controller/scores.controller"; import LeaderboardController from "./controller/leaderboard.controller"; import { DiscordChannels, initDiscordBot, logToChannel } from "./bot/bot"; import { EmbedBuilder } from "discord.js"; +import { getAppVersion } from "./common/app.util"; // Load .env file dotenv.config({ @@ -163,7 +164,12 @@ app.use( */ app.use( swagger({ - path: isProduction() ? "/api/swagger" : "/swagger", + documentation: { + info: { + title: "ScoreSaber Reloaded Documentation", + version: await getAppVersion(), + }, + }, }) );