Giter Club home page Giter Club logo

bs-node-http's Introduction

bs-node-http

Node http bindings for Bucklescript in Reason

Status

Obligatory "this is just a WIP" section. Feel free to pull down and extend the API and/or make it better ... I don't pretend to be a ReasonML wizard.

I will be accepting PR's. Node HTTP is one of my most used modules and I'm surprised this wasn't done yet. A good alternative, though, is the bs-express project if you are after routing as well.

Installation

Install bs-node-http from npm. npm i -S bs-node-http.

Then, add bs-node-http to yor bs-dependencies in your bsconfig.json.

{
  "bs-dependencies": ["bs-node-http"]
}

Usage

The api is modified to favour piping the response so doesn't map 1 to 1 with the Node API. It's very minimal at the moment - if what you want isn't added feel free to add a binding in src/NodeHTTP.re then implement the API in src/Http.re

open Http;

let handler = (~request as _, ~response) =>
  response
  |> Response.setStatusCode(200)
  |> Response.setHeader("X-some-fancy-header", "hederz 4 dayz")
  |> Response.write("Foo")
  |> Response.write("Bar")
  |> Response.close;

let server = create_server(handler) |> Server.listen(~port=3000);

bs-node-http's People

Contributors

tomlingham avatar

Watchers

James Cloos avatar Glenn Slotte avatar

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.