@loopback/core
Advanced tools
Comparing version 1.10.7 to 1.11.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [1.11.0](https://github.com/strongloop/loopback-next/compare/@loopback/core@1.10.7...@loopback/core@1.11.0) (2019-11-25) | ||
### Features | ||
* **core:** add [@service](https://github.com/service) decorator to inject a service by class/interface ([1d80904](https://github.com/strongloop/loopback-next/commit/1d80904b670724b00cb6a2965b8472f44d23eed0)) | ||
## [1.10.7](https://github.com/strongloop/loopback-next/compare/@loopback/core@1.10.6...@loopback/core@1.10.7) (2019-11-12) | ||
@@ -8,0 +19,0 @@ |
@@ -5,2 +5,3 @@ import { Binding, Constructor, Context, Provider } from '@loopback/context'; | ||
import { Server } from './server'; | ||
import { ServiceOptions } from './service'; | ||
/** | ||
@@ -181,3 +182,3 @@ * Application is the container for various types of artifacts, such as | ||
*/ | ||
service<S>(cls: Constructor<S> | Constructor<Provider<S>>, name?: string): Binding<S>; | ||
service<S>(cls: Constructor<S> | Constructor<Provider<S>>, name?: string | ServiceOptions): Binding<S>; | ||
} | ||
@@ -184,0 +185,0 @@ /** |
@@ -13,2 +13,3 @@ "use strict"; | ||
const lifecycle_registry_1 = require("./lifecycle-registry"); | ||
const service_1 = require("./service"); | ||
const debug = debugFactory('loopback:core:application'); | ||
@@ -262,17 +263,4 @@ /** | ||
service(cls, name) { | ||
if (!name && context_1.isProviderClass(cls)) { | ||
// Trim `Provider` from the default service name | ||
// This is needed to keep backward compatibility | ||
const templateFn = context_1.bindingTemplateFor(cls); | ||
const template = context_1.Binding.bind('template').apply(templateFn); | ||
if (template.tagMap[context_1.ContextTags.PROVIDER] && | ||
!template.tagMap[context_1.ContextTags.NAME]) { | ||
// The class is a provider and no `name` tag is found | ||
name = cls.name.replace(/Provider$/, ''); | ||
} | ||
} | ||
const binding = context_1.createBindingFromClass(cls, { | ||
name, | ||
type: 'service', | ||
}); | ||
const options = typeof name === 'string' ? { name } : name; | ||
const binding = service_1.createServiceBinding(cls, options); | ||
this.add(binding); | ||
@@ -279,0 +267,0 @@ return binding; |
@@ -9,1 +9,2 @@ export * from '@loopback/context'; | ||
export * from './server'; | ||
export * from './service'; |
@@ -19,2 +19,3 @@ "use strict"; | ||
__export(require("./lifecycle-registry")); | ||
__export(require("./service")); | ||
//# sourceMappingURL=index.js.map |
@@ -77,2 +77,6 @@ import { BindingKey } from '@loopback/context'; | ||
/** | ||
* Binding tag for the service interface | ||
*/ | ||
const SERVICE_INTERFACE = "serviceInterface"; | ||
/** | ||
* Binding tag for life cycle observers | ||
@@ -79,0 +83,0 @@ */ |
@@ -87,2 +87,6 @@ "use strict"; | ||
/** | ||
* Binding tag for the service interface | ||
*/ | ||
CoreTags.SERVICE_INTERFACE = 'serviceInterface'; | ||
/** | ||
* Binding tag for life cycle observers | ||
@@ -89,0 +93,0 @@ */ |
{ | ||
"name": "@loopback/core", | ||
"version": "1.10.7", | ||
"version": "1.11.0", | ||
"description": "LoopBack 4 core", | ||
@@ -22,9 +22,9 @@ "engines": { | ||
"dependencies": { | ||
"@loopback/context": "^1.23.5", | ||
"@loopback/context": "^1.24.0", | ||
"debug": "^4.1.1" | ||
}, | ||
"devDependencies": { | ||
"@loopback/build": "^2.0.16", | ||
"@loopback/eslint-config": "^4.1.4", | ||
"@loopback/testlab": "^1.9.4", | ||
"@loopback/build": "^2.1.0", | ||
"@loopback/eslint-config": "^4.1.5", | ||
"@loopback/testlab": "^1.9.5", | ||
"@types/debug": "^4.1.5", | ||
@@ -46,3 +46,3 @@ "@types/node": "^10.17.5" | ||
}, | ||
"gitHead": "7f0ae6ec124c19357c3016cd11f9bc9c739dffcb" | ||
"gitHead": "c111543a6139c5a2999930c593aabbbdf10a838e" | ||
} |
@@ -9,8 +9,5 @@ // Copyright IBM Corp. 2017,2018. All Rights Reserved. | ||
BindingScope, | ||
bindingTemplateFor, | ||
Constructor, | ||
Context, | ||
ContextTags, | ||
createBindingFromClass, | ||
isProviderClass, | ||
Provider, | ||
@@ -28,2 +25,3 @@ } from '@loopback/context'; | ||
import {Server} from './server'; | ||
import {createServiceBinding, ServiceOptions} from './service'; | ||
const debug = debugFactory('loopback:core:application'); | ||
@@ -315,21 +313,6 @@ | ||
cls: Constructor<S> | Constructor<Provider<S>>, | ||
name?: string, | ||
name?: string | ServiceOptions, | ||
): Binding<S> { | ||
if (!name && isProviderClass(cls)) { | ||
// Trim `Provider` from the default service name | ||
// This is needed to keep backward compatibility | ||
const templateFn = bindingTemplateFor(cls); | ||
const template = Binding.bind<S>('template').apply(templateFn); | ||
if ( | ||
template.tagMap[ContextTags.PROVIDER] && | ||
!template.tagMap[ContextTags.NAME] | ||
) { | ||
// The class is a provider and no `name` tag is found | ||
name = cls.name.replace(/Provider$/, ''); | ||
} | ||
} | ||
const binding = createBindingFromClass(cls, { | ||
name, | ||
type: 'service', | ||
}); | ||
const options = typeof name === 'string' ? {name} : name; | ||
const binding = createServiceBinding(cls, options); | ||
this.add(binding); | ||
@@ -336,0 +319,0 @@ return binding; |
@@ -17,1 +17,2 @@ // Copyright IBM Corp. 2017,2018. All Rights Reserved. | ||
export * from './server'; | ||
export * from './service'; |
@@ -123,2 +123,6 @@ // Copyright IBM Corp. 2017,2018. All Rights Reserved. | ||
export const SERVICE = 'service'; | ||
/** | ||
* Binding tag for the service interface | ||
*/ | ||
export const SERVICE_INTERFACE = 'serviceInterface'; | ||
@@ -125,0 +129,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
143652
42
2822
Updated@loopback/context@^1.24.0