6
29%
MIT
Fastify bindings in Reason

Logo

Fastify bindings for BuckleScript in ReasonML

Getting Started

Create a new project:

bsb -init server -theme basic-reason

Install fastify-with-reason using npm:

yarn add fastify-with-reason

Then add fastify-with-reason as a dependency to bsconfig.json

Example Server

Create a Server.re inside src:

  • RE
  • ML
open Fastify;

let app = createServer(~logger=true);

app->get("/", (_request, reply) => reply->send("Hello, world!"));

app->listen(3000, result =>
  switch (result) {
  | Ok(_address) => ()
  | Error(error) =>
    app->logError(error);
    Node.Process.exit(1);
  }
);
2310: syntax error, consider adding a `;' before

This server simply respond with a json "Hello, world!" on localhost:3000

yarn build
node src/Server.bs.js

A little Benchmark with Autocannon

On my iMac (2,3 GHz Intel Core i5 - 8 GB 2133 MHz DDR4)

Benchmark

Go to Wiki for documentation (coming soon)