Express Transport
The@feathersjs/express module provides Express framework bindings and a REST API provider for Feathers applications.
Installation
feathersExpress()
Creates a Feathers application that extends an Express app with Feathers functionality.Signature
A Feathers application instance to extend with Express functionality
An Express application instance (defaults to
express())Returns
Combined Express and Feathers application with extended functionality including:
- All Express app methods and middleware
- All Feathers service and hook capabilities
- Enhanced
listen()method that calls Featherssetup() - Enhanced
use()method that handles both Express middleware and Feathers services
Example
rest()
Configures the REST transport provider for Feathers services.Signature
REST configuration options or a custom formatter function
RestOptions
Custom response formatter middleware (defaults to JSON formatter)
Authentication configuration for parsing credentials from HTTP requests
Example
errorHandler()
Express error handling middleware that formats Feathers errors.Signature
Error handler configuration options
ErrorHandlerOptions
Path to public directory for HTML error pages
Logger configuration for error logging
HTML error page configuration or custom handler function
JSON error response configuration or custom handler function
Example
notFound()
Middleware that creates a NotFound error for unmatched routes.Signature
Include the requested URL in the error message
Example
authenticate()
Express middleware for authenticating requests.Signature
Authentication service name or settings object
Authentication strategies to use
AuthenticationSettings
Name of the authentication service
Array of authentication strategy names
Example
parseAuthentication()
Middleware that parses authentication credentials from HTTP headers.Signature
Authentication parsing configuration
Example
Exported Express Utilities
The module also exports commonly used Express utilities:Service Options
Express-specific service options can be configured when registering services:Middleware to run before the service handler
Middleware to run after the service handler
Request Extensions
The Express request object is extended with Feathers-specific properties:Feathers params object containing provider, headers, and other metadata
Service route lookup information
Response Extensions
The Express response object is extended with:The service method result data
The hook context from the service call