Skip to content

Commit

Permalink
refactor: types and add drivers to hash drivers collection
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jan 17, 2023
1 parent f6a612b commit 19d6ac6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion modules/hash/drivers_collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -26,7 +27,11 @@ class HashDriversCollection {
/**
* List of registered drivers
*/
list: Partial<HashDriversList> = {}
list: Partial<HashDriversList> = {
bcrypt: (config) => new Bcrypt(config),
argon2: (config) => new Argon(config),
scrypt: (config) => new Scrypt(config),
}

/**
* Extend drivers collection and add a custom
Expand Down
2 changes: 1 addition & 1 deletion providers/app_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class AppServiceProvider {
protected registerLoggerManager() {
const LoggerServiceManager = LoggerManager as unknown as AbstractConstructor<LoggerService>
this.app.container.singleton(LoggerServiceManager, () => {
const config = this.app.config.get<any>('app.logger')
const config = this.app.config.get<any>('logger')
return new LoggerManager(config) as LoggerService
})
this.app.container.alias('logger', LoggerServiceManager)
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type InferLoggers<T extends LoggerManagerConfig<any>> = T['loggers']
*/
export interface HashDriversList {
bcrypt: (config: BcryptConfig) => Bcrypt
argon: (config: ArgonConfig) => Argon
argon2: (config: ArgonConfig) => Argon
scrypt: (config: ScryptConfig) => Scrypt
}

Expand Down

0 comments on commit 19d6ac6

Please sign in to comment.