{"id":13680839,"url":"https://github.com/bloodyowl/rescript-express","last_synced_at":"2026-03-12T15:04:06.758Z","repository":{"id":38424175,"uuid":"348313851","full_name":"bloodyowl/rescript-express","owner":"bloodyowl","description":"Experimental (nearly zero-cost) bindings to express","archived":false,"fork":false,"pushed_at":"2023-11-14T10:58:55.000Z","size":42,"stargazers_count":79,"open_issues_count":2,"forks_count":12,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-06T06:51:13.880Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"ReScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bloodyowl.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["bloodyowl"]}},"created_at":"2021-03-16T11:01:15.000Z","updated_at":"2024-11-19T07:44:22.000Z","dependencies_parsed_at":"2024-01-10T19:10:46.787Z","dependency_job_id":null,"html_url":"https://github.com/bloodyowl/rescript-express","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/bloodyowl/rescript-express","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloodyowl%2Frescript-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloodyowl%2Frescript-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloodyowl%2Frescript-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloodyowl%2Frescript-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bloodyowl","download_url":"https://codeload.github.com/bloodyowl/rescript-express/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloodyowl%2Frescript-express/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30429320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T14:34:45.044Z","status":"ssl_error","status_checked_at":"2026-03-12T14:09:33.793Z","response_time":114,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:01:22.661Z","updated_at":"2026-03-12T15:04:06.721Z","avatar_url":"https://github.com/bloodyowl.png","language":"ReScript","readme":"# rescript-express\n\n\u003e (nearly) zero-cost bindings to express \n\n## Installation\n\nRun the following in your console:\n\n```console\n$ yarn add rescript-express express\n```\n\nThen add `rescript-express` to your `bsconfig.json`'s `bs-dependencies`:\n\n```diff\n {\n   \"bs-dependencies\": [\n+    \"rescript-express\"\n   ]\n }\n```\n\n## Module system\n\nFor now, due to compability issues between commonJS and ES6 module, the bindings expose two `express` functions:\n\n- `express` for ES6\n- `expressCjs` to CommonJS\n\nBe careful to pick the right one given your compiler's configuration.\n\n## API\n\nThe API closely matches the express one. You can refer to the [express docs](https://expressjs.com/en/4x/api.html).\n\n### Notable differences\n\n- `express.json`, `express.raw`, `express.text`, `express.urlencoded`, `express.static` are all suffixed with `Middleware` to prevent name clashing.\n- `accept*` and `is` return an option intead of a string/boolean\n- `req.get` is called `getRequestHeader` and `res.get` is called `getResponseHeader`\n\nYou can check [the interface file](./src/Express.resi) to see the exposed APIs.\n\n## Example\n\n```rescript\nopen Express\n\nlet app = express()\n\napp-\u003euse(jsonMiddleware())\n\napp-\u003eget(\"/\", (_req, res) =\u003e {\n  let _ = res-\u003estatus(200)-\u003ejson({\"ok\": true})\n})\n\napp-\u003epost(\"/ping\", (req, res) =\u003e {\n  let body = req-\u003ebody\n  let _ = switch body[\"name\"]-\u003eJs.Nullable.toOption {\n  | Some(name) =\u003e res-\u003estatus(200)-\u003ejson({\"message\": `Hello ${name}`})\n  | None =\u003e res-\u003estatus(400)-\u003ejson({\"error\": `Missing name`})\n  }\n})\n\napp-\u003euseWithError((err, _req, res, _next) =\u003e {\n  Js.Console.error(err)\n  let _ = res-\u003estatus(500)-\u003eendWithData(\"An error occured\")\n})\n\nlet port = 8081\nlet _ = app-\u003elistenWithCallback(port, _ =\u003e {\n  Js.Console.log(`Listening on http://localhost:${port-\u003eBelt.Int.toString}`)\n})\n```\n\nGenerates the following\n\n```js\nvar Express = require(\"express\");\n\nvar app = Express();\n\napp.use(Express.json());\n\napp.get(\"/\", function (_req, res) {\n  res.status(200).json({\n    ok: true,\n  });\n});\n\napp.post(\"/ping\", function (req, res) {\n  var body = req.body;\n  var name = body.name;\n  if (name == null) {\n    res.status(400).json({\n      error: \"Missing name\",\n    });\n  } else {\n    res.status(200).json({\n      message: \"Hello \" + name,\n    });\n  }\n});\n\napp.use(function (err, _req, res, _next) {\n  console.error(err);\n  res.status(500).end(\"An error occured\");\n});\n\napp.listen(8081, function (param) {\n  console.log(\"Listening on http://localhost:\" + String(8081));\n});\n```\n","funding_links":["https://github.com/sponsors/bloodyowl"],"categories":["ReScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloodyowl%2Frescript-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbloodyowl%2Frescript-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloodyowl%2Frescript-express/lists"}