Add make helper and bump version

orm-types
Garrett Mills 2 years ago
parent 737d06f6f0
commit ba87ea32c3

@ -1,6 +1,6 @@
{
"name": "@extollo/lib",
"version": "0.9.3",
"version": "0.9.4",
"description": "The framework library that lifts up your code.",
"main": "lib/index.js",
"types": "lib/index.d.ts",

@ -37,6 +37,8 @@ export * from './http/lifecycle/Request'
export * from './http/lifecycle/Response'
export * from './http/RequestLocalStorage'
export * from './make'
export * as api from './http/response/api'
export * from './http/response/DehydratedStateResponseFactory'
export * from './http/response/ErrorResponseFactory'

@ -0,0 +1,13 @@
import {TypedDependencyKey} from './di'
import {Application} from './lifecycle/Application'
import {RequestLocalStorage} from './http/RequestLocalStorage'
export function make<T>(key: TypedDependencyKey<T>): T {
const container = Application.getApplication()
const rls = container.make<RequestLocalStorage>(RequestLocalStorage)
if ( rls.has() ) {
return rls.get().make(key)
}
return container.make(key)
}
Loading…
Cancel
Save