njinn
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

nJinn Build Status codecov npm

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.

Readme

Keywords

Package Sidebar

Install

npm i njinn

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

30.4 kB

Total Files

19

Last publish

Collaborators

  • jansivans