Actio

The Node.js framework for monoliths and microservices.

README

Actio

The Node.js framework for monoliths and microservices.


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.


  1. ```sh
  2. npm i -S @crufters/actio
  3. ```

Simple


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

  1. ```typescript
  2. import { Service, Servicelike, startServer } from "@crufters/actio";

  3. interface MyEndpointRequest {
  4.   name?: string;
  5. }

  6. @Service()
  7. class MyService implements Servicelike {
  8.   constructor() {}

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

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

  17. startServer([MyService]);
  18. ```

Dependencies made easy


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

  1. ```ts
  2. @Service()
  3. class MyService implements Servicelike {
  4.   constructor(otherService: MyOtherService) {}
  5. }
  6. ```

Monolith or microservices? Actio blurs the line


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

  1. ```
  2. Without configuration, service calls are just normal function calls:
  3. --------------------------------
  4. |  LoginService     <-|  <-|   |
  5. | PaymentService  ----|    |   |
  6. |  OrderService   ---------|   |
  7. -------------------------------|
  8. instance address
  9.      0.0.0.0
  10.   no Actio config


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

  13. -------------------                     -----------------
  14. | PaymentService  |-------------------> | LoginService  |
  15. |  OrderService   |-------------------> |               |
  16. -------------------                     -----------------
  17. instance address                        instance address
  18.      0.0.0.0                                 0.0.0.1
  19. envar LOGIN_SERVICE=0.0.0.1

  20. Calls to the login service become network calls automatically.
  21. ```

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:

- [x] Authentication service for login, register, oauth (facebook etc.).
- [x] KeyValue service for saving unstructured data without creating yet another anemic endpoint/service.
- [x] File service for file upload. Upload to a local disk or to Google Storage etc. in production.
- [x] Config service for handling public configuration and secret values.
- [x] System service for inspecting the Actio runtime and enabling building tools upon Actio (such as API explorers etc.).
- [x] Payment service: a double entry ledger system with Stripe and other payment provider support.
- [ ] ...and many others that the community might find useful.

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.

- [x] Postgres
- [ ] Redis
- [ ] Many more coming

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.

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.