messing around with the backend
Some checks failed
Deploy Backend / deploy (push) Successful in 1m36s
Deploy Website / deploy (push) Has been cancelled

This commit is contained in:
Lee 2024-10-04 23:59:29 +01:00
parent 296179a10b
commit e202d72331
11 changed files with 90 additions and 16 deletions

View File

@ -39,7 +39,6 @@ jobs:
git.fascinated.cc/fascinated/scoresaber-reloaded-backend:latest
build-args: |
GIT_REV=${{ gitea.sha }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Install kubectl
uses: azure/setup-kubectl@v4

View File

@ -6,6 +6,9 @@ ENV PNPM_HOME=/usr/local/bin
WORKDIR /app
ARG GIT_REV
ENV GIT_REV=${GIT_REV}
# Copy necessary files for installation
COPY package.json* pnpm-lock.yaml* pnpm-workspace.yaml* ./
COPY common ./common

View File

@ -1,10 +1,12 @@
import { Module } from "@nestjs/common";
import { AppController } from "./controller/app.controller";
import { PlayerService } from "./service/player.service";
import { PlayerController } from "./controller/player.controller";
import { AppService } from "./service/app.service";
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
controllers: [AppController, PlayerController],
providers: [AppService, PlayerService],
})
export class AppModule {}

View File

@ -6,7 +6,10 @@ export class AppController {
constructor(private readonly appService: AppService) {}
@Get("/")
getHello(): string {
return this.appService.getHello();
getHome() {
return {
message: "ScoreSaber Reloaded API",
version: this.appService.getVersion(),
};
}
}

View File

@ -0,0 +1,12 @@
import { Controller, Get, Param } from "@nestjs/common";
import { PlayerService } from "../service/player.service";
@Controller("/player")
export class PlayerController {
constructor(private readonly playerService: PlayerService) {}
@Get("/history/:id")
getHistory(@Param("id") id: string) {
return this.playerService.getHistory(id);
}
}

View File

@ -1,9 +1,14 @@
import { Injectable } from "@nestjs/common";
import { helloMeowMeow } from "@ssr/common/dist";
import { isProduction } from "@ssr/common/dist";
@Injectable()
export class AppService {
getHello(): string {
return helloMeowMeow();
/**
* Gets the app version.
*
* @returns the app version
*/
getVersion(): string {
return `1.0.0-${isProduction() ? process.env.GIT_REV.substring(0, 7) : "dev"}`;
}
}

View File

@ -0,0 +1,16 @@
import { Injectable } from "@nestjs/common";
@Injectable()
export class PlayerService {
/**
* Gets the statistic history for the given player
*
* @param id the id of the player
* @returns the players statistic history
*/
getHistory(id: string) {
return {
id: id,
};
}
}

View File

@ -6,6 +6,7 @@
"build": "tsup src/index.ts"
},
"devDependencies": {
"@types/node": "^22.7.4",
"tsup": "^6.5.0",
"typescript": "^5"
}

View File

@ -1,3 +1 @@
export function helloMeowMeow() {
return "hi";
}
export * from "src/utils";

6
common/src/utils.ts Normal file
View File

@ -0,0 +1,6 @@
/**
* Checks if we're in production
*/
export function isProduction() {
return process.env.NODE_ENV === "production";
}

39
pnpm-lock.yaml generated
View File

@ -98,9 +98,12 @@ importers:
common:
devDependencies:
'@types/node':
specifier: ^22.7.4
version: 22.7.4
tsup:
specifier: ^6.5.0
version: 6.7.0(postcss@8.4.47)(ts-node@10.9.2(@types/node@20.16.10)(typescript@5.6.2))(typescript@5.6.2)
version: 6.7.0(postcss@8.4.47)(ts-node@10.9.2(@types/node@22.7.4)(typescript@5.6.2))(typescript@5.6.2)
typescript:
specifier: ^5
version: 5.6.2
@ -2017,6 +2020,9 @@ packages:
'@types/node@20.16.10':
resolution: {integrity: sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==}
'@types/node@22.7.4':
resolution: {integrity: sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==}
'@types/pg-pool@2.0.6':
resolution: {integrity: sha512-TaAUE5rq2VQYxab5Ts7WZhKNmuN78Q6PiFonTDdpbx8a1H0M1vhy3rhiMjl+e2iHmogyMw7jZF4FrE6eJUy5HQ==}
@ -7040,6 +7046,10 @@ snapshots:
dependencies:
undici-types: 6.19.8
'@types/node@22.7.4':
dependencies:
undici-types: 6.19.8
'@types/pg-pool@2.0.6':
dependencies:
'@types/pg': 8.6.1
@ -9505,13 +9515,13 @@ snapshots:
camelcase-css: 2.0.1
postcss: 8.4.47
postcss-load-config@3.1.4(postcss@8.4.47)(ts-node@10.9.2(@types/node@20.16.10)(typescript@5.6.2)):
postcss-load-config@3.1.4(postcss@8.4.47)(ts-node@10.9.2(@types/node@22.7.4)(typescript@5.6.2)):
dependencies:
lilconfig: 2.1.0
yaml: 1.10.2
optionalDependencies:
postcss: 8.4.47
ts-node: 10.9.2(@types/node@20.16.10)(typescript@5.6.2)
ts-node: 10.9.2(@types/node@22.7.4)(typescript@5.6.2)
postcss-load-config@4.0.2(postcss@8.4.47)(ts-node@10.9.2(@types/node@20.16.10)(typescript@5.6.2)):
dependencies:
@ -10309,6 +10319,25 @@ snapshots:
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
ts-node@10.9.2(@types/node@22.7.4)(typescript@5.6.2):
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.11
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.4
'@types/node': 22.7.4
acorn: 8.12.1
acorn-walk: 8.3.4
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
typescript: 5.6.2
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
optional: true
tsafe@1.7.5: {}
tsconfig-paths-webpack-plugin@4.1.0:
@ -10332,7 +10361,7 @@ snapshots:
tslib@2.7.0: {}
tsup@6.7.0(postcss@8.4.47)(ts-node@10.9.2(@types/node@20.16.10)(typescript@5.6.2))(typescript@5.6.2):
tsup@6.7.0(postcss@8.4.47)(ts-node@10.9.2(@types/node@22.7.4)(typescript@5.6.2))(typescript@5.6.2):
dependencies:
bundle-require: 4.2.1(esbuild@0.17.19)
cac: 6.7.14
@ -10342,7 +10371,7 @@ snapshots:
execa: 5.1.1
globby: 11.1.0
joycon: 3.1.1
postcss-load-config: 3.1.4(postcss@8.4.47)(ts-node@10.9.2(@types/node@20.16.10)(typescript@5.6.2))
postcss-load-config: 3.1.4(postcss@8.4.47)(ts-node@10.9.2(@types/node@22.7.4)(typescript@5.6.2))
resolve-from: 5.0.0
rollup: 3.29.5
source-map: 0.8.0-beta.0