Skip to content

README

Hono

Installation

npm install --save rescript-types-hono

Summary

This package contains rescript type definitions for hono.

Example

let app = Hono.make()

let expiresIn = () => Math.floor(Date.now() /. 1000.0) +. 60.0 *. 5.0

let secret = "secret"

app->Hono.use("/auth/*", HonoJwt.jwt({secret, cookie: "auth"}))
app->Hono.getAsync("/", async c => {
  let authCookieContents = await HonoJwt.sign({sub: "", role: "", exp: expiresIn()}, secret)
  HonoCookie.setCookie2(
    c,
    "auth",
    authCookieContents,
    {
      path: "/",
      secure: false,
      domain: "localhost",
      httpOnly: true,
      expires: Date.fromTime(expiresIn() *. 1000.0),
      sameSite: "Strict",
    },
  )
  c.text("hi")
})

app->Hono.get("/auth/", c => {
  c.text("hi user")
})
import { serve } from '@hono/node-server'
//@ts-ignore
import {app } from "./App.res.js"

serve({
  fetch: app.fetch,
  port: 8787
}, (info) => {
  console.log(`Server is running on http://localhost:${info.port}`)
})

Details

Files were exported from https://codeberg.org/lil5/rescript-reasonably-typed/src/branch/main/types/hono.