moon add mizchi/js
moon add mizchi/npm_typed
npm install honoimport {
"mizchi/js",
"mizchi/js_core" @core,
"mizchi/js_web/http",
"mizchi/npm_typed/hono",
}async fn main {
let app : @hono.Hono[Unit, Unit] = @hono.Hono::new()
app.get("/", fn(c) { c.text("Hello, Hono!") }) |> ignore
// serve with @hono/node-server or deploy to Cloudflare Workers
}async fn create_app() -> @hono.Hono[Unit, Unit] {
let hono_jsx = @hono.import_hono_jsx()
let hono_css = @hono.import_hono_css()
let app = @hono.Hono::new()
app.get("/", fn(c) {
let content = hono_jsx.jsx("div", [
hono_jsx.jsx("h1", ["Hello, World!"]),
])
c.html_jsx(content)
})
}async fn create_app() -> @hono.Hono[Unit, Unit] {
// Required for ESM: initialize Fragment before using fragment()
@hono.init_jsx_runtime()
let app = @hono.Hono::new()
app.get("/", fn(c) {
let content = @hono.jsx("div", [
@hono.jsx("h1", ["Hello, World!"]),
])
c.html_jsx(content)
})
}let hono_jsx = @hono.import_hono_jsx()
hono_jsx.fragment([child1, child2]) // No manual init neededimpl CssClassName for Stringpub type ClientEndpointasync fn ClientEndpoint::delete_(self : ClientEndpoint, query? : Any, form? : Any, json? : Any, param? : Any, header? : Any, init? : Any) -> ClientResponseasync fn ClientEndpoint::get_(self : ClientEndpoint, query? : Any, form? : Any, json? : Any, param? : Any, header? : Any, init? : Any) -> ClientResponseasync fn ClientEndpoint::patch_(self : ClientEndpoint, query? : Any, form? : Any, json? : Any, param? : Any, header? : Any, init? : Any) -> ClientResponseasync fn ClientEndpoint::post_(self : ClientEndpoint, query? : Any, form? : Any, json? : Any, param? : Any, header? : Any, init? : Any) -> ClientResponseasync fn ClientEndpoint::put_(self : ClientEndpoint, query? : Any, form? : Any, json? : Any, param? : Any, header? : Any, init? : Any) -> ClientResponsefn ClientEndpoint::url_(self : ClientEndpoint, query? : Any, form? : Any, json? : Any, param? : Any, header? : Any, init? : Any) -> Stringpub type ClientResponsepub(all) struct Context[Env, ExecutionContext] {
req : HonoRequest
env : Env
executionCtx : ExecutionContext
}#external
pub type CorsMiddleware#external
pub type CssClassimpl CssClassName for CssClass#external
pub type Hono[Env, ExecutionContext]let app = Hono::new()
let app_strict = Hono::new(strict=false)pub type HonoClient#external
pub type HonoContext[T]#external
pub type HonoCss// Simple usage without interpolation
let cls = hono_css.css("color: red")
// With interpolation
let color = "blue"
let size = 16
let cls = hono_css.css("color: ${@0}; font-size: ${@1}px", args=[
@core.any(color),
@core.any(size),
])// Simple usage
let anim = hono_css.keyframes("from { opacity: 0 } to { opacity: 1 }")
// With interpolation
let start = 0.5
let end = 1.0
let anim = hono_css.keyframes(
"from { transform: scale(${@0}) } to { transform: scale(${@1}) }",
args=[@core.any(start), @core.any(end)],
)#external
pub type HonoJsxpub(all) struct HonoRequest {
url : String
bodyUsed : Bool
}#external
pub type HtmlEscapedStringimpl HonoNode for HtmlEscapedString#external
pub type JSXNodepub(all) enum JwtAlgorithm {
HS256
HS384
HS512
RS256
RS384
RS512
PS256
PS384
PS512
ES256
ES384
ES512
EdDSA
}pub(all) struct JwtPayload {
sub : String?
iss : String?
aud : String?
exp : Int?
nbf : Int?
iat : Int?
jti : String?
}fn cors(origin? : String, allowMethods? : Array[String], allowHeaders? : Array[String], maxAge? : Int, credentials? : Bool, exposeHeaders? : Array[String]) -> CorsMiddlewarefn[Env, ExecutionContext] delete_cookie(c : Context[Env, ExecutionContext], name : String, path? : String, secure? : Bool, domain? : String) -> String?fn[Env, ExecutionContext] get_cookie(c : Context[Env, ExecutionContext], name : String, prefix? : String) -> String?async fn[Env, ExecutionContext] get_signed_cookie(c : Context[Env, ExecutionContext], secret : String, name : String) -> String?async fn init_jsx_runtime() -> Unitasync fn[Env, ExecutionContext] set_signed_cookie(c : Context[Env, ExecutionContext], name : String, value : String, secret : String, domain? : String, expires? : Any, httpOnly? : Bool, maxAge? : Int, path? : String, secure? : Bool, sameSite? : String, priority? : String, prefix? : String, partitioned? : Bool) -> Unit