0.0.6 • Published 11 months ago

@ngasemjs/server-core v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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?

  1. Zero dependencies, only use NodeJS native module.
  2. Simple procedure call API
  3. (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. 1. NodeJS 2. JavaScript

Or, you don't need to install any client, you can send HTTP request to the server with rules below. 1. HTTP request to RPC server address (eg. http://localhost:8080) 2. Using POST request method 3. 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!

0.0.5

11 months ago

0.0.4

11 months ago

0.0.6

11 months ago

0.0.34

4 years ago

0.0.33

4 years ago

0.0.32

4 years ago

0.0.31

4 years ago