Extending Server API
ReactPress API is built on NestJS; source lives in monorepo server/. Two extension paths: modify core modules (contributors) and write plugin Hooks (recommended for third parties).
When to use plugins vs Server changes
| Approach | For | Upgrade impact |
|---|---|---|
| Plugin Hook | Business rules, field transforms, integrations | Low — independent package |
| Server PR | New REST resources, auth model, core bugs | Follows release cycle |
Third-party integrations should prefer Plugin development.
Server directory layout (summary)
server/src/
├── modules/
│ ├── article/ # post CRUD + Headless
│ ├── page/
│ ├── auth/
│ ├── plugin/ # plugin registry and HookService
│ └── ...
├── common/ # filters, guards, interceptors
└── main.ts
Each Feature Module has *.module.ts, *.controller.ts, *.service.ts.
Add a REST endpoint (contributors)
- Create or extend a module under
server/src/modules/ - Use Swagger decorators on Controller (
@ApiTags,@ApiOperation) - Register module in
app.module.ts - Run
pnpm run build:toolkitto regenerate OpenAPI client
// example: read-only endpoint
@Controller('example')
@ApiTags('example')
export class ExampleController {
@Get()
findAll() {
return { items: [] };
}
}
Hook integration points
PluginModule loads enabled plugins from .reactpress/plugins/ at startup; HookService dispatches:
applyFilters(name, payload)— can mutate datadoAction(name, payload)— side effects
Publish flow: see Plugin development.
Local API debugging
pnpm dev:api # Server only :3002
pnpm run test:smoke # /api/health
Swagger: http://localhost:3002/api
Architecture constraints
- Server must not depend on
web/,themes/, orplugins/source packages (plugin runtime loads via dynamic require) - All public types should flow through OpenAPI → toolkit codegen