Services
Services are the core of the module. They expose Feathers methods and carry the business contract of the application.
Recommended creation flow
bash
bunx nuxt-feathers-zod add service articles --adapter mongodb --schema zodThe CLI creates a structure that matches the module scanner and updates the .nfz manifest.
Standard methods
A Feathers service may expose:
find;get;create;update;patch;remove.
The actual available methods depend on the generated service and selected options.
Custom methods
bash
bunx nuxt-feathers-zod add custom-service reports --methods find,run --customMethods runCustom methods must be declared on both the service and the client side. This avoids transport errors, especially across SSR, REST and Socket.io.
Schemas
The recommended mode for business services is zod.
bash
bunx nuxt-feathers-zod add service tasks --schema zodThe module also supports lighter modes:
nonefor a minimal service;jsonfor a JSON-oriented description;zodfor a stronger TypeScript and runtime contract.
Hooks
Feathers hooks should be used for:
- authentication;
- RBAC rules;
- business validation;
- data enrichment;
- auditing;
- business events.
ts
export default {
before: {
all: [],
find: [],
create: [],
},
after: {
all: [],
},
error: {
all: [],
},
}Best practices
- Generate services with the CLI.
- Keep hooks close to the service.
- Define exposed methods clearly.
- Hide sensitive fields in external resolvers.
- Version the
.nfzmanifest. - Prefer domain composables or stores for sensitive pages.
