Skip to content

Commit 8d801e2

Browse files
committed
style: code
1 parent 81b39ae commit 8d801e2

5 files changed

Lines changed: 21 additions & 24 deletions

File tree

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npm run lint
4+
npm run lint && npm run test

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"dependencies": {
6868
"@nestjs/common": "^8.4.4",
6969
"@nestjs/core": "^8.4.4",
70-
"@vodyani/core": "^0.2.30",
70+
"@vodyani/core": "^0.3.4",
7171
"lodash": "^4.17.21",
7272
"threads": "^1.7.0",
7373
"tiny-worker": "^2.3.0"

src/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class DustModule {
1515
static forRoot(options: DustManagerOptions, global = false): DynamicModule {
1616
const providers = [
1717
DustProvider,
18-
new DustManager(options).getFactoryProvider(),
18+
new DustManager(options).create(),
1919
];
2020

2121
return {

src/provider/dust-manager.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
1-
import { FixedContext } from '@vodyani/core';
2-
import { FactoryProvider } from '@nestjs/common';
1+
import { FixedContext, ProviderFactory } from '@vodyani/core';
32

43
import { DustManagerOptions } from '../common';
54

65
import { DustProvider } from './dust-provider';
76

8-
export class DustManager {
7+
export class DustManager implements ProviderFactory {
98
public static token = Symbol('DustManager');
109

11-
private provider: FactoryProvider;
10+
constructor(
11+
private readonly options: DustManagerOptions,
12+
) {}
1213

13-
constructor(private readonly options: DustManagerOptions) {
14-
this.provider = {
14+
@FixedContext
15+
public create() {
16+
return {
1517
inject: [DustProvider],
1618
provide: DustManager.token,
1719
useFactory: this.useFactory,
1820
};
1921
}
2022

2123
@FixedContext
22-
public getFactoryProvider() {
23-
return this.provider;
24-
}
25-
26-
@FixedContext
27-
private async useFactory(dust: DustProvider) {
24+
private async useFactory(provider: DustProvider) {
2825
this.options.forEach(({ dustKey, dustHandlerPath, dustOptions }) => {
29-
dust.create(dustKey, dustHandlerPath, dustOptions);
26+
provider.create(dustKey, dustHandlerPath, dustOptions);
3027
});
3128

32-
return dust;
29+
return provider;
3330
}
3431
}

0 commit comments

Comments
 (0)