Add make helper and bump version

This commit is contained in:
Garrett Mills 2022-03-29 15:29:27 -05:00
parent 737d06f6f0
commit ba87ea32c3
3 changed files with 16 additions and 1 deletions

View File

@ -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",

View File

@ -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'

13
src/make.ts Normal file
View File

@ -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)
}