mirror of
https://gitlab.com/mobicoop/v3/service/configuration.git
synced 2026-01-09 16:32:40 +00:00
add auth default configuration
This commit is contained in:
@@ -19,12 +19,14 @@ import redisConfig from './config/redis.config';
|
||||
import { Transport } from '@nestjs/microservices';
|
||||
import matchConfig from './config/match.config';
|
||||
import geographyConfig from './config/geography.config';
|
||||
import authConfig from './config/auth.config';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
load: [
|
||||
authConfig,
|
||||
brokerConfig,
|
||||
carpoolConfig,
|
||||
geographyConfig,
|
||||
|
||||
10
src/config/auth.config.ts
Normal file
10
src/config/auth.config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { registerAs } from '@nestjs/config';
|
||||
import { Config } from './config';
|
||||
|
||||
export interface AuthConfig extends Config {
|
||||
encryptionAlgorithm: string;
|
||||
}
|
||||
|
||||
export default registerAs('match', () => ({
|
||||
encryptionAlgorithm: process.env.ENCRYPTION_ALGORITHM ?? 'BCRYPT',
|
||||
}));
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
import { NotFoundException } from '@mobicoop/ddd-library';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { AuthConfig } from '@src/config/auth.config';
|
||||
import { CarpoolConfig } from '@src/config/carpool.config';
|
||||
import { Config } from '@src/config/config';
|
||||
import { GeographyConfig } from '@src/config/geography.config';
|
||||
@@ -19,6 +20,10 @@ export class ConfigurationsManagerService {
|
||||
|
||||
list = (): Config[] => {
|
||||
return [
|
||||
{
|
||||
...(this.configService.get<AuthConfig>('auth') as AuthConfig),
|
||||
domain: ConfigurationDomain.AUTH,
|
||||
},
|
||||
{
|
||||
...(this.configService.get<CarpoolConfig>('carpool') as CarpoolConfig),
|
||||
domain: ConfigurationDomain.CARPOOL,
|
||||
|
||||
@@ -12,6 +12,10 @@ import { Config } from '@src/config/config';
|
||||
const mockConfigService = {
|
||||
get: jest.fn().mockImplementation((domain: string) => {
|
||||
switch (domain) {
|
||||
case 'auth':
|
||||
return {
|
||||
encryptionAlgorithm: 'BCRYPT',
|
||||
};
|
||||
case 'carpool':
|
||||
return {
|
||||
departureTimeMargin: 900,
|
||||
@@ -69,7 +73,7 @@ describe('Configurations Manager Service', () => {
|
||||
|
||||
it('should return the list of configuration elements', () => {
|
||||
const list: Config[] = configurationsManagerService.list();
|
||||
expect(list).toHaveLength(4);
|
||||
expect(list).toHaveLength(5);
|
||||
});
|
||||
|
||||
describe('identifierType', () => {
|
||||
|
||||
Reference in New Issue
Block a user