messing around with the backend
This commit is contained in:
parent
296179a10b
commit
e202d72331
@ -39,7 +39,6 @@ jobs:
|
|||||||
git.fascinated.cc/fascinated/scoresaber-reloaded-backend:latest
|
git.fascinated.cc/fascinated/scoresaber-reloaded-backend:latest
|
||||||
build-args: |
|
build-args: |
|
||||||
GIT_REV=${{ gitea.sha }}
|
GIT_REV=${{ gitea.sha }}
|
||||||
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
||||||
|
|
||||||
- name: Install kubectl
|
- name: Install kubectl
|
||||||
uses: azure/setup-kubectl@v4
|
uses: azure/setup-kubectl@v4
|
||||||
|
@ -6,6 +6,9 @@ ENV PNPM_HOME=/usr/local/bin
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
ARG GIT_REV
|
||||||
|
ENV GIT_REV=${GIT_REV}
|
||||||
|
|
||||||
# Copy necessary files for installation
|
# Copy necessary files for installation
|
||||||
COPY package.json* pnpm-lock.yaml* pnpm-workspace.yaml* ./
|
COPY package.json* pnpm-lock.yaml* pnpm-workspace.yaml* ./
|
||||||
COPY common ./common
|
COPY common ./common
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { Module } from "@nestjs/common";
|
import { Module } from "@nestjs/common";
|
||||||
import { AppController } from "./controller/app.controller";
|
import { AppController } from "./controller/app.controller";
|
||||||
|
import { PlayerService } from "./service/player.service";
|
||||||
|
import { PlayerController } from "./controller/player.controller";
|
||||||
import { AppService } from "./service/app.service";
|
import { AppService } from "./service/app.service";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [],
|
imports: [],
|
||||||
controllers: [AppController],
|
controllers: [AppController, PlayerController],
|
||||||
providers: [AppService],
|
providers: [AppService, PlayerService],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
@ -6,7 +6,10 @@ export class AppController {
|
|||||||
constructor(private readonly appService: AppService) {}
|
constructor(private readonly appService: AppService) {}
|
||||||
|
|
||||||
@Get("/")
|
@Get("/")
|
||||||
getHello(): string {
|
getHome() {
|
||||||
return this.appService.getHello();
|
return {
|
||||||
|
message: "ScoreSaber Reloaded API",
|
||||||
|
version: this.appService.getVersion(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
backend/src/controller/player.controller.ts
Normal file
12
backend/src/controller/player.controller.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,14 @@
|
|||||||
import { Injectable } from "@nestjs/common";
|
import { Injectable } from "@nestjs/common";
|
||||||
import { helloMeowMeow } from "@ssr/common/dist";
|
import { isProduction } from "@ssr/common/dist";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppService {
|
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"}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
backend/src/service/player.service.ts
Normal file
16
backend/src/service/player.service.ts
Normal 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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@
|
|||||||
"build": "tsup src/index.ts"
|
"build": "tsup src/index.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/node": "^22.7.4",
|
||||||
"tsup": "^6.5.0",
|
"tsup": "^6.5.0",
|
||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1 @@
|
|||||||
export function helloMeowMeow() {
|
export * from "src/utils";
|
||||||
return "hi";
|
|
||||||
}
|
|
||||||
|
6
common/src/utils.ts
Normal file
6
common/src/utils.ts
Normal 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
39
pnpm-lock.yaml
generated
@ -98,9 +98,12 @@ importers:
|
|||||||
|
|
||||||
common:
|
common:
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
'@types/node':
|
||||||
|
specifier: ^22.7.4
|
||||||
|
version: 22.7.4
|
||||||
tsup:
|
tsup:
|
||||||
specifier: ^6.5.0
|
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:
|
typescript:
|
||||||
specifier: ^5
|
specifier: ^5
|
||||||
version: 5.6.2
|
version: 5.6.2
|
||||||
@ -2017,6 +2020,9 @@ packages:
|
|||||||
'@types/node@20.16.10':
|
'@types/node@20.16.10':
|
||||||
resolution: {integrity: sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==}
|
resolution: {integrity: sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==}
|
||||||
|
|
||||||
|
'@types/node@22.7.4':
|
||||||
|
resolution: {integrity: sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==}
|
||||||
|
|
||||||
'@types/pg-pool@2.0.6':
|
'@types/pg-pool@2.0.6':
|
||||||
resolution: {integrity: sha512-TaAUE5rq2VQYxab5Ts7WZhKNmuN78Q6PiFonTDdpbx8a1H0M1vhy3rhiMjl+e2iHmogyMw7jZF4FrE6eJUy5HQ==}
|
resolution: {integrity: sha512-TaAUE5rq2VQYxab5Ts7WZhKNmuN78Q6PiFonTDdpbx8a1H0M1vhy3rhiMjl+e2iHmogyMw7jZF4FrE6eJUy5HQ==}
|
||||||
|
|
||||||
@ -7040,6 +7046,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 6.19.8
|
undici-types: 6.19.8
|
||||||
|
|
||||||
|
'@types/node@22.7.4':
|
||||||
|
dependencies:
|
||||||
|
undici-types: 6.19.8
|
||||||
|
|
||||||
'@types/pg-pool@2.0.6':
|
'@types/pg-pool@2.0.6':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/pg': 8.6.1
|
'@types/pg': 8.6.1
|
||||||
@ -9505,13 +9515,13 @@ snapshots:
|
|||||||
camelcase-css: 2.0.1
|
camelcase-css: 2.0.1
|
||||||
postcss: 8.4.47
|
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:
|
dependencies:
|
||||||
lilconfig: 2.1.0
|
lilconfig: 2.1.0
|
||||||
yaml: 1.10.2
|
yaml: 1.10.2
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
postcss: 8.4.47
|
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)):
|
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:
|
dependencies:
|
||||||
@ -10309,6 +10319,25 @@ snapshots:
|
|||||||
v8-compile-cache-lib: 3.0.1
|
v8-compile-cache-lib: 3.0.1
|
||||||
yn: 3.1.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: {}
|
tsafe@1.7.5: {}
|
||||||
|
|
||||||
tsconfig-paths-webpack-plugin@4.1.0:
|
tsconfig-paths-webpack-plugin@4.1.0:
|
||||||
@ -10332,7 +10361,7 @@ snapshots:
|
|||||||
|
|
||||||
tslib@2.7.0: {}
|
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:
|
dependencies:
|
||||||
bundle-require: 4.2.1(esbuild@0.17.19)
|
bundle-require: 4.2.1(esbuild@0.17.19)
|
||||||
cac: 6.7.14
|
cac: 6.7.14
|
||||||
@ -10342,7 +10371,7 @@ snapshots:
|
|||||||
execa: 5.1.1
|
execa: 5.1.1
|
||||||
globby: 11.1.0
|
globby: 11.1.0
|
||||||
joycon: 3.1.1
|
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
|
resolve-from: 5.0.0
|
||||||
rollup: 3.29.5
|
rollup: 3.29.5
|
||||||
source-map: 0.8.0-beta.0
|
source-map: 0.8.0-beta.0
|
||||||
|
Reference in New Issue
Block a user