These files show how to use AsyncContext in different scenarios. They are not part of the build and are meant for reference.
- Node.js 18+
- Install dependencies at the repo root (
npm install)
Some examples require extra dependencies (install if you want to run them):
expressfastifykoanext@nestjs/common@sentry/node@opentelemetry/api
npx tsx example/basic-context.tsIf you do not have tsx available, run from the repo root:
npm run dev -- example/basic-context.tsSENTRY_DSN(only needed byexample/sentry.ts)
example/basic-context.tsBasic Context usage (run, add values, snapshot).example/logger-basic.tsLogger with context, redaction, child logger, and timer.example/logger-env.tsLogger configured from environment.example/performance.tsContext.measure usage.example/openai.tsOpenAI wrapper with a fake call.example/opentelemetry.tsOpenTelemetry span and baggage with optional dynamic import.example/sentry.tsSentry init and exception capture with optional dynamic import.example/express.tsExpress middleware integration.example/fastify.tsFastify hook integration.example/koa.tsKoa middleware integration.example/next-api.tsNext.js API handler integration.example/nest.tsNest middleware integration (Express adapter).example/adonis.tsAdonis middleware integration.