1.0.3 • Published 5 years ago

httple v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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
1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago