Step by Step Intro to Basic Feathers

Feathers is a REST and realtime API layer for modern applications.

[FeathersJS'] signature feature [is] that it’s super lightweight. It contains a simple and logical workflow that streamlines building apis and can make an api that would have taken hours and builds it in minutes. It hits the perfect balance of magic and control where you still have full control over how your api behaves but the tools provided make your life so much easier. -- Medium - "FeathersJS — A framework that will spoil you"

Warning: Feathers is addictive.

Services

Services are the heart of Feathers, as this is what all clients will interact with. They are middlemen and can be used to perform operations of any kind.

  • interact with a database
  • interact with a microservice/API
  • interact with the filesystem
  • interact with other resources
    • send an email,
    • process a payment,
    • return the current weather for a location, etc.

Hooks

Hooks are functions that run automatically before or after a service is called upon. They can be service gatekeepers and make sure that all operations are allowed and have the required information. They can also make sure that only data that should be returned to a client is returned.

  • before hooks: validate/cleanse/check permissions.
  • after hooks: add additional data or remove unneeded data before it's sent to the client.

Events

Events are sent to clients (or other servers if the feathers-sync package is used) when a service method completes. The created, updated, patched, and removed events provide real-time functionality

Event Filtering determines which users should receive an event. This is the Feathers alternative to Socket.io's rooms and it's an extremely intelligent approach that enables reactive applications to scale well.

Authentication

Feathers provides local, JSON Web Token, OAuth1 and OAuth2 authentication (using PassportJS) over REST and WebSockets.

Providers

Choose which providers to use in your application.

Middleware

Express middleware handles the extra fluff that isn't exactly necessary, but can be nice for optimization/logging.

  • before service methods: compression, CORS, etc.
  • after service methods: logs, error handlers, etc.

This guide's purpose

This guide covers

  • Services used with a database.
  • Hooks.
  • Events.
  • Providers.

It does not assume any prior knowledge of Feathers.

By the time you finish this guide, you will

  • have a solid understanding of Feathers basics.
  • understand how Feathers permits your code to be database agnostic.
  • understand how a Feathers server simultaneously and transparently supports a HTTP REST API, Feathers REST clients, and Feathers WebSocket clients.
  • understand that you can access your database from the client as if that client code was running on the server.
  • understand that the Feathers generators will structure your application for you, and you will understand the boilerplate they produce.

By the time you finish this guide, you will be ready to write your first app.

results matching ""

    No results matching ""