Hi! I’m working on (nearly) zero-cost bindings for express (some APIs require a tiny layer as they return whether a bool or a string ).
I’ve added the main APIs. If you use express and want to provide some feedback about things that look weird or missing APIs, don’t hesitate.
Looks like the following:
open Express
let app = express()
app->use(jsonMiddleware())
app->get("/", (_req, res) => {
open Res
let _ = res->status(200)->json({"ok": true})
})
app->post("/ping", (req, res) => {
open Req
let name = (req->body)["name"]
open Res
let _ = res->status(200)->json({"message": `Hello ${name}`})
})
let _ = app->listen(8081)
Kinda related: did you have a look at fastifyjs yet? it seems to be a better supported, more stable http server framework than express. It’s also maintained by one of Node’s core maintainers
I’d probably not use express for any new projects anymore
Also have a look at bs-express. The master branch has been ported to Rescript syntax. If it’s similar enough to what you’re planning, the project is actively looking for a maintainer if you are interested.
uff, we need to get rid / migrate all the old libraries that start with ˋbs-ˋ… so many old artifacts that are not idiomatic to ReScript anymore and need a total rewrite. The new convention is ˋrescript-[mylib]ˋ, like @bloodyowl did.
Very hard to tell which libraries are actually being actively maintained, and which ones are just old artifacts of our previous ecosystem.
I thought about that, but the API I wanted is so far away from the original one that it’d make all the bs-express users unhappy with the changes if they upgrade to a new one that has nothing to do with the original.