Skip to content

Commit

Permalink
Bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
JensForstmann committed Apr 1, 2024
1 parent afb504b commit 750c69f
Show file tree
Hide file tree
Showing 12 changed files with 1,985 additions and 1,413 deletions.
1,331 changes: 1,024 additions & 307 deletions backend/package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
"start": "node ./dist/backend/src/index.js"
},
"dependencies": {
"@tsoa/runtime": "^6.0.0",
"express": "^4.18.2",
"@tsoa/runtime": "^6.2.0",
"express": "^4.19.2",
"short-uuid": "^4.2.2",
"steamid": "^2.0.0",
"typed-emitter": "^2.1.0",
"ws": "^8.16.0"
},
"devDependencies": {
"@tsoa/cli": "^6.0.1",
"@tsoa/cli": "^6.2.0",
"@types/debug": "^4.1.12",
"@types/express": "^4.17.21",
"@types/node": "^20.11.5",
"@types/node": "^20.12.2",
"@types/steamid": "^2.0.3",
"@types/ws": "^8.5.10",
"nodemon": "^3.0.3",
"nodemon": "^3.1.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
"typescript": "^5.4.3"
}
}
4 changes: 4 additions & 0 deletions backend/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export type IAuthResponseOptional =
type: 'UNAUTHORIZED';
};

export type ExpressRequest<T extends IAuthResponse | IAuthResponseOptional> = Request & {
user: T;
};

interface ITokenContent {
comment?: string;
}
Expand Down
30 changes: 15 additions & 15 deletions backend/src/matchesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
IMatchResponse,
IMatchUpdateDto,
} from '../../common';
import { IAuthResponse, IAuthResponseOptional } from './auth';
import { ExpressRequest, IAuthResponse, IAuthResponseOptional } from './auth';
import * as Events from './events';
import * as Match from './match';
import * as MatchMap from './matchMap';
Expand All @@ -37,9 +37,9 @@ export class MatchesController extends Controller {
@Security('bearer_token_optional')
async createMatch(
@Body() requestBody: IMatchCreateDto,
@Request() { user }: { user: IAuthResponseOptional }
@Request() req: ExpressRequest<IAuthResponseOptional>
): Promise<IMatch> {
const match = await MatchService.create(requestBody, user.type === 'GLOBAL');
const match = await MatchService.create(requestBody, req.user.type === 'GLOBAL');
this.setHeader('Location', `/api/matches/${match.data.id}`);
this.setStatus(201);
return match.data;
Expand All @@ -54,7 +54,7 @@ export class MatchesController extends Controller {
*/
@Get()
async getAllMatches(
@Request() { user }: { user: IAuthResponse },
@Request() req: ExpressRequest<IAuthResponse>,
@Query('state') state?: string[],
@Query('passthrough') passthrough?: string[],
@Query('isStopped') isStopped?: boolean,
Expand Down Expand Up @@ -82,7 +82,7 @@ export class MatchesController extends Controller {
@Get('{id}')
async getMatch(
id: string,
@Request() { user }: { user: IAuthResponse }
@Request() req: ExpressRequest<IAuthResponse>
): Promise<IMatchResponse | void> {
const match = MatchService.get(id);
if (match) {
Expand All @@ -108,15 +108,15 @@ export class MatchesController extends Controller {
* Get the last 1000 log lines from a specific match.
*/
@Get('{id}/logs')
async getLogs(id: string, @Request() { user }: { user: IAuthResponse }): Promise<string[]> {
async getLogs(id: string, @Request() req: ExpressRequest<IAuthResponse>): Promise<string[]> {
return await Match.getLogsTail(id);
}

/**
* Get the last 1000 events from a specific match.
*/
@Get('{id}/events')
async getEvents(id: string, @Request() { user }: { user: IAuthResponse }): Promise<Event[]> {
async getEvents(id: string, @Request() req: ExpressRequest<IAuthResponse>): Promise<Event[]> {
return await Events.getEventsTail(id);
}

Expand All @@ -127,7 +127,7 @@ export class MatchesController extends Controller {
@Get('{id}/server/round_backups')
async getRoundBackups(
id: string,
@Request() { user }: { user: IAuthResponse },
@Request() req: ExpressRequest<IAuthResponse>,
@Query('count') count?: number
): Promise<{ latestFiles: string[]; total: number } | void> {
const match = MatchService.get(id);
Expand All @@ -147,7 +147,7 @@ export class MatchesController extends Controller {
async loadRoundBackup(
id: string,
file: string,
@Request() { user }: { user: IAuthResponse }
@Request() req: ExpressRequest<IAuthResponse>
): Promise<boolean | void> {
const match = MatchService.get(id);
if (match) {
Expand All @@ -170,7 +170,7 @@ export class MatchesController extends Controller {
async updateMatch(
id: string,
@Body() requestBody: IMatchUpdateDto,
@Request() { user }: { user: IAuthResponse }
@Request() req: ExpressRequest<IAuthResponse>
): Promise<void> {
const match = MatchService.get(id);
if (match) {
Expand All @@ -188,7 +188,7 @@ export class MatchesController extends Controller {
id: string,
mapNumber: number,
@Body() requestBody: IMatchMapUpdateDto,
@Request() { user }: { user: IAuthResponse }
@Request() req: ExpressRequest<IAuthResponse>
): Promise<void> {
const match = MatchService.get(id);
if (!match) {
Expand All @@ -207,7 +207,7 @@ export class MatchesController extends Controller {
* Stop supervising a specific match. TMT will no longer listen to the game server and will not execute any rcon commands.
*/
@Delete('{id}')
async deleteMatch(id: string, @Request() { user }: { user: IAuthResponse }): Promise<void> {
async deleteMatch(id: string, @Request() req: ExpressRequest<IAuthResponse>): Promise<void> {
if (!(await MatchService.remove(id))) {
this.setStatus(404);
}
Expand All @@ -217,7 +217,7 @@ export class MatchesController extends Controller {
* Revive a specific match. TMT will start supervising a (stopped) match again (listen to the game sever and execute rcon commands).
*/
@Patch('{id}/revive')
async reviveMatch(id: string, @Request() { user }: { user: IAuthResponse }): Promise<void> {
async reviveMatch(id: string, @Request() req: ExpressRequest<IAuthResponse>): Promise<void> {
if (!(await MatchService.revive(id))) {
this.setStatus(404);
}
Expand All @@ -230,14 +230,14 @@ export class MatchesController extends Controller {
async rcon(
id: string,
@Body() requestBody: string[],
@Request() { user }: { user: IAuthResponse }
@Request() req: ExpressRequest<IAuthResponse>
): Promise<string[] | void> {
const match = MatchService.get(id);
if (!match) {
this.setStatus(404);
return;
}
if (match.data.gameServer.hideRconPassword && user.type === 'MATCH') {
if (match.data.gameServer.hideRconPassword && req.user.type === 'MATCH') {
this.setStatus(400);
throw 'cannot execute rcon commands on this server';
}
Expand Down
13 changes: 8 additions & 5 deletions backend/src/presetsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SuccessResponse,
} from '@tsoa/runtime';
import { IPreset, IPresetCreateDto } from '../../common/types/preset';
import { IAuthResponse } from './auth';
import { ExpressRequest, IAuthResponse } from './auth';
import * as Presets from './presets';

@Route('/api/presets')
Expand All @@ -21,7 +21,7 @@ export class PresetsController extends Controller {
* Get all configured presets.
*/
@Get()
async getPresets(@Request() { user }: { user: IAuthResponse }): Promise<IPreset[]> {
async getPresets(@Request() req: ExpressRequest<IAuthResponse>): Promise<IPreset[]> {
return Presets.getAll();
}

Expand All @@ -32,7 +32,7 @@ export class PresetsController extends Controller {
@SuccessResponse(201)
async createPreset(
@Body() requestBody: IPresetCreateDto,
@Request() { user }: { user: IAuthResponse }
@Request() req: ExpressRequest<IAuthResponse>
): Promise<IPreset> {
const preset = Presets.add(requestBody);
this.setStatus(201);
Expand All @@ -43,7 +43,10 @@ export class PresetsController extends Controller {
* Update an existing preset.
*/
@Put()
async updatePreset(@Body() requestBody: IPreset, @Request() { user }: { user: IAuthResponse }) {
async updatePreset(
@Body() requestBody: IPreset,
@Request() req: ExpressRequest<IAuthResponse>
) {
if (!(await Presets.update(requestBody))) {
this.setStatus(404);
}
Expand All @@ -53,7 +56,7 @@ export class PresetsController extends Controller {
* Delete an existing preset.
*/
@Delete('{id}')
async deletePreset(id: string, @Request() { user }: { user: IAuthResponse }): Promise<void> {
async deletePreset(id: string, @Request() req: ExpressRequest<IAuthResponse>): Promise<void> {
if (!(await Presets.remove(id))) {
this.setStatus(404);
}
Expand Down
Loading

0 comments on commit 750c69f

Please sign in to comment.