From 19d6ac6f0c3f5ae55e45f2b2168a13fb4c0ff325 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Tue, 17 Jan 2023 18:36:10 +0530 Subject: [PATCH] refactor: types and add drivers to hash drivers collection --- modules/hash/drivers_collection.ts | 7 ++++++- providers/app_provider.ts | 2 +- src/types.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/hash/drivers_collection.ts b/modules/hash/drivers_collection.ts index 86463e7e..2f3e8985 100644 --- a/modules/hash/drivers_collection.ts +++ b/modules/hash/drivers_collection.ts @@ -16,6 +16,7 @@ * regular usage and specific to AdonisJS container flow. */ +import { Argon, Bcrypt, Scrypt } from './main.js' import { RuntimeException } from '@poppinss/utils' import type { HashDriversList } from '../../src/types.js' @@ -26,7 +27,11 @@ class HashDriversCollection { /** * List of registered drivers */ - list: Partial = {} + list: Partial = { + bcrypt: (config) => new Bcrypt(config), + argon2: (config) => new Argon(config), + scrypt: (config) => new Scrypt(config), + } /** * Extend drivers collection and add a custom diff --git a/providers/app_provider.ts b/providers/app_provider.ts index 0a05436b..d46aa79f 100644 --- a/providers/app_provider.ts +++ b/providers/app_provider.ts @@ -44,7 +44,7 @@ export default class AppServiceProvider { protected registerLoggerManager() { const LoggerServiceManager = LoggerManager as unknown as AbstractConstructor this.app.container.singleton(LoggerServiceManager, () => { - const config = this.app.config.get('app.logger') + const config = this.app.config.get('logger') return new LoggerManager(config) as LoggerService }) this.app.container.alias('logger', LoggerServiceManager) diff --git a/src/types.ts b/src/types.ts index dad42dc4..dd159627 100644 --- a/src/types.ts +++ b/src/types.ts @@ -45,7 +45,7 @@ export type InferLoggers> = T['loggers'] */ export interface HashDriversList { bcrypt: (config: BcryptConfig) => Bcrypt - argon: (config: ArgonConfig) => Argon + argon2: (config: ArgonConfig) => Argon scrypt: (config: ScryptConfig) => Scrypt }