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

1.1.1 • Public • Published

body-reader

Lazy request body stream consumption.

import * as Http from "http";
import * as Parser from "body-reader";
import * as B from "fmt-bytes";
 
Http.createServer((request, response) => {
  Parser.Json.read(
    request,
    { limit: B.toBytes(100, "KiB"), encoding: "utf8" },
    result =>
      result.match({
        Ok(data) {
          response.setHeader("content-type", "application/json");
          response.write(JSON.stringify(data));
          response.end();
        },
        Err(err) {
          response.writeHead(err.code, {
            "content-type": "application/json",
          });
          response.write(JSON.stringify(err));
          response.end();
        },
      })
  );
}).listen({ port: 3000 });

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.1
    0
  • 1.1.0
    0

Package Sidebar

Install

npm i body-reader

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

12.8 kB

Total Files

21

Last publish

Collaborators

  • alexsasharegan