- Many stars, users, donwloads https://github.com/honojs/hono
- Many middleware https://hono.dev/ https://github.com/honojs/middleware
This file contains hidden or 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 { upgradeWebSocket, websocket } from 'hono/bun' | |
| import { MyApiServer } from './my-api-server' | |
| import { newHonoRpcResponse } from './capnweb-server-hono.ts' | |
| const app = new Hono() | |
| app.all('/api', (c) => { | |
| return newHonoRpcResponse(c, new MyApiServer(), { | |
| upgradeWebSocket |
This file contains hidden or 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 { serve } from '@hono/node-server' | |
| import { Hono } from 'hono' | |
| const app = new Hono() | |
| app.get('/reproduce-flush', async (c) => { | |
| let transformController | |
| let bufferedChunks = ['chunk1', 'chunk2'] | |
| const stream = new ReadableStream({ |
This file contains hidden or 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, normalizePath } from 'vite' | |
| import path from 'node:path' | |
| import picomatch from 'picomatch' | |
| import type { ServerResponse } from 'node:http' | |
| type ShouldInjectFunction = (req: ServerResponse['req'], res: ServerResponse) => boolean | |
| type Options = { | |
| /** | |
| * default ['src\/\*\*\/\*.ts', 'src\/\*\*\/\*.tsx'] |
This file contains hidden or 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 { encodeBase64Url } from '../../utils/encode' | |
| import { utf8Encoder } from '../../utils/jwt/utf8' | |
| import { signing } from './jws' | |
| import { verifyFromJwks } from './jwt' | |
| describe('verifyFromJwks header.alg fallback', () => { | |
| it('Should use header.alg as fallback when matchingKey.alg is missing', async () => { | |
| // Setup: Create a JWT signed with HS384 (different from default HS256) | |
| const payload = { message: 'hello world' } | |
| const headerAlg = 'HS384' // Non-default value |
This file contains hidden or 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
| app.use( | |
| '/', | |
| reactRenderer(({ children }) => { | |
| return ( | |
| <html lang="en"> | |
| <head> | |
| <meta charSet="UTF-8" /> | |
| <link rel="icon" type="image/svg+xml" href="/vite.svg" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Vite + React TS</title> |
This file contains hidden or 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 { ServerResponse } from 'node:http' | |
| function ssrHotReload(): Plugin { | |
| return { | |
| name: 'vite-plugin-ssr-hot-reload', | |
| apply: 'serve', | |
| configureServer(server) { | |
| const injectScript = `<script type="module" src="/@vite/client"></script>` | |
| server.middlewares.use((req, res, next) => { |
This file contains hidden or 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 { createRoute } from 'honox/factory' | |
| import { Suspense } from 'hono/jsx' | |
| import { getContext } from 'hono/context-storage' | |
| export const getData = async (userId: string | undefined) => { | |
| await new Promise((resolve) => setTimeout(resolve, 1000)) | |
| if (!userId) { | |
| return undefined | |
| } | |
| const userData = getContext().var.db.getUser(userId) |
This file contains hidden or 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 { streamText } from 'hono/streaming' | |
| type Env = { | |
| Bindings: { | |
| AI: Ai | |
| } | |
| } | |
| const app = new Hono<Env>() |
This file contains hidden or 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 { streamText } from 'hono/streaming' | |
| type Env = { | |
| Bindings: { | |
| AI: Ai | |
| } | |
| } | |
| const app = new Hono<Env>() |
NewerOlder