diff --git a/package.json b/package.json index cc2088f..426d0f1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.ts b/src/index.ts index 9172a45..54b06ec 100644 --- a/src/index.ts +++ b/src/index.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' diff --git a/src/make.ts b/src/make.ts new file mode 100644 index 0000000..cac8e26 --- /dev/null +++ b/src/make.ts @@ -0,0 +1,13 @@ +import {TypedDependencyKey} from './di' +import {Application} from './lifecycle/Application' +import {RequestLocalStorage} from './http/RequestLocalStorage' + +export function make(key: TypedDependencyKey): T { + const container = Application.getApplication() + const rls = container.make(RequestLocalStorage) + if ( rls.has() ) { + return rls.get().make(key) + } + + return container.make(key) +}