[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ENZDDC47YV4WZ4XTZ0THKB":3,"skill-same:01M7ENZDDC47YV4WZ4XTZ0THKB":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":40,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":6,"ownerDescription":43,"updatedAt":44,"install":45,"resources":58},"01M7ENZDDC47YV4WZ4XTZ0THKB","nestjs",null,"Use when building or structuring a NestJS backend — feature modules, providers and DI wiring, provider scopes and request-lifecycle order, where to bind guards\u002Fpipes\u002Finterceptors\u002Ffilters, and testing with Test.createTestingModule. NOT a bare Express\u002FFastify service with no DI (that is `nodejs`), NOT framework-agnostic REST design (that is `api-design`).","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fnestjs\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: nestjs\ndescription: \"Use when building or structuring a NestJS backend — feature modules, providers and DI wiring, provider scopes and request-lifecycle order, where to bind guards\u002Fpipes\u002Finterceptors\u002Ffilters, and testing with Test.createTestingModule. NOT a bare Express\u002FFastify service with no DI (that is `nodejs`), NOT framework-agnostic REST design (that is `api-design`).\"\ntags: [nestjs, nodejs, backend, dependency-injection, guards, pipes, testing, typescript]\nrecommends: [nodejs, typescript, api-design, prisma-orm, testing-web]\norigin: risco\n---\n\n# NestJS\n\nBuild server-side Node apps the way NestJS intends: feature modules, providers wired through the DI container, controllers, and a cross-cutting layer bound at a deliberate scope. This skill is about Nest-specific mechanics — how DI scopes resolve, what order the request lifecycle runs in, where to bind guards\u002Fpipes\u002Finterceptors\u002Ffilters, and how to test it with `Test.createTestingModule`.\n\n## Not this — route instead\n\n- Bare Express\u002FFastify\u002F`http` service, no `@Module`\u002F`@Injectable` → `..\u002Fnodejs\u002FSKILL.md`. Nest starts the moment the DI container appears.\n- REST resource modeling, versioning, status codes, idempotency (framework-agnostic) → `..\u002Fapi-design\u002FSKILL.md`. Nest is where you *implement* those decisions.\n- Designing the schema \u002F writing queries \u002F migrations → `..\u002Fprisma-orm\u002FSKILL.md`. *Injecting* a repo or `DataSource` provider stays here; designing the table does not.\n- Generic JS\u002FTS test infra (Jest config, coverage thresholds, monorepo) → `..\u002Ftesting-web\u002FSKILL.md`. The Nest harness (`TestingModule`, `overrideProvider`, Supertest bootstrap) stays here.\n\n## Mental model\n\nEverything is a **provider** in a directed DI graph. **Modules** draw the boundaries of that graph — a provider is only reachable where it is provided or imported. **Cross-cutting concerns** (guards, interceptors, pipes, filters) are decorators bound at a scope you choose: global, controller, or route. Get those three right and the rest is plumbing.\n\nThe request lifecycle runs in a fixed order. Memorize it — most \"my guard can't see the validated body\" bugs are an ordering misunderstanding:\n\n```text\nreq → middleware → guards → interceptors(pre) → pipes → handler → interceptors(post) → exception filters → res\n```\n\nSo pipes run *after* guards (a guard cannot read a transformed DTO), and filters catch everything thrown downstream. Source: NestJS request-lifecycle docs.\n\n## Module design\n\nOne feature module per bounded context. Rules, each with its why:\n\n- **`exports` is the module's public API.** A provider not exported is private to that module — that is the encapsulation, lean on it.\n- **`imports` brings in another module's exports; it does not re-declare providers.** Re-declaring a provider in two modules gives you two singletons and silent state bugs.\n- **Keep `AppModule` thin.** It wires feature modules and global config, nothing else. A god `AppModule` that declares every controller becomes an untestable circular-dependency magnet.\n- **Use a dynamic module (`forRoot` \u002F `forRootAsync`) for configurable infrastructure** (DB, cache, mailer) so consumers pass options instead of editing the module.\n\n```typescript\n\u002F\u002F Bad — everything dumped in AppModule, no boundaries\n@Module({ controllers: [OrdersController, UsersController, BillingController],\n          providers: [OrdersService, UsersService, BillingService, PrismaService] })\nexport class AppModule {}\n\n\u002F\u002F Good — a feature module owns its slice and exports only its public surface\n@Module({\n  imports: [PrismaModule],\n  controllers: [OrdersController],\n  providers: [OrdersService],\n  exports: [OrdersService], \u002F\u002F other modules consume the service, not the repo\n})\nexport class OrdersModule {}\n```\n\n## Providers & DI\n\nPick the custom-provider form by intent:\n\n| Form | Use it when | Resolved by |\n|------|-------------|-------------|\n| `useClass` | Default — swap implementation by class (e.g. real vs fake mailer) | Nest instantiates |\n| `useValue` | A ready object\u002Fconstant: config, a mock in tests | Used as-is |\n| `useFactory` | Value needs computing or other providers (`inject: [...]`) | Your factory fn |\n| `useExisting` | Alias an existing token to a new token | Reuses instance |\n\nA non-class token needs explicit injection — Nest has no type to reflect on:\n\n```typescript\nconst STRIPE = 'STRIPE_CLIENT';\n\n@Module({\n  providers: [{\n    provide: STRIPE,\n    useFactory: (cfg: ConfigService) => new Stripe(cfg.get('STRIPE_KEY')),\n    inject: [ConfigService],\n  }],\n  exports: [STRIPE],\n})\nexport class PaymentsModule {}\n\n@Injectable()\nexport class CheckoutService {\n  constructor(@Inject(STRIPE) private readonly stripe: Stripe) {}\n}\n```\n\n`forwardRef(() => X)` is a last resort, not a fix — it works around a circular dependency that usually signals two modules that should share a third. Reach for the refactor first; if you must, `forwardRef` goes on *both* sides. See the anti-patterns table.\n\n## Provider scopes\n\n| Scope | Lifetime | Use when |\n|-------|----------|----------|\n| `DEFAULT` | Singleton (one per app) | Almost always — stateless services |\n| `REQUEST` | New instance per request | You genuinely need per-request state (`@Inject(REQUEST)` for the live request) |\n| `TRANSIENT` | New instance per consumer | Each injector gets its own copy |\n\nREQUEST scope **bubbles up**: any provider that injects a request-scoped provider becomes request-scoped too, and so does the controller — with a real per-request instantiation cost. Default to singleton; reach for REQUEST only when you must.\n\n```typescript\n@Injectable({ scope: Scope.REQUEST })\nexport class RequestContext {\n  constructor(@Inject(REQUEST) private readonly req: Request) {}\n  get userId() { return this.req.user?.id; }\n}\n```\n\nThe classic gotcha: a request-scoped provider injected into a **guard** reads as undefined or stale because guards run early and the scope propagation is not what you assumed. If a guard needs request data, pull it from `ExecutionContext` (`context.switchToHttp().getRequest()`), not from an injected request-scoped service.\n\n## Cross-cutting layer\n\nPick the primitive by what it is *for*:\n\n| Primitive | Job | Signature |\n|-----------|-----|-----------|\n| Guard | Authorize — allow\u002Fdeny the request | returns `boolean` \u002F `Promise\u003Cboolean>` |\n| Interceptor | Wrap the handler before **and** after (logging, transform, timeout, cache) | RxJS, `handle().pipe(...)` |\n| Pipe | Validate and\u002For transform an input argument | returns transformed value or throws |\n| Exception filter | Catch a thrown error and shape the response | `catch(exception, host)` |\n\nThen pick the binding scope:\n\n| Binding | Reach | Can inject deps? |\n|---------|-------|------------------|\n| `APP_GUARD` \u002F `APP_PIPE` \u002F `APP_INTERCEPTOR` \u002F `APP_FILTER` token in a module's `providers` | Global | **Yes** — resolved by the DI container |\n| `@UseGuards(X)` \u002F `@UsePipes(X)` on controller or route | Local | Yes if you pass the class |\n| `app.useGlobalGuards(new X())` in `main.ts` | Global | **No** — you instantiated it yourself |\n\nThe gotcha that bites everyone: `app.useGlobalPipes(new ValidationPipe())` works, but a guard or pipe that needs to inject a `ConfigService` **cannot** be registered with `new` — Nest never resolved it. Use the `APP_*` token instead so the container builds it:\n\n```typescript\n\u002F\u002F Good — global AND DI-capable\n@Module({\n  providers: [{ provide: APP_GUARD, useClass: AuthGuard }],\n})\nexport class AppModule {}\n```\n\nDeeper material — `ExecutionContext`, custom param decorators, `Reflector` + `SetMetadata` for role\u002F`@Public()` guards, transform\u002Ftimeout interceptors, filter shape, multiple-binding order — is in `references\u002Fcross-cutting.md`.\n\n## Validation\n\nDTO + `ValidationPipe` + `class-validator`\u002F`class-transformer`. The production-safe config:\n\n```typescript\n\u002F\u002F main.ts\napp.useGlobalPipes(new ValidationPipe({\n  whitelist: true,            \u002F\u002F strip properties with no decorator\n  forbidNonWhitelisted: true, \u002F\u002F 400 on unknown properties instead of silently dropping\n  transform: true,            \u002F\u002F coerce payloads to DTO class instances (and primitives)\n}));\n```\n\n```typescript\nexport class CreateOrderDto {\n  @IsString() @IsNotEmpty()\n  sku: string;\n\n  @IsInt() @Min(1)\n  quantity: number;\n}\n```\n\nIf the pipe needs to inject something, bind it globally via `APP_PIPE` instead of `new` (same DI rule as above).\n\n## Testing\n\n`Test.createTestingModule({...}).compile()` returns a `TestingModule` you pull providers from. Decision line: **unit-test a provider with its collaborators mocked; e2e-test the wired app over HTTP.**\n\nUnit — mock the collaborators:\n\n```typescript\nconst moduleRef = await Test.createTestingModule({\n  providers: [OrdersService],\n})\n  .overrideProvider(OrderRepository)\n  .useValue({ findById: vi.fn().mockResolvedValue(order) })\n  .compile();\n\nconst service = moduleRef.get(OrdersService);\n```\n\ne2e — boot the real app and hit it with Supertest. **Replicate the global config from `main.ts`** (pipes, filters, guards) or the test passes while prod 400s:\n\n```typescript\nconst app = moduleRef.createNestApplication();\napp.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true })); \u002F\u002F mirror main.ts\nawait app.init();\nawait request(app.getHttpServer()).post('\u002Forders').send(body).expect(201);\n```\n\n`overrideGuard(AuthGuard).useValue({ canActivate: () => true })` lets an e2e test bypass auth. Full recipes — mocking a repo, request-scoped via `resolve()`, ConfigModule in tests, Vitest vs Jest — in `references\u002Ftesting-recipes.md`.\n\n## Bootstrap & tooling\n\n- Scaffold with the CLI, not by hand: `nest g resource orders`, `nest g module orders`, `nest g service orders`. It wires the module registration for you.\n- **NestJS 11** is current (Jan 2025), requires **Node.js 20+**, and ships **Express v5** as the default HTTP adapter (Fastify remains an option).\n- Use the **SWC builder** for dev — roughly 20x faster builds and faster cold start than `tsc`. Keep `tsc` for type-checking in CI.\n- ESM is first-class in v11 (top-level await aligned with modern Node).\n- The official harness is moving toward **Vitest** (SWC-powered) alongside Jest; Jest is still fully supported and is what `nest new` historically scaffolds.\n\n## Anti-patterns\n\n| Anti-pattern | Why it hurts | Do instead |\n|--------------|--------------|------------|\n| God `AppModule` declaring every controller\u002Fprovider | No boundaries; breeds circular deps; untestable | One feature module per bounded context, `exports` = public API |\n| `new OrdersService(repo)` inside a controller\u002Fservice | Bypasses DI; same class becomes two unmocked instances | Constructor-inject; let the container build it |\n| Business logic in the controller | Controllers should map HTTP ↔ service calls only | Push logic into a provider; controller stays thin |\n| `Scope.REQUEST` by default | Bubbles up the chain, per-request cost, surprise undefined in guards | Default singleton; REQUEST only with a real reason |\n| `useGlobalPipes(new X())` for a pipe that needs deps | `new` is not DI-resolved; injected deps are undefined | Bind via `APP_PIPE` \u002F `APP_GUARD` token in `providers` |\n| e2e test that skips `main.ts` globals | Green test, red prod — validation\u002Ffilters not applied | Replicate global pipes\u002Ffilters\u002Fguards in the e2e bootstrap |\n| `forwardRef` sprinkled to silence \"circular dependency\" | Hides the real coupling; fragile bootstrap order | Refactor to a shared module; `forwardRef` only as last resort, on both sides |\n\n## Verify\n\nRun `scripts\u002Fverify.sh [dir]` to statically catch DI bypasses without a Nest install. It hard-fails only on `new XxxService(...)` outside test files; everything else is a warning. Exits 0 on a clean or empty target.\n","# NestJS\n\nBuild server-side Node apps the way NestJS intends: feature modules, providers wired through the DI container, controllers, and a cross-cutting layer bound at a deliberate scope. This skill is about Nest-specific mechanics — how DI scopes resolve, what order the request lifecycle runs in, where to bind guards\u002Fpipes\u002Finterceptors\u002Ffilters, and how to test it with `Test.createTestingModule`.\n\n## Not this — route instead\n\n- Bare Express\u002FFastify\u002F`http` service, no `@Module`\u002F`@Injectable` → `..\u002Fnodejs\u002FSKILL.md`. Nest starts the moment the DI container appears.\n- REST resource modeling, versioning, status codes, idempotency (framework-agnostic) → `..\u002Fapi-design\u002FSKILL.md`. Nest is where you *implement* those decisions.\n- Designing the schema \u002F writing queries \u002F migrations → `..\u002Fprisma-orm\u002FSKILL.md`. *Injecting* a repo or `DataSource` provider stays here; designing the table does not.\n- Generic JS\u002FTS test infra (Jest config, coverage thresholds, monorepo) → `..\u002Ftesting-web\u002FSKILL.md`. The Nest harness (`TestingModule`, `overrideProvider`, Supertest bootstrap) stays here.\n\n## Mental model\n\nEverything is a **provider** in a directed DI graph. **Modules** draw the boundaries of that graph — a provider is only reachable where it is provided or imported. **Cross-cutting concerns** (guards, interceptors, pipes, filters) are decorators bound at a scope you choose: global, controller, or route. Get those three right and the rest is plumbing.\n\nThe request lifecycle runs in a fixed order. Memorize it — most \"my guard can't see the validated body\" bugs are an ordering misunderstanding:\n\n```text\nreq → middleware → guards → interceptors(pre) → pipes → handler → interceptors(post) → exception filters → res\n```\n\nSo pipes run *after* guards (a guard cannot read a transformed DTO), and filters catch everything thrown downstream. Source: NestJS request-lifecycle docs.\n\n## Module design\n\nOne feature module per bounded context. Rules, each with its why:\n\n- **`exports` is the module's public API.** A provider not exported is private to that module — that is the encapsulation, lean on it.\n- **`imports` brings in another module's exports; it does not re-declare providers.** Re-declaring a provider in two modules gives you two singletons and silent state bugs.\n- **Keep `AppModule` thin.** It wires feature modules and global config, nothing else. A god `AppModule` that declares every controller becomes an untestable circular-dependency magnet.\n- **Use a dynamic module (`forRoot` \u002F `forRootAsync`) for configurable infrastructure** (DB, cache, mailer) so consumers pass options instead of editing the module.\n\n```typescript\n\u002F\u002F Bad — everything dumped in AppModule, no boundaries\n@Module({ controllers: [OrdersController, UsersController, BillingController],\n          providers: [OrdersService, UsersService, BillingService, PrismaService] })\nexport class AppModule {}\n\n\u002F\u002F Good — a feature module owns its slice and exports only its public surface\n@Module({\n  imports: [PrismaModule],\n  controllers: [OrdersController],\n  providers: [OrdersService],\n  exports: [OrdersService], \u002F\u002F other modules consume the service, not the repo\n})\nexport class OrdersModule {}\n```\n\n## Providers & DI\n\nPick the custom-provider form by intent:\n\n| Form | Use it when | Resolved by |\n|------|-------------|-------------|\n| `useClass` | Default — swap implementation by class (e.g. real vs fake mailer) | Nest instantiates |\n| `useValue` | A ready object\u002Fconstant: config, a mock in tests | Used as-is |\n| `useFactory` | Value needs computing or other providers (`inject: [...]`) | Your factory fn |\n| `useExisting` | Alias an existing token to a new token | Reuses instance |\n\nA non-class token needs explicit injection — Nest has no type to reflect on:\n\n```typescript\nconst STRIPE = 'STRIPE_CLIENT';\n\n@Module({\n  providers: [{\n    provide: STRIPE,\n    useFactory: (cfg: ConfigService) => new Stripe(cfg.get('STRIPE_KEY')),\n    inject: [ConfigService],\n  }],\n  exports: [STRIPE],\n})\nexport class PaymentsModule {}\n\n@Injectable()\nexport class CheckoutService {\n  constructor(@Inject(STRIPE) private readonly stripe: Stripe) {}\n}\n```\n\n`forwardRef(() => X)` is a last resort, not a fix — it works around a circular dependency that usually signals two modules that should share a third. Reach for the refactor first; if you must, `forwardRef` goes on *both* sides. See the anti-patterns table.\n\n## Provider scopes\n\n| Scope | Lifetime | Use when |\n|-------|----------|----------|\n| `DEFAULT` | Singleton (one per app) | Almost always — stateless services |\n| `REQUEST` | New instance per request | You genuinely need per-request state (`@Inject(REQUEST)` for the live request) |\n| `TRANSIENT` | New instance per consumer | Each injector gets its own copy |\n\nREQUEST scope **bubbles up**: any provider that injects a request-scoped provider becomes request-scoped too, and so does the controller — with a real per-request instantiation cost. Default to singleton; reach for REQUEST only when you must.\n\n```typescript\n@Injectable({ scope: Scope.REQUEST })\nexport class RequestContext {\n  constructor(@Inject(REQUEST) private readonly req: Request) {}\n  get userId() { return this.req.user?.id; }\n}\n```\n\nThe classic gotcha: a request-scoped provider injected into a **guard** reads as undefined or stale because guards run early and the scope propagation is not what you assumed. If a guard needs request data, pull it from `ExecutionContext` (`context.switchToHttp().getRequest()`), not from an injected request-scoped service.\n\n## Cross-cutting layer\n\nPick the primitive by what it is *for*:\n\n| Primitive | Job | Signature |\n|-----------|-----|-----------|\n| Guard | Authorize — allow\u002Fdeny the request | returns `boolean` \u002F `Promise\u003Cboolean>` |\n| Interceptor | Wrap the handler before **and** after (logging, transform, timeout, cache) | RxJS, `handle().pipe(...)` |\n| Pipe | Validate and\u002For transform an input argument | returns transformed value or throws |\n| Exception filter | Catch a thrown error and shape the response | `catch(exception, host)` |\n\nThen pick the binding scope:\n\n| Binding | Reach | Can inject deps? |\n|---------|-------|------------------|\n| `APP_GUARD` \u002F `APP_PIPE` \u002F `APP_INTERCEPTOR` \u002F `APP_FILTER` token in a module's `providers` | Global | **Yes** — resolved by the DI container |\n| `@UseGuards(X)` \u002F `@UsePipes(X)` on controller or route | Local | Yes if you pass the class |\n| `app.useGlobalGuards(new X())` in `main.ts` | Global | **No** — you instantiated it yourself |\n\nThe gotcha that bites everyone: `app.useGlobalPipes(new ValidationPipe())` works, but a guard or pipe that needs to inject a `ConfigService` **cannot** be registered with `new` — Nest never resolved it. Use the `APP_*` token instead so the container builds it:\n\n```typescript\n\u002F\u002F Good — global AND DI-capable\n@Module({\n  providers: [{ provide: APP_GUARD, useClass: AuthGuard }],\n})\nexport class AppModule {}\n```\n\nDeeper material — `ExecutionContext`, custom param decorators, `Reflector` + `SetMetadata` for role\u002F`@Public()` guards, transform\u002Ftimeout interceptors, filter shape, multiple-binding order — is in `references\u002Fcross-cutting.md`.\n\n## Validation\n\nDTO + `ValidationPipe` + `class-validator`\u002F`class-transformer`. The production-safe config:\n\n```typescript\n\u002F\u002F main.ts\napp.useGlobalPipes(new ValidationPipe({\n  whitelist: true,            \u002F\u002F strip properties with no decorator\n  forbidNonWhitelisted: true, \u002F\u002F 400 on unknown properties instead of silently dropping\n  transform: true,            \u002F\u002F coerce payloads to DTO class instances (and primitives)\n}));\n```\n\n```typescript\nexport class CreateOrderDto {\n  @IsString() @IsNotEmpty()\n  sku: string;\n\n  @IsInt() @Min(1)\n  quantity: number;\n}\n```\n\nIf the pipe needs to inject something, bind it globally via `APP_PIPE` instead of `new` (same DI rule as above).\n\n## Testing\n\n`Test.createTestingModule({...}).compile()` returns a `TestingModule` you pull providers from. Decision line: **unit-test a provider with its collaborators mocked; e2e-test the wired app over HTTP.**\n\nUnit — mock the collaborators:\n\n```typescript\nconst moduleRef = await Test.createTestingModule({\n  providers: [OrdersService],\n})\n  .overrideProvider(OrderRepository)\n  .useValue({ findById: vi.fn().mockResolvedValue(order) })\n  .compile();\n\nconst service = moduleRef.get(OrdersService);\n```\n\ne2e — boot the real app and hit it with Supertest. **Replicate the global config from `main.ts`** (pipes, filters, guards) or the test passes while prod 400s:\n\n```typescript\nconst app = moduleRef.createNestApplication();\napp.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true })); \u002F\u002F mirror main.ts\nawait app.init();\nawait request(app.getHttpServer()).post('\u002Forders').send(body).expect(201);\n```\n\n`overrideGuard(AuthGuard).useValue({ canActivate: () => true })` lets an e2e test bypass auth. Full recipes — mocking a repo, request-scoped via `resolve()`, ConfigModule in tests, Vitest vs Jest — in `references\u002Ftesting-recipes.md`.\n\n## Bootstrap & tooling\n\n- Scaffold with the CLI, not by hand: `nest g resource orders`, `nest g module orders`, `nest g service orders`. It wires the module registration for you.\n- **NestJS 11** is current (Jan 2025), requires **Node.js 20+**, and ships **Express v5** as the default HTTP adapter (Fastify remains an option).\n- Use the **SWC builder** for dev — roughly 20x faster builds and faster cold start than `tsc`. Keep `tsc` for type-checking in CI.\n- ESM is first-class in v11 (top-level await aligned with modern Node).\n- The official harness is moving toward **Vitest** (SWC-powered) alongside Jest; Jest is still fully supported and is what `nest new` historically scaffolds.\n\n## Anti-patterns\n\n| Anti-pattern | Why it hurts | Do instead |\n|--------------|--------------|------------|\n| God `AppModule` declaring every controller\u002Fprovider | No boundaries; breeds circular deps; untestable | One feature module per bounded context, `exports` = public API |\n| `new OrdersService(repo)` inside a controller\u002Fservice | Bypasses DI; same class becomes two unmocked instances | Constructor-inject; let the container build it |\n| Business logic in the controller | Controllers should map HTTP ↔ service calls only | Push logic into a provider; controller stays thin |\n| `Scope.REQUEST` by default | Bubbles up the chain, per-request cost, surprise undefined in guards | Default singleton; REQUEST only with a real reason |\n| `useGlobalPipes(new X())` for a pipe that needs deps | `new` is not DI-resolved; injected deps are undefined | Bind via `APP_PIPE` \u002F `APP_GUARD` token in `providers` |\n| e2e test that skips `main.ts` globals | Green test, red prod — validation\u002Ffilters not applied | Replicate global pipes\u002Ffilters\u002Fguards in the e2e bootstrap |\n| `forwardRef` sprinkled to silence \"circular dependency\" | Hides the real coupling; fragile bootstrap order | Refactor to a shared module; `forwardRef` only as last resort, on both sides |\n\n## Verify\n\nRun `scripts\u002Fverify.sh [dir]` to statically catch DI bypasses without a Nest install. It hard-fails only on `new XxxService(...)` outside test files; everything else is a warning. Exits 0 on a clean or empty target.\n",{"name":5,"tags":24,"origin":32,"recommends":33,"description":7},[5,25,26,27,28,29,30,31],"nodejs","backend","dependency-injection","guards","pipes","testing","typescript","risco",[25,31,34,35,36],"api-design","prisma-orm","testing-web","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Fnestjs",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill nestjs",{"tool":51,"command":52},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill nestjs",{"tool":54,"command":55},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill nestjs","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fnestjs\u002FSKILL.md",true,[59,65,69,73],{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"evals\u002Fcases.yaml","REFERENCE","参考文档",2163,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fnestjs\u002Fevals\u002Fcases.yaml",{"path":66,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":67,"sourceHtmlUrl":68},"evals\u002FREADME.md",71,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fnestjs\u002Fevals\u002FREADME.md",{"path":70,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fcross-cutting.md",4768,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fnestjs\u002Freferences\u002Fcross-cutting.md",{"path":74,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":75,"sourceHtmlUrl":76},"references\u002Ftesting-recipes.md",3791,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fnestjs\u002Freferences\u002Ftesting-recipes.md",[78,86,91,98,105,112],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":85},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":87,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":85},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":85},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":85},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":85},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":85},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]