MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / main

Function main

examples/context/src/interceptor-proxy.ts:88–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86}
87
88export 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
109if (require.main === module) {
110 main().catch(err => {

Callers 1

Calls 9

bindMethod · 0.95
addMethod · 0.95
getMethod · 0.95
createBindingFromClassFunction · 0.90
toMethod · 0.80
toClassMethod · 0.80
tagMethod · 0.80
logMethod · 0.65
greetMethod · 0.65

Tested by

no test coverage detected