Install
| Product | Versions |
|---|---|
| .NET Standard |
README
Glutinum.Express
Fable bindings for express, generated by Glutinum
Generated by Glutinum from @types/express.
The bindings live in the Glutinum.Express module. Express.Exports.express () creates the application, Exports.json, Exports.urlencoded and Exports.Router are the values of the express namespace, and its types are Express.Request, Express.Response and Express.RequestHandler.
open Glutinum
open Glutinum.Express
let app = Exports.express ()
// The JSON body parser, a middleware of connect
app.``use`` (ExpressAdapter.Middleware(Exports.json None)) |> ignore
// A handler takes the request and the response, `ExpressAdapter.RequestHandler` also accepts `next`
app.get ("/users/:id", ExpressAdapter.RequestHandler(fun request response ->
let id = unbox<string> request.``params``.["id"]
response.json {| id = id; name = "Ada" |} |> ignore))
|> ignore
app.post ("/users", ExpressAdapter.RequestHandler(fun request response ->
response.status(201).json {| name = request.body?name |} |> ignore))
|> ignore
app.listen 3000 |> ignore
ExpressAdapter is hand-written in Glutinum.Express.Extensions.fs, shipped with the package. The route methods (get, post, all, use...) return the application, so a call ends with |> ignore. The tests/App.fs file of this folder is a complete example.
Install the npm package next to the NuGet package, or run femto to do it.
The file Glutinum.Express.fs is generated by ./build.sh generate Express in the hub, do not edit it.
Changes from Previous Version
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.