Coder Social home page Coder Social logo

the-http's Introduction

The HTTP (TH)

A toolkit to help build HTTP service.

Features

  • Modern: Using async/await instead of callback
  • Simple: Simple function model: async (request) => response
  • Extensible: Via making and composing intuitive wrappers
  • Standard: Just HTTP
  • Micro: Suitable for micro service

Categories

Install

npm i --save the-http

Getting Started

const {Response, compose, handleErrors, listen} = require('the-http') 

async function handler(request) {
  const {name, age} = await request.body.asJSON()
  return Response.withJSONBody({
    isAdult: age >= 18,
    message: `Hello ${name}`
  })
}

const enhancedHandler = compose(
  handleErrors()
)(handler)

listen(3000)(enhancedHandler)

See RequestBody, Request, Response and more in API doc.

Awesome List

License

MIT

the-http's People

Stargazers

NeiNei_MyLove avatar eugle avatar Yao Zhao avatar

Watchers

James Cloos avatar Yao Zhao avatar

the-http's Issues

Thought about v2

  • get rid of lower node http module concept
  • use conversion over type or class
    • throw normal error
    • input args are normal object
    • support common output types
  • using js-type-language to doc api
  • keep core simple, do not include any utils or helpers
  • ship with generally proper built-in error handling logic

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.