( name: string, defaultScope = BindingScope.SINGLETON, )
| 80 | * @param - Default binding scope |
| 81 | */ |
| 82 | export function bindingScope( |
| 83 | name: string, |
| 84 | defaultScope = BindingScope.SINGLETON, |
| 85 | ) { |
| 86 | const scopeName = (process.env.BINDING_SCOPE ?? defaultScope).toLowerCase(); |
| 87 | const scopes = [ |
| 88 | BindingScope.APPLICATION, |
| 89 | BindingScope.SERVER, |
| 90 | BindingScope.REQUEST, |
| 91 | BindingScope.SINGLETON, |
| 92 | BindingScope.TRANSIENT, |
| 93 | BindingScope.CONTEXT, |
| 94 | ]; |
| 95 | const scope = |
| 96 | scopes.find(s => s.toLowerCase() === scopeName) ?? BindingScope.TRANSIENT; |
| 97 | debug('Binding scope for "%s" is set to "%s".', name, scope); |
| 98 | return scope; |
| 99 | } |
| 100 | |
| 101 | export async function count(ctx: Context, name: string) { |
| 102 | const keys = [REQUEST_COUNTER, SERVER_COUNTER, APPLICATION_COUNTER]; |
no test coverage detected