Skip to content

With this repo you can create a simple server to write/read to/from shared memory through two dedicated APIs.

License

Notifications You must be signed in to change notification settings

exvion/Shared-Memory-NodeJS-Demo-Server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to write/read to/from shared memory with NodeJS

With this repo you can create a simple server to write/read to/from shared memory through two dedicated APIs.

Prerequisites

The prerequisites are:

  • NodeJS with npm and node-gyp
  • C++

Building node module

First of all, you have to build the custom node module in order to use it. So, go to shmnode directory and launch two simple node-gyp commands.

From the root directory of the repo, launch these commands:

cd shmnode
node-gyp configure --debug
node-gyp build --debug

If the output of the terminal is like this

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
...
gyp info ok

after node-gyp configure --debug and

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info spawn make
...
gyp info ok

your build is succesfull and you can start using this custom module.

Now you can return to the root directory of the repo.

Starting server

Once you have built the node module, you have to install some packages in order to start the simple server. So, go to the root directory of the repo and install node packages with:

npm install

After that, if the installation ends without errors, you can easily start the server with:

node server.js

The server is listening on port 8080 by default and you can use its APIs. If the node command ends without errors, you should have this in output (node listening on selected port):

user@user-vm:~/path/to/repo$ node server.js 
listening on *:8080
|

Server routes

In this section server routes are provided.

Read from shared memory


Returns json data read from shared memory.

Title Shared memory data
URL /read
Method GET
URL Parameters None
Success Response Code: 200
Content: {"TEST": "test"}

Write to shared memory


Returns json data wrote and read from shared memory.

Title Shared memory data
URL /write
Method POST
URL Parameters None
Body type: application/json
data: {"TEST": "test"}
Success Response Code: 200
Content: {"TEST": "test"}

Credits

Staff Makarenalabs

About

With this repo you can create a simple server to write/read to/from shared memory through two dedicated APIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 66.8%
  • JavaScript 30.1%
  • Python 3.1%