New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

postfunction

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postfunction

A basic npm module used to *quickly* develop Node.js libraries and functions by exposing them through a webserver, easily allowing you to check it's return value with given arguments. Idea is to work well with pure functions.

latest
Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
Created
Source

postfunction

A basic npm module used to quickly develop Node.js libraries and functions by exposing them through a webserver, easily allowing you to check it's return value with given arguments. Idea is to work well with pure functions.

Basic Usage

Require the module in the file you have your functions in and just startWith the functions passed in:

const postfunction = require('./index');


function isEven(number) {
    return number % 2 === 0 ? `${number} is even!` : `${number} is odd.`
}

function someAsync(firstName, lastName) {
    return Promise.resolve(`Hello ${firstName} ${lastName}!`);
}

function greeting(firstName, lastName) {
    return someAsync(firstName, lastName);
}

postfunction.startWith(isEven, greeting);
...

The server starts on a random port and the following is logged in the app's console:

postFunction Server listening on port: 53883

Now just POST your arguments to http://localhost:port/functionName and have a look at your response!

Request:

{ "firstName": "John", "lastName": "Doe" }

Response:

{ "type": "promise<string>", "resolved": "Hello John Doe!", "rejected": null }

Magic!

Config

As of now, the only configuration available is the ability to define a port to start the server on. This is probably going to be useful.

postfunction.setPort(3000);

Todo

So far, only a regular JS object, type or Promise is supported. I would like the option to have the function run in a Node.js VM instance for pure functions to avoid side effects. A basic test has been written but please bare in mind this is pretty much the 'fist stab' at this so I'm sure it can be improved in may ways.

FAQs

Package last updated on 11 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts