-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9588 from nestjs/9.0.0
chore(): v9.0.0 release (wip)
- Loading branch information
Showing
171 changed files
with
5,168 additions
and
2,959 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 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
17 changes: 17 additions & 0 deletions
17
integration/module-utils/src/integration.module-definition.ts
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,17 @@ | ||
import { ConfigurableModuleBuilder } from '@nestjs/common'; | ||
import { IntegrationModuleOptions } from './interfaces/integration-module-options.interface'; | ||
|
||
export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = | ||
new ConfigurableModuleBuilder<IntegrationModuleOptions>() | ||
.setClassMethodName('forRoot') | ||
.setFactoryMethodName('construct') | ||
.setExtras( | ||
{ | ||
isGlobal: true, | ||
}, | ||
(definition, extras) => ({ | ||
...definition, | ||
global: extras.isGlobal, | ||
}), | ||
) | ||
.build(); |
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,16 @@ | ||
import { Inject, Module } from '@nestjs/common'; | ||
import { | ||
ConfigurableModuleClass, | ||
MODULE_OPTIONS_TOKEN, | ||
} from './integration.module-definition'; | ||
import { IntegrationModuleOptions } from './interfaces/integration-module-options.interface'; | ||
|
||
@Module({}) | ||
export class IntegrationModule extends ConfigurableModuleClass { | ||
constructor( | ||
@Inject(MODULE_OPTIONS_TOKEN) | ||
public readonly options: IntegrationModuleOptions, | ||
) { | ||
super(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
integration/module-utils/src/interfaces/integration-module-options.interface.ts
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,4 @@ | ||
export interface IntegrationModuleOptions { | ||
url: string; | ||
secure?: boolean; | ||
} |
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,47 @@ | ||
import { Test } from '@nestjs/testing'; | ||
import { expect } from 'chai'; | ||
import { IntegrationModule } from '../src/integration.module'; | ||
|
||
describe('Module utils (ConfigurableModuleBuilder)', () => { | ||
it('should auto-generate "forRoot" method', async () => { | ||
const moduleRef = await Test.createTestingModule({ | ||
imports: [ | ||
IntegrationModule.forRoot({ | ||
isGlobal: true, | ||
url: 'test_url', | ||
secure: false, | ||
}), | ||
], | ||
}).compile(); | ||
|
||
const integrationModule = moduleRef.get(IntegrationModule); | ||
|
||
expect(integrationModule.options).to.deep.equal({ | ||
url: 'test_url', | ||
secure: false, | ||
}); | ||
}); | ||
|
||
it('should auto-generate "forRootAsync" method', async () => { | ||
const moduleRef = await Test.createTestingModule({ | ||
imports: [ | ||
IntegrationModule.forRootAsync({ | ||
isGlobal: true, | ||
useFactory: () => { | ||
return { | ||
url: 'test_url', | ||
secure: false, | ||
}; | ||
}, | ||
}), | ||
], | ||
}).compile(); | ||
|
||
const integrationModule = moduleRef.get(IntegrationModule); | ||
|
||
expect(integrationModule.options).to.deep.equal({ | ||
url: 'test_url', | ||
secure: false, | ||
}); | ||
}); | ||
}); |
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,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"declaration": false, | ||
"noImplicitAny": false, | ||
"removeComments": true, | ||
"noLib": false, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"target": "es6", | ||
"sourceMap": true, | ||
"allowJs": true, | ||
"outDir": "./dist" | ||
}, | ||
"include": [ | ||
"src/**/*", | ||
"e2e/**/*" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
] | ||
} |
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
Oops, something went wrong.