Skip to main content

Understanding Service Paths

In Feathers, every service is registered at a specific path that becomes its API endpoint. The path determines how clients access the service through REST, Socket.io, or other transports.

Basic Path Registration

Basic Paths
The path you register becomes the base URL for all service method calls:
  • GET /usersusers.find()
  • GET /users/123users.get(123)
  • POST /usersusers.create(data)
  • PATCH /users/123users.patch(123, data)
  • DELETE /users/123users.remove(123)

Path Normalization

Feathers automatically normalizes service paths by stripping leading and trailing slashes:
Path Normalization
Leading and trailing slashes are always stripped, so /users/ and users refer to the same service.

Root-Level Services

You can register a service at the root path:
Root Service

Nested Service Paths

Services can be registered at nested paths to create organized API structures:
Nested Paths

Route Parameters

Feathers routing supports dynamic route parameters using the :param syntax:
Route Parameters

Accessing Route Parameters

Route parameters are available in the params.route object within service methods and hooks:
Using Route Parameters

Sub-Applications

Mount entire Feathers applications as sub-applications to create modular, versioned APIs:
Sub-Applications
1

Create Sub-Application

Create a new Feathers application instance:
2

Register Services

Add services to the sub-application:
3

Mount Sub-App

Mount the sub-application on the main app with a path prefix:

Sub-Application Benefits

  • Modular Organization: Group related services together
  • API Versioning: Maintain multiple API versions side-by-side
  • Independent Configuration: Each sub-app can have its own hooks and settings
  • Service Reuse: Share services across multiple apps
Sub-App with Hooks

Express Middleware and Service Paths

When using Feathers with Express, you can add middleware before and after services:
Middleware with Services

Middleware Options

Pass middleware as service options for better organization:
Middleware Options

Router Implementation

Feathers uses an efficient routing system based on a tree structure that supports parameter matching:
Custom Router

Route Matching Priority

  1. Exact matches are checked first
  2. Placeholder matches (:param) are checked if no exact match
  3. First matching placeholder wins if multiple placeholders exist
Route Priority

Case Sensitivity

By default, Feathers routing is case-sensitive:
Case Sensitivity
To make routing case-insensitive:
Case-Insensitive Routing

Service Path Patterns

Common patterns for organizing service paths:

Complete Routing Example

Here’s a complete example with nested routes, parameters, and middleware:
Complete Routing Example