ngasemjs-server-core
NodeJS Framework to Create RPC Server
As you know about RPC, this is way to communicate between applications. Here, you got a very cool RPC server framework for NodeJS.
How cool is this?
- Zero dependencies, only use NodeJS native module.
- Simple procedure call API
- (i will define it next day, maybe :v)
How to use?
Installation
First, create your NodeJs project using npm init
command.
Then run command below inside that project.
npm i @ngasemjs/rpc-server
Creating RPC Server
To starting your RPC server, you have to create a file that calling the listen method from this RPC framework. You can follow example below.
// importing the framework
const rpc = require('@ngasemjs/rpc-server');
// run RPC server on port 8080
rpc.listen(8080, () => {
console.log('RPC server is running...');
});
Creating a Procedure
Before a procedure called, you have to define it. To do this, see the example below.
rpc.def('sum', (a, b) => {
return a + b;
});
Calling the Procedure
To call a procedure, you have to install client library for this framework. You can see client provided list below.
Or, you don't need to install any client, you can send HTTP request to the server with rules below.
- HTTP request to RPC server address (eg. http://localhost:8080)
- Using POST request method
- Put body like this:
{
"call": "procedureName",
"parameters": [ 1, 2, 3, 4 ]
}
Contributing
I hope everyone will contribute to this project, but i am not sure :v
If you want to contribute, fork and give me a pull request!