npm.io
0.1.4 • Published 7 years ago

fastify-with-reason

Licence
MIT
Version
0.1.4
Deps
3
Size
207 kB
Vulns
5
Weekly
0
Stars
4

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:

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);
  }
);

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)

Keywords