Feathers.JS: Realtime Micro-services with Node.js

As a technology consultation provider, Cenacle works with customers from various domains including Automotive, Healthcare, Retail, Energy and BFSI, on solutions ranging from IIOT, Blockchain, EHR, SmartContracts, DevOps, Predictive Analytics etc.

To be able to successfully deliver such varied solutions in a timely manner, we need architectures and frameworks that allow reuse and rapid-development. For majority of our solutions, we use micro-services architecture with backend data controlled through RESTful resources, sockets and flexible data-base plug-ins.

FeathersJS is a realtime, microservices web framework for NodeJs that suits all our above requirements. The micro-services architecture allows reuse, and scalability. RESTful and socket access allow easy integration for cross-language clients to access our functionality.

FeathersJS integrates nicely with various front-end frameworks, such as Vue, and can be used directly from browser code with @feathersjs/client.

FeathersJS has adapters for 15+ data sources out of the box, including MongoDB, Postgres, RethinkDB etc., which means we can support various customer backends seamlessly.

Optional plugins that support Passport authentication means, flexible authorization with JWT, OAuth1, OAuth2 etc.

Service hooks is a very powerful feature of FeathersJS that allows you plugin any custom code before and after various route handler methods, which is useful to inject loggers, rate limit controllers etc.

Creating a RESTful resource in FeathersJS is as simple as declaring a Javascript class module with below structure:

const myService = {
    async find(params) {
        return [];
    },
    async get(id, params) {},
    async create(data, params) {},
    async update(id, data, params) {},
    async patch(id, data, params) {},
    async remove(id, params) {},
    setup(app, path) {}
}

app.use('/my-service', myService);

Such defined FeathersJS service can be accessed through URL with one of the POST, GET etc. methods, or internally accessed through services, as:

  const myService = app.service('my-service');

  myService.find().then(items => console.log('.find()', items));
  myService.get(1).then(item => console.log('.get(1)', item));

This allows you to create interleaved services that access each other internally to provide a complex functionality at the application level.

Leave a Comment