0.0.1-beta.5 • Published 2 years ago
@futurert/rescript-koa v0.0.1-beta.5
Rescript-Koa
example
install
npm install @futurert/rescript-koa --save-dev
bsconfig
You should add "@futurert/rescript-koa" in bs-dependencies, just like this:
{
"name": "rescript-project-template",
"version": "0.0.1",
"sources": {
"dir" : "src",
"subdirs" : true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"bs-dependencies": [
"@futurert/rescript-koa",
],
"warnings": {
"error" : "+101"
}
}
Get First Koa App
Koa is great for its middleware design, we just can use sync function as app->use()
function params, just like here:
open KoaJs.Koa
// init koa app
let app = koa(koaOptions())
// Just for instance.
// app.env = "development"
// you can use middleware like this
app->App.use(async (context, next) => {
Js.log("1")
context.body = "hello"
await next();
Js.log("2")
})
app->App.use(async (_, next) => {
Js.log("3")
await next()
Js.log("4")
})
app->App.env("哈哈哈")
app->App.listen(~port = 3000, ~host= "127.0.0.1", ~callback= _ => Js.log("哈哈哈"))
// Js.log(app->App.env)
// app.listen()
app->App.on("error", (err, ctx) => Js.log(err))
There is a full example to help you start, Let's try it!
0.0.1-beta.5
2 years ago
0.0.1-beta.3
3 years ago
0.0.1-beta.2
3 years ago
0.0.1-beta.4
2 years ago
0.0.1-beta.1
3 years ago
0.0.1-alpha.20
3 years ago
0.0.1-alpha.19
3 years ago
0.0.1-alpha.18
3 years ago
0.0.1-alpha.17
3 years ago
0.0.1-alpha.16
3 years ago
0.0.1-alpha.15
3 years ago
0.0.1-alpha.14
3 years ago
0.0.1-alpha.13
3 years ago
0.0.1-alpha.12
3 years ago
0.0.1-alpha.11
3 years ago
0.0.1-alpha.10
3 years ago
0.0.1-alpha.9
3 years ago
0.0.1-alpha.8
3 years ago
0.0.1-alpha.7
3 years ago
0.0.1-alpha.6
3 years ago
0.0.1-alpha.5
3 years ago
0.0.1-alpha.4
3 years ago
0.0.1-alpha.3
3 years ago
0.0.1-alpha.2
3 years ago
0.0.1-alpha.1
3 years ago