Service Interface
A Feathers service implements up to six standard methods:Services are not required to implement all methods. Implement only what your use case needs.
Standard Methods
find(params)
Retrieve multiple records, optionally filtered and paginated:service.ts:7-9
- Paginated
- Non-Paginated
get(id, params)
Retrieve a single record by its unique identifier:service.ts:9
create(data, params)
Create one or more new records:service.ts:10
update(id, data, params)
Replace a record entirely (PUT semantics):service.ts:11
patch(id, data, params)
Partially update one or multiple records:service.ts:12
remove(id, params)
Delete one or multiple records:service.ts:13
Params Object
Theparams parameter provides context for service method calls:
declarations.ts:330-335
Custom Methods
Define custom service methods beyond the standard CRUD operations:service.ts:15,26-28
Custom methods must be explicitly listed in the
methods option to be available to external clients.Protected Methods
Certain method names are reserved and cannot be used as custom methods:service.ts:26-28
Lifecycle Hooks
setup(app, path)
Called when the application initializes:declarations.ts:91
teardown(app, path)
Called when the application shuts down:declarations.ts:93
Service Options
Configure services with options:declarations.ts:26-44
- Methods
- Events
- Route Params
Real-World Examples
Best Practices
- Validate input - Always validate data in hooks before processing
- Handle errors gracefully - Throw appropriate Feathers errors
- Return consistent shapes - Keep response formats predictable
- Use params for context - Pass authentication, user info via params
- Implement only needed methods - Don’t implement methods you don’t use
- Document custom methods - Make it clear what custom methods do
- Use TypeScript - Type your services for better developer experience
Next Steps
Hooks
Learn how to add middleware to service methods
Events
Understand real-time events from services