Api
Use whenever writing, reviewing, or debugging code inside the `api/` NestJS module of BSS Fraud Blocker — the compat/legacy layer handling merchant CRUD (rules, tag-rules, checkout-rules, orders, settings, shop, analytics), Shopify webhook ingestion, and outbound sync-to-tracker events over RabbitMQ. Trigger on any task touching `api/src/**`: controllers/services/repositories/schemas/DTOs, `AuthGuard`/`ShopifyGuard` auth, RabbitMQ consumers/publishers (`@golevelup/nestjs-rabbitmq` + raw amqplib, two separate broker connections), Redis cache-invalidation calls, the HTTP response envelope, config namespaces, or `main.ts` bootstrap — even when phrased casually as "add an endpoint", "fix this consumer", "why isn't this rule syncing to tracker", or "add a Redis cache here". Covers the real, code-verified module/controller/service/repository/schema/DTO shape, both RabbitMQ brokers and every real consumer/publish call site, the Redis invalidate-only pattern, the HTTP envelope, config/bootstrap conventions, naming rules, and a "Never Do" guardrail list. Do NOT use for `cms` (Remix/React/Polaris frontend, no RabbitMQ) or `tracker` (storefront intake/rule-eval/bot-detection write path, which publishes *to* `api`) — those have their own skills; also skip for generic NestJS/RabbitMQ/Redis questions unrelated to this repo's `api` module.From its SKILL.md
npx -y skills add thanhhai0311/fraud-md --skill apiAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
8.5 KB, as published. Nobody here has run it
API Service — Coding Skill
Stack: NestJS 11, Mongoose 8, RabbitMQ (@golevelup/nestjs-rabbitmq + raw amqplib), Redis (ioredis), TypeScript 5.7, npm
api is the compat/legacy layer: it owns merchant-facing CRUD (rules, tag-rules, checkout-rules, orders, settings, shop, analytics), Shopify webhook ingestion, and a one-way outbound sync to tracker over RabbitMQ. It does not receive live sync data from tracker for tracking data — storefront.track.completed is consumed by api from tracker, not the other way around (see references/rabbitmq.md).
Security & Scale
Trước khi thêm query Mongo mới, cache key Redis mới, hoặc consumer/publisher RabbitMQ mới, đọc
.claude/rules/db-scale-and-security.md — quy tắc bảo mật (NoSQL injection qua filter chưa validate,
message RabbitMQ là input ngoài biên giới) và chuẩn thiết kế cho quy mô ≥100 triệu bản ghi (index,
cursor pagination, TTL Redis, consumer prefetch/idempotency) áp dụng chung cho api + tracker.
MCP Tools for api work
- Before extending a shared repository/service method, or adding a new consumer/publisher, use CodeGraph (
codegraph_search→codegraph_callers/codegraph_impact) instead of a grep+read loop. This module's own conventions are inconsistent from feature to feature (see the RabbitMQ error-handling reality inreferences/rabbitmq.md) — CodeGraph gets you to the actual nearest sibling implementation fast, which is what you should match, not a generic template. - Before changing a shared
types/*.type.tsenum or aSyncEvent/eventTypestring, usecodegraph_impactto see every caller acrossapibefore assuming a rename is safe — these values are also mirrored intrackerand are not caught by this repo's type checker alone.
Scripts (deterministic checks — run instead of hand-verifying)
node .claude/skills/api/scripts/check-redis-invalidate-only.mjs api/src— after touching any Redis call, flags anyredisService.set/get/setexoutsideredis.service.tsitself (api should only everdelete()). Seereferences/redis.md.node .claude/scripts/check-rabbitmq-contract.mjs api/src tracker/src— cross-service check (shared withtracker's skill): flags any consumerroutingKeywith no matching.publish('direct', '<key>', ...)anywhere in api+tracker source. Seereferences/rabbitmq.md.
Directory Layout
Real feature folders under api/src/: analytic, analyticV2, blocked-order, bot-detection, change-stream, checkout-rule, command, crm, device, integration, ip-info, job, module, order, order-risk, rule, setting, shop, shopify/* (webhook, auth, …), sync, tag-rule, visitor.
The canonical full module shape (used by rule, checkout-rule, tag-rule, device, order, module, analyticV2, blocked-order, setting, shop):
api/src/<feature>/
├── <feature>.module.ts # DI wiring
├── <feature>.controller.ts # HTTP endpoints
├── <feature>.service.ts # Business logic
├── <feature>.repository.ts # Data access (Mongoose)
├── <feature>.consumer.ts # RabbitMQ subscriber (if needed)
├── <feature>.publisher.ts # RabbitMQ publisher (if needed)
├── <feature>.mapper.ts # DTO ↔ Schema transformation (only a few features actually have one)
├── dto/
│ ├── create-<feature>.dto.ts
│ ├── update-<feature>.dto.ts
│ └── query-<feature>.dto.ts
├── schemas/
│ └── <feature>.schema.ts
└── types/
└── <feature>.type.ts
This is a template, not a hard rule — several real modules deliberately omit pieces:
sync/— no repository/dto/schema, justsync.module/service/consumer/publisher.ts+types/sync-event.type.ts. It's pure event routing (consumesstorefront.track.completedfrom tracker).bot-detection/— only.module.ts+.consumer.ts+types.ts+schemas/visitor-blacklist.schema.ts; no controller/service/repository of its own — delegates toVisitorService.change-stream/— a dynamic module (ChangeStreamModule.forFeature<T>()) built on native Mongoosemodel.watch()change streams, used to push rule/tag-rule/checkout-rule changes into Shopify metafields.change-stream.consumer.tsis an empty stub with no@RabbitSubscribe— despite the name it is not a RabbitMQ consumer.analyticV2/— driven by a cron job (src/job/analyticV2.cron.ts), not by user writes..mapper.tsonly exists indevice/,order/,visitor/,shared/brevo,shared/warehouse— do not assume every feature needs one.
Shared cross-cutting modules under src/shared/ (real list — user-agent no longer exists, UA parsing is inline via ua-parser-js):
src/shared/
├── rabbitmq/ # RabbitmqService (@golevelup, internal broker) + TrackingRabbitmqService (raw amqplib, separate broker)
├── redis/ # ioredis passthrough (cache-invalidation only in api, see references/redis.md)
├── geoip/ # MaxMind GeoIP2
├── proxy-check/ # Proxy/VPN detection
├── CIDR/ # CIDR IP range matching (capitalized directory)
├── aws/ # S3
├── brevo/ # Email/marketing integration
├── crm/ # CRM integration
├── mattermost/ # Notification integration
├── warehouse/ # Warehouse/data integration
├── bot-utils/ # Bot helper utilities
└── tracker/ # Tracker-facing config/helpers
Other shared top-level locations not tied to a feature: src/mappers/, src/helper/, src/keys/, src/types/.
Where to look next
This skill's detail lives in references/ — read the one(s) that match the task instead of loading everything:
| Task touches... | Read |
|---|---|
| A controller endpoint, guard, service method, repository query, Mongoose schema, DTO, enum/types file, or the HTTP response envelope | references/module-controller-service.md |
| A RabbitMQ consumer/publisher, either broker connection, or outbound sync-to-tracker events | references/rabbitmq.md |
Any Redis call (redisService.*) | references/redis.md |
A new config namespace, or main.ts bootstrap (guards, pipes, filters, interceptors) | references/config-bootstrap.md |
| Naming a new file (module/controller/service/repository/consumer/publisher/mapper/schema/dto/types) | references/naming.md |
Never Do
- Never write business logic in the repository — it is pure data access.
- Never change RabbitMQ exchange/routing key/queue name on one side only — check both
apiandtracker. - Never assume
apicaches reads in Redis — it only issuesdelete()for cache-busting; caching/reads happen intracker. - Never resurrect an "Outbox"/"ProcessedEventService" pattern by copying old docs without checking current code — both were removed; sync is a direct publish via
TrackingRabbitmqService. - Never remove a legacy endpoint or compatibility behavior without an explicit migration task.
- Never use
console.log— alwaysnew Logger(ClassName.name). - Never expose
.lean()documents as Mongoose model instances (they have no save/set methods).