-
-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: get rid of drivers collection and use config providers
Config providers simplifies the way we register and lazy load drivers A detailed post will be shared on the same soon
- Loading branch information
1 parent
cb9b434
commit 819b5bf
Showing
10 changed files
with
200 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* @adonisjs/core | ||
* | ||
* (c) AdonisJS | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { ApplicationService, ConfigProvider } from './types.js' | ||
|
||
/** | ||
* Helper to create config provider and resolve config from | ||
* them | ||
*/ | ||
export const configProvider = { | ||
create<T>(resolver: ConfigProvider<T>['resolver']): ConfigProvider<T> { | ||
return { | ||
type: 'provider', | ||
resolver, | ||
} | ||
}, | ||
|
||
async resolve<T>(app: ApplicationService, provider: unknown): Promise<T | null> { | ||
if (provider && typeof provider === 'object' && 'type' in provider) { | ||
return (provider as ConfigProvider<T>).resolver(app) | ||
} | ||
|
||
return null | ||
}, | ||
} |
Oops, something went wrong.