Kuzzle blog

Kuzzle as a Framework: a brand new way of developing applications

Written by Alicia Thermos | December 11, 2020

Every product goes through major stages of development. The complete overhaul of an API is definitely considered one of these milestones.

 
Article en Français

Today we officially release version 2.8.0 of Kuzzle, which includes the new API to extend the functionality of the backend: Kuzzle as a Framework.

 

TL;DR:

  • New API to extend backend functionality
  • Existing applications based on plugins remain 100% compatible
  • 100% Typescript compatibility
  • The plugin API will now be dedicated to... plugins only (generic and reusable bricks on several projects)
  • The documentation has been entirely rewritten for the occasion

Bad design lead to poor Developer eXperience

Since the creation of Kuzzle, the addition of specific business features was done via the plugin system, which were loaded from the file system.

 

This Nginx-like workflow with enabled and available folders was like a UFO in the world of Node.js and web backend development.

 

Although being a classic Node.js application, Kuzzle was launched as a kind of standalone application that could be customized via this plugin system.

 

We were aware that this was causing a lot of misunderstandings for our users and was slowing down the adoption of Kuzzle as a first class solution for backend development.

Talk is cheap, show me the code

After several months of development, we completely rethought the way to extend the backend functionalities.

 

The development of new features and their integration to Kuzzle is now done in the same way as most of the available Node.js framework.

 

Just install the kuzzle NPM package and start developing your application:

 

import { Backend, KuzzleRequest } from 'kuzzle';
import PluginOAuth from 'kuzzle-plugin-auth-passport-oauth';

// Instantiate the backend
const app = new Backend('iot-sensors');

// Use an external plugin
app.plugin.use(new PluginOAuth());

// Register an API controller
app.controller.register('iot', {
  actions: {
    measure: {
      handler: async (request: KuzzleRequest) => {
        await app.sdk.document.create('iot', 'measures', request.input.body);

        return { status: 'created' };
      }
    }
  }
});

// Start the application
app.start()
  .then(() => {
    app.log.info('Application started');
});

 

Most of the functionalities available for plugins are also available in the framework through the Backend class:

 

 

Internally the Backend class is just syntaxic sugar around the plugin API.

 

A brand new Getting Started allows you to start using the new framework in a few minutes: Write an Application

 

We have been using this feature internally for several months now, however we still consider it experimental because we want to be able to integrate possible feedback from the community.

 

 

 

100% Typescript Compatibility

Typescript has been growing in popularity among developers for several years now, making it a de facto standard for Open Source products.

 

This overhaul of our internal API has been accompanied by the conversion to Typescript of 100% of the classes and methods exposed to application developers.

 

Thus it is possible to take advantage of the security of the types system, as well as the integrated documentation and examples (if your editor allows it).

 

 

 

Brand New Documentation

The documentation was also completely rewritten for the occasion.

 

It has been divided into different guides to facilitate the learning of Kuzzle.

 

The references of the standard Kuzzle API (payloads, controllers, etc) and the references of the framework classes have been separated for more clarity.

 

We also took the opportunity to redesign the Algolia search and use the Open Source Algolia engine: DocSearch.

And Now ?

We are counting on your feedback to further improve Developer eXperience.

 

In the coming months we will of course continue to add new features in the framework!

 

Don't hesitate to come and join us on Discord if you have any questions or remarks ;-)