httple
The simple and minimal http wrapper for microservice
Usage
const httple = require("httple")
httple(
[HTTP method name]: string,
[port number]: number,
[regexp of endpoint]: RegExp,
[validation json object]: { [key: string]: (val) => boolean; },
[server behavir function]: (req, res, json: object) => void,
[server created callback function]: () => void
)
Sample code
JSON receive server
const httple = require("httple")
httple("POST", 3000, /^\/$/, {
a: (v) => { return v.length > 0; },
b: (v) => { return v.length > 1; },
c: (v) => { return v.length > 3; },
}, (req, res, json) => {
console.log(json);
res.writeHead(200, "Success");
res.end();
}, () => {
console.log("server start");
})
Simple GET server
const httple = require("httple")
httple("GET", 3000, /^\/$/, null, (req, res) => {
res.writeHead(200, "Success");
res.end();
}, () => {
console.log("server start");
})
Exec in Docker container
redshoga/httple-docker-sample: Sample docker container for simple http module
TODO
- [ ] Add test