()
| 86 | } |
| 87 | |
| 88 | export async function main() { |
| 89 | const ctx = new Context('request'); |
| 90 | // Bind request context |
| 91 | ctx.bind(REQUEST_CONTEXT).to(ctx); |
| 92 | |
| 93 | const binding = createBindingFromClass(TracingInterceptor, { |
| 94 | key: TRACING_INTERCEPTOR, |
| 95 | }); |
| 96 | ctx.add(binding); |
| 97 | |
| 98 | let count = 1; |
| 99 | const reqUuidGenerator: RequestIdGenerator = context => |
| 100 | `[${context.name}] ${count++}`; |
| 101 | ctx.bind(REQUEST_ID_GENERATOR).to(reqUuidGenerator); |
| 102 | ctx.bind(GREETER).toClass(Greeter); |
| 103 | ctx.bind(CONVERTER).toClass(Converter).tag(BindingScope.SINGLETON); |
| 104 | |
| 105 | const greeter = await ctx.get(GREETER, {asProxyWithInterceptors: true}); |
| 106 | console.log(await greeter!.greet('John')); |
| 107 | } |
| 108 | |
| 109 | if (require.main === module) { |
| 110 | main().catch(err => { |
no test coverage detected