Integrations
Packages under integrations/ in the SHOPin storefront accelerator are data source adapters: NestJS modules that talk to external APIs (or mocks), map results to @core/contracts, and expose a service provider token that the BFF injects into DataSourceFactory (data-source.module.ts, data-source.factory.ts).
Reference trees in the repo include integrations/commercetools-api, integrations/mock-api, and integrations/contentful-api when present—the exact list can change; use integrations/ as source of truth.
Package layout
Illustrative tree (integrations/your-package/):
integrations/your-package/ ├── src/ │ ├── *-api.module.ts # Main module │ ├── *-service-provider.ts # Service provider │ ├── interfaces.ts │ ├── index.ts │ ├── client/ │ │ └── client.module.ts # API client config │ ├── services/ │ │ ├── index.ts │ │ ├── product.service.ts │ │ ├── navigation.service.ts │ │ └── *.service.ts │ └── [supporting-dirs]/ # mappers, helpers, queries, schemas, generators ├── package.json ├── tsconfig.json └── turbo.json
File names such as product.service.ts are examples—match domains your integration actually implements.
Anatomy
- Main module (
*-api.module.ts) — Often@Global(); exports the provider token (e.g.COMMERCETOOLS_SERVICE_PROVIDER,MOCK_SERVICE_PROVIDER); registers service implementations; imports the client module. - Service provider (
*-service-provider.ts) — Implements the*ServiceProviderinterface; aggregates services behind onegetServices()shape; injects concrete services. - Client module (
client/client.module.ts) — SDK or HTTP client, environment, authentication; request-scoped where needed; may use language/locale for localised APIs. - Services (
services/) — Implement interfaces and types from@core/contracts;index.tsre-exports classes the module registers. - Supporting code — Live APIs:
mappers/,helpers/,queries/,schemas/. Mock:generators/,helpers/.
Provider token names and folder layout are illustrative—copy from an existing integration in the monorepo.
Guides
- Add a new method — Contracts, all integrations, BFF delegation, optional HTTP route.
- Add a new service — New domain service across contracts, integrations, and BFF.
- Add a new integration — New package under
integrations/.
Summary
| Concern | Where to look |
|---|---|
| BFF wiring | Data sources, BFF |
| API shapes | Maintain contracts |
| Data source keys | Config & constants |
| New package shape | Other workspaces |