Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ac22f52
[New][#142]
May 7, 2026
4b02caf
- added new interfaces for admin request and responses in auth.types.ts
May 11, 2026
93135bb
- some imports where is missing that's why we got ECONNREFUSED bug du…
May 11, 2026
234c7e1
- working on action modal for admin
May 11, 2026
7b76f53
- added loading state to admin usermanagement site
CodeLittleToImprove May 12, 2026
9764f7d
- changed look of adminactionmodal and message
CodeLittleToImprove May 12, 2026
37cc7d8
- added function to change a role of a user and modify the AdminActio…
CodeLittleToImprove May 12, 2026
775828b
small refactoring
May 13, 2026
1d39661
- changed UpdatePlayerStatsDto from type to class because nest.js met…
May 13, 2026
ba2d1b4
Merge remote-tracking branch 'origin/143_javadjan' into 142_codelittl…
CodeLittleToImprove May 26, 2026
d1bc8dc
- missing dependencies for auth user for some reason
CodeLittleToImprove May 26, 2026
414c160
- added ProtectedRoute for admin panel and check for the role admin
CodeLittleToImprove May 26, 2026
f88a589
Provider, AuthModal, ProtectedRoute now know the last page you were o…
CodeLittleToImprove May 27, 2026
4ee15bf
added account suspendend message when a banned is logged in
CodeLittleToImprove May 27, 2026
0c2fd6f
removed reason because we never show it away from AdminActionModal.tsx
CodeLittleToImprove May 27, 2026
c2740b3
added option for AdminActionModal.tsx to have free input for stats
CodeLittleToImprove May 27, 2026
6dce345
added live stats to edit player stats
CodeLittleToImprove May 27, 2026
e675bf8
fix bug where protected route redirects but user could not leave the …
May 28, 2026
82e3bc7
changed user profile stats display behavior for kda and winrate to on…
May 28, 2026
bfa947b
made sure edit stats window is hard limit to a min and max constant
May 28, 2026
db69c86
using zod to display specific error message when a admin changing sta…
May 28, 2026
da2b26b
added toast notification to all admin actions
May 28, 2026
7bf7e47
added kick button with reason textfield , revert disable user also ha…
CodeLittleToImprove May 31, 2026
1788bfd
added zod to kick and ban reason message
CodeLittleToImprove May 31, 2026
c657d90
needed to wrap provider into AuthProviderContent with a React Suspenc…
CodeLittleToImprove May 31, 2026
b6c588a
added error boundary for admin dashboard
CodeLittleToImprove May 31, 2026
bb8bcc6
added a option to display more user entries results by going to to ne…
CodeLittleToImprove May 31, 2026
7c8f865
[END][#142]
Jun 5, 2026
add3971
Merge branch 'development' into 142_codelittletoimprove
Jun 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/BFF/src/modules/auth/contracts/dto/auth-contracts.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export type AuditListResponseDto = {
pageInfo: PageInfoDto;
};

export type UpdatePlayerStatsDto = {
export class UpdatePlayerStatsDto {
matchesWon?: string[];
matchesLost?: string[];
achievements?: string[];
Expand All @@ -241,6 +241,6 @@ export type UpdatePlayerStatsDto = {
damageTaken?: number;
createdAt?: string;
updatedAt?: string;
};
}

export type PlayerStatsDto = Record<string, unknown>;
2 changes: 1 addition & 1 deletion apps/BFF/src/modules/config/env.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const baseSchema = z.object({
.default('development'),
PORT: z.coerce.number().int().min(1).max(65535).default(3000),

AUTH_SERVICE_URL: z.string().url(),
AUTH_SERVICE_URL: z.string().url().default('http://auth_service:3000'),
SOCIAL_SERVICE_URL: z.string().url().default('http://social_service:3000'),
STATS_SERVICE_URL: z.string().url().default('http://stats_service:3000'),

Expand Down
15 changes: 13 additions & 2 deletions apps/BFF/src/modules/stats/stats.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Controller, Get, Headers, Param, Query, Req, Post, Body, Put } from '@nestjs/common';
import { Controller, Get, Headers, Param, Patch, Query, Req, Post, Body, Put } from '@nestjs/common';
import type { Request } from 'express';
import { StatsService } from './stats.service';
import { PlayerStatsSchema, type PlayerStats } from './contracts/player-stats.schema';
import { UpdatePlayerStatsDto } from '../auth/contracts/dto/auth-contracts.dto';

function computeDerived(stats: Record<string, unknown>) {
const kills = Number((stats as any).kills ?? 0);
Expand All @@ -18,7 +19,6 @@ function computeDerived(stats: Record<string, unknown>) {
export class StatsController {
constructor(private readonly service: StatsService) {}


@Get('users')
async getUsers(
@Headers() headers: Record<string, string>,
Expand Down Expand Up @@ -97,4 +97,15 @@ export class StatsController {
return this.service.UpsertAcheivement(body, { authorization });
}


@Patch('user/:userId')
async updateStats(
@Param('userId') userId: string,
@Body() updateDto: UpdatePlayerStatsDto,
@Headers('authorization') auth: string,
) {
return this.service.update(userId, updateDto, {
authorization: auth,
});
}
}
52 changes: 39 additions & 13 deletions apps/BFF/src/modules/stats/stats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import axios, { AxiosError } from 'axios';
import { BffConfigService } from '../config/bff-config.service';
import { PlayerStatsDto } from '../auth/contracts/dto/auth-contracts.dto';

type RequestContext = { authorization?: string; params?: Record<string, unknown> };
type RequestContext = {
authorization?: string;
params?: Record<string, unknown>;
};

@Injectable()
export class StatsService {
Expand All @@ -18,30 +21,33 @@ export class StatsService {
});
}

async fetchUserById(userId: string, context: RequestContext): Promise<PlayerStatsDto> {
async fetchUserById(
userId: string,
context: RequestContext,
): Promise<PlayerStatsDto> {
return this.callStatsService<PlayerStatsDto>({
method: 'GET',
path: `/internal/stats/user/${encodeURIComponent(userId)}`,
context
});
method: 'GET',
path: `/internal/stats/user/${encodeURIComponent(userId)}`,
context,
});
}

private async callStatsService<T = PlayerStatsDto>(
input: { method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
path: string;
context: RequestContext;
data?: unknown;
params?: Record<string, unknown>;
params?: Record<string, unknown>;
}): Promise<T> {
const headers: Record<string, string> = { 'x-service-name': 'bff' };
if (input.context.authorization) headers.authorization = input.context.authorization;
if (input.context.authorization)
headers.authorization = input.context.authorization;

try {
const url = `${this.config.stats.serviceUrl}${input.path}`;
const response = await axios.request<T>({
method: input.method as any,
//url: `${this.config.stats.serviceUrl}${input.path}`,
url,
url,
headers,
data: input.data,
params: input.context.params ?? input.params,
Expand All @@ -59,11 +65,31 @@ export class StatsService {
} catch (error) {
if (error instanceof AxiosError) {
const status = error.response?.status ?? 502;
throw new BadGatewayException({ code: `stats_service_${status}`, message: error.message, details: error.response?.data });
throw new BadGatewayException({
code: `stats_service_${status}`,
message: error.message,
details: error.response?.data,
});
}
throw new BadGatewayException({ code: 'stats_service_unreachable', message: 'Unable to reach stats service', details: error });
throw new BadGatewayException({
code: 'stats_service_unreachable',
message: 'Unable to reach stats service',
details: error,
});
}
}
async update(
userId: string,
data: any,
context: RequestContext,
): Promise<PlayerStatsDto> {
return this.callStatsService<PlayerStatsDto>({
method: 'PATCH',
path: `/internal/stats/user/${encodeURIComponent(userId)}`,
context,
data,
});
}

// fetch member of match:
async fetchMatchMembers(matchId: string, context: { authorization?: string }) {
Expand All @@ -89,7 +115,7 @@ export class StatsService {
return this.callStatsService({
method : 'PUT',
path: `/internal/stats/user/${id}`,
data: body,
data: body,
context
})
}
Expand Down
34 changes: 30 additions & 4 deletions apps/auth-user/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions apps/auth-user/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"axios": "^1.4.0",
"@nestjs/common": "^11.0.1",
"@nestjs/config": "^4.0.3",
"@nestjs/core": "^11.0.1",
Expand All @@ -29,6 +28,7 @@
"@prisma/adapter-pg": "^7.5.0",
"@prisma/client": "^7.5.0",
"argon2": "^0.44.0",
"axios": "^1.16.1",
"bcrypt": "^6.0.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.15.1",
Expand Down Expand Up @@ -85,4 +85,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class AuthLoginService {

if (user.status !== 'ACTIVE' || user.disabledAt) {
await this.auditLoginFailed(user.id, input.email, context, 'DISABLED');
throw new UnauthorizedException('Invalid email or password');
throw new UnauthorizedException('Your account has been suspended.');
}

const loggedIn = await this.prisma.$transaction(
Expand Down
Loading
Loading