node package manager

caesarjs

caesarjs v0.7.1

Caesar js is a microservice framework for node.js

Caesar.js Project's homepage

https://caesarjs.com/

Project Documentation

https://caesarjs.com/api-documentation/

Key Concepts

Pattern Matching Objects

Pattern matching objects instead of URLs. When defining a server-based service the API user provides an object pattern. While caesarjs server will create an internal url for the service, the client won’t need to know about it. The API user will have to provide the object pattern so the client can work out the actual URL for the required service. The pattern matching is based on the patrun module and defines 2 basic rules:

  1. More specific matches beat less specific matches. That is, more property values beat fewer.
  2. Property names are checked in alphabetical order.

Mutual Data Encryption

Data is encrypted when exchanged between server and client. This feature works out of the box.

Mutual Certificate Authentication

Caesar.js client & server can be easily configured to securely communicate via the SSL/HTTPS channel and perform mutual authentication.

Built in endpoint metrics, stats

Caesar.js features a number of build in server endpoints returning performance metrics for specific endpoints, usage count stats for each endpoint and overall daily count.

Built in option to limit endpoints daily usage

You can limit the number of daily endpoint calls by setting a simple 'maxNumberOfRequests' request option at server level.

Built on top of Express and Request

Caesar.js is built on top of the node.js’s community widely used Express server and Request client.

Dead easy API

Client & server feature a very comprehensive, easy to understand API.

A quick code example for server & client APIs

const server = require('caesarjs').server;
const client = require('caesarjs').client;

const encryptorKey = '33a24560-a43b-44cc-b2bc-9cc0de14a093';

new server(3000, {encryptorKey}).add(
    {role: 'calculator', operation: 'sum'},
    (req, res) => {
        let n1 = req.data.n1;
        let n2 = req.data.n2;
        let sum = (n1 + n2);
        res.caesarJson({sum});
    })
.add(
    {role: 'calculator', operation: 'subtraction'},
    (req, res) => {
        let n1 = req.data.n1;
        let n2 = req.data.n2;
        let subtraction = (n1 - n2);
        res.caesarJson({subtraction});
    })
.listen();

let cclient = null;
new client('localhost', 3000, {encryptorKey})
                .init()
                .then( (client) => {
                    cclient = client;
                    return cclient.call({role: 'calculator', operation: 'sum'}, {n1: 10, n2: 10});
                }).then( (resp) => {
                    console.log('SUM', resp);
                    return cclient.call({role: 'calculator', operation: 'subtraction'}, {n1: 100, n2: 10});
                }).then( (resp) => {
                    console.log('SUBTRACTION', resp);
                }).catch( (err) => console.log(err) );