httple

1.0.3 • Public • Published

httple

MIT License npm version

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

Dependents (0)

Package Sidebar

Install

npm i httple

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

3.95 kB

Total Files

3

Last publish

Collaborators

  • redshoga