Home

Awesome

<p align="center"> <img width="200" height="200" src="assets/actiologo.png"> </p> <h1 align="center">Actio</h1> <h4 align="center">The Node.js framework for monoliths and microservices.</h4> <p align="center"> <img src="https://github.com/crufters/actio/actions/workflows/build.yaml/badge.svg" /> <a href="https://www.gnu.org/licenses/agpl-3.0"><img src="https://img.shields.io/badge/License-AGPL_v3-blue.svg" alt="License: AGPL v3"/></a> <img src="https://img.shields.io/badge/semver-0.3.6-yellow" /> </p>

Actio is a modern, batteries included Node.js (Typescript) framework for your backend applications. It enables you to effortlessly switch between monolithic and microservices architectures.

Start out with a monolith and turn it into microservices without changing your code once you need to scale!

Get started.

npm i -S @crufters/actio

Simple

Actio values simplicity and elegance, because enjoying coding makes you more productive.

import { Service, Servicelike, startServer } from "@crufters/actio";

interface MyEndpointRequest {
  name?: string;
}

@Service()
class MyService implements Servicelike {
  constructor() {}

  // this method will be exposed as an HTTP endpoint
  async myEndpoint(req: MyEndpointRequest) {
    return { hi: req.name };
  }

  async _onInit() {
    console.log("MyService: _onInit runs whenever the server boots up.");
  }
}

startServer([MyService]);

Dependencies made easy

Your services can easily call each other just by accepting a constructor parameter:

@Service()
class MyService implements Servicelike {
  constructor(otherService: MyOtherService) {}
}

Monolith or microservices? Actio blurs the line

Service calls are just function calls. Function calls become network calls simply by configuring Actio with envars:

Without configuration, service calls are just normal function calls:
--------------------------------
|  LoginService     <-|  <-|   |
| PaymentService  ----|    |   |
|  OrderService   ---------|   |
-------------------------------|
 instance address
     0.0.0.0
  no Actio config


With some lightweight configuration a true services based
architecture can be achieved, without code changes:

-------------------                     -----------------
| PaymentService  |-------------------> | LoginService  |
|  OrderService   |-------------------> |               |
-------------------                     -----------------
 instance address                        instance address
     0.0.0.0                                 0.0.0.1
envar LOGIN_SERVICE=0.0.0.1

Calls to the login service become network calls automatically.

Batteries included

Actio is batteries included: it comes with services that help you bootstrap your system (but tries to not force you to use these) faster:

Built with infrastructure in mind

Real world apps need persistence and many other infrastructure elements. Actio manages your infra dependencies just like your service dependencies.

Testing without the hassle

Run integration tests easily including all of your services and infrastructure dependencies. No need for mocking.

Namespaced for server savings

Actio enables you to run multiple projects from the same single server by namespaces. Save on server and maintenance cost.

Firm service boundaries

Actio isolates your services - no more sidestepping of service boundaries, be it intentional or accidental. Each service is a black box for other services, which enable you to reimplement services without breaking depending services.

The dependency injector makes sure your service tables live in different databases entirely - joins won't work across services. This and similar constraints enable you a seamless and refactor free transition to microservices - but also ensures your monolith doesn't became overly tightly coupled.

Examples and tutorials

For examples and tutorials see the Getting started guide.

Credits

Inspired by other microservices systems such as Micro and the author's previous work with Asim Aslam. Author: János Dobronszki. Contributors: Dávid Dobronszki, Asim Aslam, Viktor Veress.