How to use the typedi.reset function in typedi

To help you get started, we’ve selected a few typedi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MichalLytek / type-graphql / examples / using-scoped-container / index.ts View on Github external
willSendResponse(requestContext: GraphQLRequestContext) {
            // remember to dispose the scoped container to prevent memory leaks
            Container.reset(requestContext.context.requestId);

            // for developers curiosity purpose, here is the logging of current scoped container instances
            // we can make multiple parallel requests to see in console how this works
            const instancesIds = ((Container as any).instances as ContainerInstance[]).map(
              instance => instance.id,
            );
            console.log("instances left in memory:", instancesIds);
          },
        }),