upgrade packages; handle throttle failure with message broker handler

This commit is contained in:
Sylvain Briat 2024-01-16 17:30:51 +01:00
parent 1026ca7eb9
commit 3f0bef812e
7 changed files with 947 additions and 988 deletions

1813
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -30,58 +30,57 @@
"migrate:deploy": "npx prisma migrate deploy"
},
"dependencies": {
"@golevelup/nestjs-rabbitmq": "^4.0.0",
"@grpc/grpc-js": "^1.9.9",
"@golevelup/nestjs-rabbitmq": "^4.1.0",
"@grpc/grpc-js": "^1.9.13",
"@grpc/proto-loader": "^0.7.10",
"@mobicoop/configuration-module": "^7.2.1",
"@mobicoop/ddd-library": "^2.1.1",
"@mobicoop/health-module": "^2.3.1",
"@mobicoop/message-broker-module": "^2.1.1",
"@mobicoop/configuration-module": "^8.0.0",
"@mobicoop/ddd-library": "^2.4.3",
"@mobicoop/health-module": "^2.3.2",
"@mobicoop/message-broker-module": "^2.1.2",
"@nestjs/axios": "^3.0.1",
"@nestjs/common": "^10.2.8",
"@nestjs/common": "^10.3.0",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.2.8",
"@nestjs/core": "^10.3.0",
"@nestjs/cqrs": "^10.2.6",
"@nestjs/event-emitter": "^2.0.2",
"@nestjs/microservices": "^10.2.8",
"@nestjs/platform-express": "^10.2.8",
"@nestjs/terminus": "^10.1.1",
"@prisma/client": "^5.5.2",
"@nestjs/event-emitter": "^2.0.3",
"@nestjs/microservices": "^10.3.0",
"@nestjs/platform-express": "^10.3.0",
"@nestjs/terminus": "^10.2.0",
"@prisma/client": "^5.8.1",
"argon2": "^0.31.2",
"axios": "^1.6.0",
"axios": "^1.6.5",
"bcrypt": "5.1.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"reflect-metadata": "^0.1.13",
"class-validator": "^0.14.1",
"rimraf": "^5.0.5",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@nestjs/cli": "^10.2.1",
"@nestjs/schematics": "^10.0.3",
"@nestjs/testing": "^10.2.8",
"@types/bcrypt": "^5.0.1",
"@types/express": "^4.17.20",
"@types/jest": "29.5.7",
"@types/node": "^20.8.10",
"@types/supertest": "^2.0.15",
"@types/uuid": "^9.0.6",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@nestjs/cli": "^10.3.0",
"@nestjs/schematics": "^10.1.0",
"@nestjs/testing": "^10.3.0",
"@types/bcrypt": "^5.0.2",
"@types/express": "^4.17.21",
"@types/jest": "29.5.11",
"@types/node": "^20.11.4",
"@types/supertest": "^6.0.2",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"dotenv-cli": "^7.3.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "29.7.0",
"prettier": "^3.0.3",
"prisma": "^5.5.2",
"prettier": "^3.2.2",
"prisma": "^5.8.1",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"supertest": "^6.3.4",
"ts-jest": "29.1.1",
"ts-loader": "^9.5.0",
"ts-node": "^10.9.1",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "4.2.0",
"typescript": "^5.2.2",
"typescript": "^5.3.3",
"uuid": "^9.0.1"
},
"jest": {

View File

@ -1,7 +1,4 @@
import {
ConfigurationDomainGet,
ConfigurationType,
} from '@mobicoop/configuration-module';
import { KeyType, Type } from '@mobicoop/configuration-module';
import { IsStrongPasswordOptions } from 'class-validator';
export const STRONG_PASSWORD_OPTIONS: IsStrongPasswordOptions = {
@ -13,9 +10,9 @@ export const STRONG_PASSWORD_OPTIONS: IsStrongPasswordOptions = {
};
export const AUTH_CONFIG_ENCRYPTION_ALGORITHM = 'encryptionAlgorithm';
export const AuthConfig: ConfigurationDomainGet[] = [
export const AuthKeyTypes: KeyType[] = [
{
key: AUTH_CONFIG_ENCRYPTION_ALGORITHM,
type: ConfigurationType.STRING,
type: Type.STRING,
},
];

View File

@ -17,13 +17,13 @@ import {
UsernameAlreadyExistsException,
} from '@modules/authentication/core/domain/authentication.errors';
import {
ConfigurationDomain,
Configurator,
Domain,
GetConfigurationRepositoryPort,
} from '@mobicoop/configuration-module';
import {
AUTH_CONFIG_ENCRYPTION_ALGORITHM,
AuthConfig,
AuthKeyTypes,
} from '@modules/authentication/authentication.constants';
import { EncryptionAlgorithm } from '@modules/authentication/core/domain/username.types';
import { PasswordEncrypter } from '@modules/authentication/infrastructure/password-encrypter';
@ -40,10 +40,7 @@ export class CreateAuthenticationService implements ICommandHandler {
async execute(command: CreateAuthenticationCommand): Promise<AggregateID> {
const authConfigurator: Configurator =
await this.configurationRepository.mget(
ConfigurationDomain.AUTH,
AuthConfig,
);
await this.configurationRepository.mget(Domain.AUTH, AuthKeyTypes);
const passwordEncrypter: PasswordEncrypterPort = new PasswordEncrypter(
authConfigurator.get<EncryptionAlgorithm>(
AUTH_CONFIG_ENCRYPTION_ALGORITHM,

View File

@ -9,13 +9,13 @@ import { UpdatePasswordCommand } from './update-password.command';
import { AuthenticationRepositoryPort } from '../../ports/authentication.repository.port';
import { AuthenticationEntity } from '@modules/authentication/core/domain/authentication.entity';
import {
ConfigurationDomain,
Domain,
Configurator,
GetConfigurationRepositoryPort,
} from '@mobicoop/configuration-module';
import {
AUTH_CONFIG_ENCRYPTION_ALGORITHM,
AuthConfig,
AuthKeyTypes,
} from '@modules/authentication/authentication.constants';
import { EncryptionAlgorithm } from '@modules/authentication/core/domain/username.types';
import { PasswordEncrypterPort } from '../../ports/password-encrypter.port';
@ -32,10 +32,7 @@ export class UpdatePasswordService implements ICommandHandler {
async execute(command: UpdatePasswordCommand): Promise<AggregateID> {
const authConfigurator: Configurator =
await this.configurationRepository.mget(
ConfigurationDomain.AUTH,
AuthConfig,
);
await this.configurationRepository.mget(Domain.AUTH, AuthKeyTypes);
const encryptionAlgorithm: EncryptionAlgorithm =
authConfigurator.get<EncryptionAlgorithm>(
AUTH_CONFIG_ENCRYPTION_ALGORITHM,

View File

@ -1,8 +1,8 @@
import {
ConfigurationDomain,
ConfigurationDomainGet,
Domain,
Configurator,
GetConfigurationRepositoryPort,
KeyType,
} from '@mobicoop/configuration-module';
import {
AggregateID,
@ -58,12 +58,12 @@ const mockConfigurationRepository: GetConfigurationRepositoryPort = {
get: jest.fn(),
mget: jest.fn().mockImplementation(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(domain: ConfigurationDomain, configs: ConfigurationDomainGet[]) => {
(domain: Domain, keyTypes: KeyType[]) => {
switch (domain) {
case ConfigurationDomain.AUTH:
return new Configurator(ConfigurationDomain.AUTH, [
case Domain.AUTH:
return new Configurator(Domain.AUTH, [
{
domain: ConfigurationDomain.AUTH,
domain: Domain.AUTH,
key: AUTH_CONFIG_ENCRYPTION_ALGORITHM,
value: 'BCRYPT',
},

View File

@ -9,10 +9,10 @@ import { UpdatePasswordRequestDto } from '@modules/authentication/interface/grpc
import { Test, TestingModule } from '@nestjs/testing';
import { UpdatePasswordCommand } from '@modules/authentication/core/application/commands/update-password/update-password.command';
import {
ConfigurationDomain,
ConfigurationDomainGet,
Domain,
Configurator,
GetConfigurationRepositoryPort,
KeyType,
} from '@mobicoop/configuration-module';
import { AUTH_CONFIG_ENCRYPTION_ALGORITHM } from '@modules/authentication/authentication.constants';
@ -38,12 +38,12 @@ const mockConfigurationRepository: GetConfigurationRepositoryPort = {
get: jest.fn(),
mget: jest.fn().mockImplementation(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(domain: ConfigurationDomain, configs: ConfigurationDomainGet[]) => {
(domain: Domain, keyTypes: KeyType[]) => {
switch (domain) {
case ConfigurationDomain.AUTH:
return new Configurator(ConfigurationDomain.AUTH, [
case Domain.AUTH:
return new Configurator(Domain.AUTH, [
{
domain: ConfigurationDomain.AUTH,
domain: Domain.AUTH,
key: AUTH_CONFIG_ENCRYPTION_ALGORITHM,
value: 'BCRYPT',
},