This repository has been archived by the owner on Feb 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement configuration via forRoot (#21)
Adds the ability to provide configuration to the InMemoryDBModule via `forRoot` static method. Implements #18
- Loading branch information
1 parent
95cdfac
commit 8904c00
Showing
6 changed files
with
175 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { DynamicModule, Module } from '@nestjs/common'; | ||
|
||
import { InMemoryDBConfig } from './interfaces'; | ||
import { InMemoryDBService } from './services'; | ||
|
||
@Module({ | ||
providers: [InMemoryDBService], | ||
exports: [InMemoryDBService], | ||
}) | ||
export class InMemoryDBModule {} | ||
export class InMemoryDBModule { | ||
static forRoot(config: Partial<InMemoryDBConfig> = {}): DynamicModule { | ||
return { | ||
module: InMemoryDBModule, | ||
providers: [ | ||
{ | ||
provide: InMemoryDBService, | ||
useValue: new InMemoryDBService(config), | ||
}, | ||
], | ||
exports: [InMemoryDBService], | ||
}; | ||
} | ||
} |
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 @@ | ||
export interface InMemoryDBConfig {} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './in-memory-db-config'; | ||
export * from './in-memory-db-entity'; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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