OOX: A Simple and Fast Node.js Microservice Framework

OOX is a Node.js‑based microservice solution that removes the need for route definitions and configuration files, supports both HTTP and Socket.IO, provides example code for calculator services, and includes recent updates such as AsyncLocalStorage tracing and Socket.IO 4.4.0.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
OOX: A Simple and Fast Node.js Microservice Framework

OOX is a Node.js‑based microservice framework that eliminates the need for explicit route definitions and configuration files, allowing remote services to be invoked like local functions, and can also run as a traditional single‑instance application when microservice mode is not required.

The framework keeps the service port unchanged while supporting both HTTP and Socket.IO, meeting typical web API needs as well as long‑connection streaming requirements.

Example usage includes the following files:

// demo/index.js<br/>const calculator = require('./calculator')<br/><br/>exports.calc = async exp => {<br/>    const [ arg1, arg2 ] = exp.match(/\d+/g)<br/>    const [ op ] = exp.match(/[\+\-\*\/]/g)<br/>    const returns = await calculator[op](+arg1, +arg2)<br/>    return `${arg1}${op}${arg2}=${returns}`<br/>}<br/><br/>// demo/calculator.js<br/>module.exports = {<br/>    '+': (a, b) => a + b,<br/>    '-': (a, b) => a - b,<br/>    '*': (a, b) => a * b,<br/>    '/': (a, b) => a / b,<br/>}

To run OOX as a singleton, execute: oox index.js port=8001 To run it in microservice mode, use commands such as:

# Run index service on port 8001<br/>oox group=demo demo/index.js port=8001<br/><br/># Run calculator service on a random port and register it with the main service<br/>oox group=demo demo/calculator.js registry=:8001

Clients can invoke the service, for example with httpie: http :8001 action=calc params='3*5' Recent updates include the use of AsyncLocalStorage for traceability, a stack‑overflow fix when the entry file is index.js without a service directory, and an upgrade of Socket.IO to version 4.4.0.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

MicroservicesBackend DevelopmentNode.jsSocket.IOOOX
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.