With this repo you can create a simple server to write/read to/from shared memory through two dedicated APIs.
The prerequisites are:
NodeJSwithnpmandnode-gypC++
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 --debugIf the output of the terminal is like this
gyp info it worked if it ends with ok
gyp info using node-gyp@6.1.0
gyp info using node@10.19.0 | linux | x64
...
gyp info okafter node-gyp configure --debug and
gyp info it worked if it ends with ok
gyp info using node-gyp@6.1.0
gyp info using node@10.19.0 | linux | x64
gyp info spawn make
...
gyp info okyour build is succesfull and you can start using this custom module.
Now you can return to the root directory of the repo.
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 installAfter that, if the installation ends without errors, you can easily start the server with:
node server.jsThe 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
|In this section server routes are provided.
Returns json data read from shared memory.
| Title | Shared memory data |
|---|---|
| URL | /read |
| Method | GET |
| URL Parameters | None |
| Success Response | Code: 200Content: {"TEST": "test"} |
Returns json data wrote and read from shared memory.
| Title | Shared memory data |
|---|---|
| URL | /write |
| Method | POST |
| URL Parameters | None |
| Body | type: application/jsondata: {"TEST": "test"} |
| Success Response | Code: 200Content: {"TEST": "test"} |