finished client endpoints

This commit is contained in:
faris Aljohari
2025-03-27 01:28:40 +03:00
parent c5dac6c564
commit cbd3f5028b
10 changed files with 169 additions and 21 deletions
+14 -7
View File
@@ -77,21 +77,28 @@ export class AuthService {
return await this.sessionRepository.save(data);
}
async getTokens(payload) {
async getTokens(
payload,
isRefreshToken = true,
accessTokenExpiry = '24h',
refreshTokenExpiry = '30d',
) {
const [accessToken, refreshToken] = await Promise.all([
this.jwtService.signAsync(payload, {
secret: this.configService.get<string>('JWT_SECRET'),
expiresIn: '24h',
}),
this.jwtService.signAsync(payload, {
secret: this.configService.get<string>('JWT_SECRET'),
expiresIn: '7d',
expiresIn: accessTokenExpiry,
}),
isRefreshToken
? this.jwtService.signAsync(payload, {
secret: this.configService.get<string>('JWT_SECRET'),
expiresIn: refreshTokenExpiry,
})
: null,
]);
return {
accessToken,
refreshToken,
...(isRefreshToken ? { refreshToken } : {}),
};
}
@@ -1,4 +1,17 @@
export class ControllerRoute {
static CLIENT = class {
public static readonly ROUTE = 'client';
static ACTIONS = class {
public static readonly REGISTER_NEW_CLIENT_SUMMARY =
'Register a new client';
public static readonly REGISTER_NEW_CLIENT_DESCRIPTION =
'This endpoint registers a new client in the system.';
public static readonly LOGIN_CLIENT_SUMMARY = 'Login a client';
public static readonly LOGIN_CLIENT_DESCRIPTION =
'This endpoint allows a client to log in to the system.';
};
};
static PROJECT = class {
public static readonly ROUTE = 'projects';
static ACTIONS = class {