This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }) };' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
yarn.lock | |
yarn-error.log | |
*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Hono } from 'npm:hono@3.10.0-rc.2' | |
const app = new Hono() | |
app.get('/', (c) => { | |
return c.text('Hi') | |
}) | |
Deno.serve( | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |