Skip to content

Instantly share code, notes, and snippets.

View yusukebe's full-sized avatar
😃
Let's go!

Yusuke Wada yusukebe

😃
Let's go!
View GitHub Profile
import { Hono } from 'hono'
import type { H, MiddlewareHandler } from 'hono/types'
const METHODS = ['GET', 'POST', 'PUT', 'DELETE'] as const
type RouteFile = {
default?: Hono | Function
} & { [M in (typeof METHODS)[number]]?: H[] }
type RendererFile = {
import { Plugin, ViteDevServer } from 'vite'
import { Miniflare } from 'miniflare'
import fs from 'fs/promises'
import { resolve, relative } from 'path'
type Options = {
r2Buckets: string[] | Record<string, string>
}
const nullScript = 'export default { fetch: () => new Response(null, { status: 404 }) };'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Hello</title>
<script src="https://cdn.tailwindcss.com"></script>
<script type="importmap">
{
"imports": {
@yusukebe
yusukebe / .gitignore
Last active November 27, 2023 15:52
node-benchmarks
node_modules
yarn.lock
yarn-error.log
*.tgz
import { Hono } from 'hono'
import { jsxRenderer } from 'hono/jsx-renderer'
import { Suspense } from 'hono/jsx/streaming'
const app = new Hono()
const Component = async () => {
const res = await fetch('https://ramen-api.dev/shops/yoshimuraya')
const data = await res.json<{ shop: { name: string } }>()
return <div>{data.shop.name} 🍜</div>
type Callback = () => void | Promise<void>
type Middleware = (
c: C,
next: (callback?: Callback) => void
) => void | Promise<void> | string | Promise<string>
type C = {}
type Next = (callback?: Callback) => void | Promise<void>
const compose = (middleware: Middleware[]) => {
const callbacks: Callback[] = []
import { Hono } from 'npm:hono@3.10.0-rc.2'
const app = new Hono()
app.get('/', (c) => {
return c.text('Hi')
})
Deno.serve(
{
import { Hono } from 'hono'
import { Suspense, renderToReadableStream } from 'hono/jsx/streaming'
import { Todo } from './types'
const app = new Hono()
const fetchData = async () => {
const res = await fetch(`https://jsonplaceholder.typicode.com/todos/1`)
return res.json<Todo>()
}
import { Hono } from 'hono'
import { use, Suspense, renderToReadableStream } from 'hono/jsx/streaming'
import type { Shop } from './types'
const app = new Hono()
const fetchData = async (): Promise<{ shop: Shop }> => {
const res = await fetch('https://ramen-api.dev/shops/yoshimuraya')
return res.json()
}
import { readFile } from 'node:fs/promises'
import initSwc, { transformSync } from '@swc/wasm-web/wasm-web'
import type { MiddlewareHandler } from 'hono'
import wasm from './wasm-web_bg.wasm'
// Cache that maps from code itself to transpiled code (since this is to be
// used in development only, no need to cap the cache size)
const cache = new Map<string, string>()
// See https://swc.rs/docs/usage/core