Services (Zod-first)
The recommended path remains:
- initialize the module,
- generate services with the CLI,
- then refine the generated files.
Example: new Nuxt 4 app + first service
bash
bunx nuxi@latest init my-nfz-services
cd my-nfz-services
bun install
bun add nuxt-feathers-zod feathers-pinia
bun add -D @pinia/nuxt
bunx nuxt-feathers-zod init embedded --force
bunx nuxt-feathers-zod add service articles --adapter mongodb --collection articles --idField _id --docs
bun devExpected structure
txt
services/<name>/
<name>.ts
<name>.class.ts
<name>.schema.ts
<name>.shared.tsFile roles
<name>.ts: service registration<name>.class.ts: service implementation<name>.schema.ts: Zod schemas / validators / resolvers when enabled<name>.shared.ts: client contract + types + shared behavior
Supported adapters
Memory
Default adapter, useful for:
- demos,
- smoke tests,
- fast start.
bash
bunx nuxt-feathers-zod add service messagesMongoDB
Use it when an embedded mongodbClient is configured.
bash
bunx nuxt-feathers-zod add service users --adapter mongodb --collection users --idField _idSchemas
By default, the generator currently aims for a simple start.
bash
bunx nuxt-feathers-zod add service messages --schema noneEnable schemas explicitly:
bash
bunx nuxt-feathers-zod add service messages --schema zod
bunx nuxt-feathers-zod add service messages --schema jsonAuth on a service
bash
bunx nuxt-feathers-zod add service users --auth --adapter mongodb --collection users --idField _idIn practice, users remains the reference service for embedded auth.
REST endpoints
With rest.path = '/feathers':
GET /feathers/articlesGET /feathers/articles/:idPOST /feathers/articlesPATCH /feathers/articles/:idDELETE /feathers/articles/:id
Best practices
- keep
servicesDirs: ['services'] - do not move services outside a scanned directory
- generate through the CLI, then customize
- do not break
*.shared.tsunless you understand its client-side role
