-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): update template to use new Functional API when it's possible
- Loading branch information
Showing
5 changed files
with
49 additions
and
142 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,35 +1,11 @@ | ||
import {Configuration, Inject, registerProvider} from "@tsed/di"; | ||
|
||
/** | ||
* Inject {{symbolName}} to the service, controller, etc... | ||
* | ||
* ## Usage | ||
* | ||
* ```typescript | ||
* import {Injectable} from "@tsed/di"; | ||
* import {{{symbolName}}} from "./{{symbolName}}"; | ||
* | ||
* @Injectable() | ||
* class MyService { | ||
* @{{symbolName}}() | ||
* private factory: {{symbolName}}; | ||
* | ||
* // or | ||
* constructor(@{{symbolName}}() private factory: {{symbolName}}){} | ||
* } | ||
* | ||
* @decorator | ||
*/ | ||
export function {{symbolName}}() { | ||
return Inject({{symbolName}}); | ||
} | ||
import {constant, injectable} from "@tsed/di"; | ||
|
||
export type {{symbolName}} = any; // implement type or interface for type checking | ||
export const {{symbolName}} = injectable(Symbol.for("{{symbolName}}") | ||
.factory(() => { | ||
// retrieve custom configuration from settings (e.g.: `@Configuration({hello: "value"})`) | ||
const hello = constant("hello"); | ||
|
||
registerProvider({ | ||
provide: {{symbolName}}, | ||
deps: [Configuration], | ||
useFactory(settings: Configuration) { | ||
return {}; | ||
} | ||
}); | ||
return {hello}; | ||
}) | ||
.token(); |
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 |
---|---|---|
@@ -1,32 +1,3 @@ | ||
import {Configuration, Inject, registerProvider} from "@tsed/di"; | ||
import {injectable} from "@tsed/di"; | ||
|
||
/** | ||
* Inject {{symbolName}} to the service, controller, etc... | ||
* | ||
* ## Usage | ||
* | ||
* ```typescript | ||
* import {Injectable} from "@tsed/di"; | ||
* import {{{symbolName}}} from "./{{symbolName}}"; | ||
* | ||
* @Injectable() | ||
* class MyService { | ||
* @{{symbolName}}() | ||
* private value: {{symbolName}}; | ||
* | ||
* // or | ||
* constructor(@{{symbolName}}() private value: {{symbolName}}){} | ||
* } | ||
* | ||
* @decorator | ||
*/ | ||
export function {{symbolName}}() { | ||
return Inject({{symbolName}}); | ||
} | ||
|
||
export type {{symbolName}} = any; // implement type or interface for type checking | ||
|
||
registerProvider({ | ||
provide: {{symbolName}}, | ||
useValue: {} | ||
}); | ||
export const {{symbolName}} = injectable(Symbol.for("{{symbolName}}")).value({}).token(); |
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