move score page fetching to the backend
This commit is contained in:
bun.lockb
projects
backend
common
package.json
src
leaderboard.ts
tsconfig.jsonleaderboard
model
player
response
score
service
types
utils
website/src
app/(pages)
common/database
components
api
friend
leaderboard
leaderboard-data.tsxleaderboard-info.tsxleaderboard-player.tsxleaderboard-score-stats.tsxleaderboard-score.tsxleaderboard-scores.tsxleaderboard-song-star-count.tsx
player
chart
player-badges.tsxplayer-data.tsxplayer-header.tsxplayer-scores.tsxplayer-stats.tsxplayer-tracked-status.tsxranking
score
55
projects/backend/src/controller/scores.controller.ts
Normal file
55
projects/backend/src/controller/scores.controller.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import { Controller, Get } from "elysia-decorators";
|
||||
import { t } from "elysia";
|
||||
import { Leaderboards } from "@ssr/common/leaderboard";
|
||||
import { ScoreService } from "../service/score.service";
|
||||
|
||||
@Controller("/scores")
|
||||
export default class ScoresController {
|
||||
@Get("/player/:leaderboard/:id/:page/:sort", {
|
||||
config: {},
|
||||
params: t.Object({
|
||||
leaderboard: t.String({ required: true }),
|
||||
id: t.String({ required: true }),
|
||||
page: t.Number({ required: true }),
|
||||
sort: t.String({ required: true }),
|
||||
}),
|
||||
query: t.Object({
|
||||
search: t.Optional(t.String()),
|
||||
}),
|
||||
})
|
||||
public async getScores({
|
||||
params: { leaderboard, id, page, sort },
|
||||
query: { search },
|
||||
}: {
|
||||
params: {
|
||||
leaderboard: Leaderboards;
|
||||
id: string;
|
||||
page: number;
|
||||
sort: string;
|
||||
};
|
||||
query: { search?: string };
|
||||
}): Promise<unknown> {
|
||||
return await ScoreService.getPlayerScores(leaderboard, id, page, sort, search);
|
||||
}
|
||||
|
||||
@Get("/leaderboard/:leaderboard/:id/:page", {
|
||||
config: {},
|
||||
params: t.Object({
|
||||
leaderboard: t.String({ required: true }),
|
||||
id: t.String({ required: true }),
|
||||
page: t.Number({ required: true }),
|
||||
}),
|
||||
})
|
||||
public async getLeaderboardScores({
|
||||
params: { leaderboard, id, page },
|
||||
}: {
|
||||
params: {
|
||||
leaderboard: Leaderboards;
|
||||
id: string;
|
||||
page: number;
|
||||
};
|
||||
query: { search?: string };
|
||||
}): Promise<unknown> {
|
||||
return await ScoreService.getLeaderboardScores(leaderboard, id, page);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user