Add make helper and bump version
This commit is contained in:
		
							parent
							
								
									737d06f6f0
								
							
						
					
					
						commit
						ba87ea32c3
					
				@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "@extollo/lib",
 | 
					  "name": "@extollo/lib",
 | 
				
			||||||
  "version": "0.9.3",
 | 
					  "version": "0.9.4",
 | 
				
			||||||
  "description": "The framework library that lifts up your code.",
 | 
					  "description": "The framework library that lifts up your code.",
 | 
				
			||||||
  "main": "lib/index.js",
 | 
					  "main": "lib/index.js",
 | 
				
			||||||
  "types": "lib/index.d.ts",
 | 
					  "types": "lib/index.d.ts",
 | 
				
			||||||
 | 
				
			|||||||
@ -37,6 +37,8 @@ export * from './http/lifecycle/Request'
 | 
				
			|||||||
export * from './http/lifecycle/Response'
 | 
					export * from './http/lifecycle/Response'
 | 
				
			||||||
export * from './http/RequestLocalStorage'
 | 
					export * from './http/RequestLocalStorage'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export * from './make'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export * as api from './http/response/api'
 | 
					export * as api from './http/response/api'
 | 
				
			||||||
export * from './http/response/DehydratedStateResponseFactory'
 | 
					export * from './http/response/DehydratedStateResponseFactory'
 | 
				
			||||||
export * from './http/response/ErrorResponseFactory'
 | 
					export * from './http/response/ErrorResponseFactory'
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								src/make.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/make.ts
									
									
									
									
									
										Normal 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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user