njinn
v1.0.0
Published
Build and run serverless javascript applications.
Downloads
3
Readme
nJinn
Build and run serverless JS applications.
Installation & Usage
CLI
nJinn can be run without any installation:
npx njinn -p 3033
Server will be available at http://localhost:3033
API
You can also use nJinn inside your project:
npm install njinn
Usage:
const nJinn = require('njinn');
(async () => {
await nJinn.startServer({ port: 3033 });
})();
Server API
Save script
POST
/saveScript
Body:
{
"id": "sum.js",
"script": "module.exports = (context) => { return context.a + context.b; }"
}
Execute script
POST
/executeScript
Body:
{
"id": "sum.js",
"context": {
"a": 2,
"b": 2
}
}
Install packages
POST
/installPackages
Body:
[
{
"package": "moment",
"version": "latest"
}
]
Queue jobs
Runs functions in the background and returns result to the specified webhook.
POST
/queueJobs
Body:
[
{
"id": "abc.js",
"webhook": { "url": "http://localhost:3034/webhook" }
}
]
Testing
Tests can be run by using docker-compose -f docker-compose.test.yml up --abort-on-container-exit --exit-code-from test
command.