open-index/open-npm huggingface dataset:
npm package: @naturalint/xsite-framework-context
Description: Just a simple wrapper for `ni-context` package
Latest version: 1.0.0

## @naturalint/xsite-nest-context

Just a simple wrapper for `ni-context` package

How to use it in your service:

In your application module load `XSiteContextModule`

```typescript
import { ContextMiddleware, XSiteContextModule } from '@naturalint/xsite-nest-context';
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';

@Module({
  imports: [XSiteContextModule],
  providers: [MyService],
})
export class MyModule implements NestModule {
  configure(consumer: MiddlewareConsumer): void {
    consumer.apply(ContextMiddleware).forRoutes(<The routes you want>);
  }
}
```

Now, in your service you can use two different decorators:

```typescript
import { Injectable } from '@nestjs/common';
import { InjectCtxId, InjectCtx } from '@naturalint/xsite-nest-context';
import { XSiteContext, ContextId } from '@naturalint/xsite-nest-context';

@Injectable()
export class MyService {
  public constructor(
    @InjectCtxId() private readonly ctx: XSiteContext, // Will give you the ctx id of the request
    @InjectCtx() private readonly ctxId: ContextId // Will give you the full context object
  ) {}
}
```

*Please read more about middleware in NestJS here:*
https://docs.nestjs.com/middleware#middleware