Bucklescript Bindings for compression express middleware.
compression
is a Node.js compression middleware.
npm install --global bs-platform
yarn install
yarn build
This package can be used only with bs-express
. Make sure you already have bs-express
as a dependency in your project.
yarn add bs-compression
And add bs-compression
to dependencies
node of your bsconfig.json
.
For instance, here is the code to serve static files from public
folder and compress them.
Remark: The compression middleware must be passed first in the array of middlewares.
let app = express();
App.useOnPathWithMany(
app,
~path="/public",
[|
Compression.compression(),
{
let options = Static.defaultOptions();
Static.make("public", options) |> Static.asMiddleware
}
|]
);
let app = express ()
let _ =
App.useOnPathWithMany app ~path:"/public"
[|(Compression.compression ());((let options = Static.defaultOptions () in
(Static.make "public" options) |>
Static.asMiddleware))|]