mirror of
https://github.com/honojs/hono.git
synced 2024-11-23 17:57:29 +01:00
parent
e0d17a3955
commit
5f78e4e1b3
@ -1 +0,0 @@
|
||||
.eslintrc.cjs
|
@ -1,9 +0,0 @@
|
||||
module.exports = {
|
||||
extends: ['@hono/eslint-config'],
|
||||
rules: {
|
||||
'@typescript-eslint/unbound-method': 'error',
|
||||
},
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.json', './runtime_tests/tsconfig.json'],
|
||||
},
|
||||
}
|
3
eslint.config.mjs
Normal file
3
eslint.config.mjs
Normal file
@ -0,0 +1,3 @@
|
||||
import baseConfig from '@hono/eslint-config'
|
||||
|
||||
export default [...baseConfig]
|
12
package.json
12
package.json
@ -20,8 +20,8 @@
|
||||
"test:lambda": "vitest --run --config ./runtime_tests/lambda/vitest.config.ts",
|
||||
"test:lambda-edge": "vitest --run --config ./runtime_tests/lambda-edge/vitest.config.ts",
|
||||
"test:all": "bun run test && bun test:deno && bun test:bun && bun test:fastly && bun test:node && bun test:workerd && bun test:lambda && bun test:lambda-edge",
|
||||
"lint": "eslint --ext js,ts,tsx src runtime_tests",
|
||||
"lint:fix": "eslint --ext js,ts,tsx src runtime_tests --fix",
|
||||
"lint": "eslint src runtime_tests",
|
||||
"lint:fix": "eslint src runtime_tests --fix",
|
||||
"format": "prettier --check --cache \"src/**/*.{js,ts,tsx}\" \"runtime_tests/**/*.{js,ts,tsx}\"",
|
||||
"format:fix": "prettier --write --cache --cache-strategy metadata \"src/**/*.{js,ts,tsx}\" \"runtime_tests/**/*.{js,ts,tsx}\"",
|
||||
"copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json ",
|
||||
@ -618,7 +618,7 @@
|
||||
"nodejs"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@hono/eslint-config": "^0.0.6",
|
||||
"@hono/eslint-config": "^1.0.1",
|
||||
"@hono/node-server": "^1.8.2",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"@types/glob": "^8.0.0",
|
||||
@ -629,7 +629,7 @@
|
||||
"arg": "^5.0.2",
|
||||
"crypto-js": "^4.1.1",
|
||||
"esbuild": "^0.15.12",
|
||||
"eslint": "^8.55.0",
|
||||
"eslint": "^9.10.0",
|
||||
"glob": "7.2.3",
|
||||
"jsdom": "^22.1.0",
|
||||
"msw": "^2.3.0",
|
||||
@ -645,6 +645,6 @@
|
||||
"zod": "^3.20.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
"node": ">=16.9.0"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { stream, streamSSE } from '../..//src/helper/streaming'
|
||||
import { serveStatic, toSSG } from '../../src/adapter/bun'
|
||||
import { createBunWebSocket } from '../../src/adapter/bun/websocket'
|
||||
import type { BunWebSocketData } from '../../src/adapter/bun/websocket'
|
||||
@ -11,7 +12,6 @@ import { jsx } from '../../src/jsx'
|
||||
import { basicAuth } from '../../src/middleware/basic-auth'
|
||||
import { jwt } from '../../src/middleware/jwt'
|
||||
import { HonoRequest } from '../../src/request'
|
||||
import { stream, streamSSE } from '../..//src/helper/streaming'
|
||||
|
||||
// Test just only minimal patterns.
|
||||
// Because others are tested well in Cloudflare Workers environment already.
|
||||
|
@ -1,9 +1,9 @@
|
||||
/** @jsxImportSource ../../src/jsx */
|
||||
import { assertEquals } from '@std/assert'
|
||||
import { Style, css } from '../../src/helper/css/index.ts'
|
||||
import { Suspense, renderToReadableStream } from '../../src/jsx/streaming.ts'
|
||||
import type { HtmlEscapedString } from '../../src/utils/html.ts'
|
||||
import { HtmlEscapedCallbackPhase, resolveCallback } from '../../src/utils/html.ts'
|
||||
import { assertEquals } from '@std/assert'
|
||||
|
||||
Deno.test('JSX', () => {
|
||||
const Component = ({ name }: { name: string }) => <span>{name}</span>
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { assertEquals } from '@std/assert'
|
||||
import { Context } from '../../src/context.ts'
|
||||
import { env, getRuntimeKey } from '../../src/helper/adapter/index.ts'
|
||||
import { Hono } from '../../src/hono.ts'
|
||||
import { assertEquals } from '@std/assert'
|
||||
|
||||
// Test just only minimal patterns.
|
||||
// Because others are tested well in Cloudflare Workers environment already.
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { assertEquals, assertMatch } from '@std/assert'
|
||||
import { assertSpyCall, assertSpyCalls, spy } from '@std/testing/mock'
|
||||
import { serveStatic } from '../../src/adapter/deno/index.ts'
|
||||
import { Hono } from '../../src/hono.ts'
|
||||
import { basicAuth } from '../../src/middleware/basic-auth/index.ts'
|
||||
import { jwt } from '../../src/middleware/jwt/index.ts'
|
||||
import { assertSpyCall, assertSpyCalls, spy } from '@std/testing/mock'
|
||||
import { assertEquals, assertMatch } from '@std/assert'
|
||||
|
||||
// Test just only minimal patterns.
|
||||
// Because others are already tested well in Cloudflare Workers environment.
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { assertEquals } from '@std/assert'
|
||||
import { toSSG } from '../../src/adapter/deno/ssg.ts'
|
||||
import { Hono } from '../../src/hono.ts'
|
||||
import { assertEquals } from '@std/assert'
|
||||
|
||||
Deno.test('toSSG function', async () => {
|
||||
const app = new Hono()
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Hono } from '../../src/hono.ts'
|
||||
import { stream, streamSSE } from '../../src/helper/streaming/index.ts'
|
||||
import { assertEquals } from '@std/assert'
|
||||
import { stream, streamSSE } from '../../src/helper/streaming/index.ts'
|
||||
import { Hono } from '../../src/hono.ts'
|
||||
|
||||
Deno.test('Shuld call onAbort via stream', async () => {
|
||||
const app = new Hono()
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Writable } from 'node:stream'
|
||||
import { vi } from 'vitest'
|
||||
import { Writable } from 'node:stream'
|
||||
import type {
|
||||
APIGatewayProxyEvent,
|
||||
APIGatewayProxyEventV2,
|
||||
|
@ -1,14 +1,14 @@
|
||||
import type { Server } from 'node:http'
|
||||
import { createAdaptorServer, serve } from '@hono/node-server'
|
||||
import request from 'supertest'
|
||||
import type { Server } from 'node:http'
|
||||
import type { AddressInfo } from 'node:net'
|
||||
import { Hono } from '../../src'
|
||||
import { Context } from '../../src/context'
|
||||
import { env, getRuntimeKey } from '../../src/helper/adapter'
|
||||
import { basicAuth } from '../../src/middleware/basic-auth'
|
||||
import { jwt } from '../../src/middleware/jwt'
|
||||
import { compress } from '../../src/middleware/compress'
|
||||
import { stream, streamSSE } from '../../src/helper/streaming'
|
||||
import type { AddressInfo } from 'node:net'
|
||||
import { basicAuth } from '../../src/middleware/basic-auth'
|
||||
import { compress } from '../../src/middleware/compress'
|
||||
import { jwt } from '../../src/middleware/jwt'
|
||||
|
||||
// Test only minimal patterns.
|
||||
// See <https://github.com/honojs/node-server> for more tests and information.
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { env, getRuntimeKey } from '../../src/helper/adapter'
|
||||
import { upgradeWebSocket } from '../../src/adapter/cloudflare-workers'
|
||||
import { env, getRuntimeKey } from '../../src/helper/adapter'
|
||||
import { Hono } from '../../src/hono'
|
||||
|
||||
const app = new Hono()
|
||||
|
@ -7,7 +7,7 @@ export interface CognitoIdentity {
|
||||
|
||||
export interface ClientContext {
|
||||
client: ClientContextClient
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
||||
Custom?: any
|
||||
env: ClientContextEnv
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Context } from '../../context'
|
||||
import { getConnInfo } from './conninfo'
|
||||
import type { AddressType } from '../../helper/conninfo'
|
||||
import { getConnInfo } from './conninfo'
|
||||
|
||||
const createRandomBunServer = ({
|
||||
address = Math.random().toString(),
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
import { stat } from 'node:fs/promises'
|
||||
import { serveStatic as baseServeStatic } from '../../middleware/serve-static'
|
||||
import type { ServeStaticOptions } from '../../middleware/serve-static'
|
||||
import type { Env, MiddlewareHandler } from '../../types'
|
||||
import { stat } from 'node:fs/promises'
|
||||
|
||||
export const serveStatic = <E extends Env = Env>(
|
||||
options: ServeStaticOptions<E>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Context } from '../../context'
|
||||
import type { CloudFrontEdgeEvent } from './handler'
|
||||
import { getConnInfo } from './conninfo'
|
||||
import type { CloudFrontEdgeEvent } from './handler'
|
||||
|
||||
describe('getConnInfo', () => {
|
||||
it('Should info is valid', () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { Context } from '../../context'
|
||||
import type { GetConnInfo } from '../../helper/conninfo'
|
||||
import type { CloudFrontEdgeEvent } from './handler'
|
||||
import type { Context } from '../../context'
|
||||
|
||||
type Env = {
|
||||
Bindings: {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
import { HttpResponse, http } from 'msw'
|
||||
import { setupServer } from 'msw/node'
|
||||
|
@ -553,7 +553,7 @@ describe('Compose', function () {
|
||||
arr.push(6)
|
||||
await next()
|
||||
arr.push(7)
|
||||
} catch (err) {
|
||||
} catch {
|
||||
arr.push(2)
|
||||
}
|
||||
arr.push(3)
|
||||
|
@ -11,6 +11,7 @@ import type {
|
||||
} from './types'
|
||||
import { HtmlEscapedCallbackPhase, resolveCallback } from './utils/html'
|
||||
import type { RedirectStatusCode, StatusCode } from './utils/http-status'
|
||||
import type { BaseMime } from './utils/mime'
|
||||
import type {
|
||||
InvalidJSONValue,
|
||||
IsAny,
|
||||
@ -18,7 +19,6 @@ import type {
|
||||
JSONValue,
|
||||
SimplifyDeepArray,
|
||||
} from './utils/types'
|
||||
import type { BaseMime } from './utils/mime'
|
||||
|
||||
type HeaderRecord =
|
||||
| Record<'Content-Type', BaseMime>
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint-disable quotes */
|
||||
/** @jsxImportSource ../../jsx */
|
||||
import { Hono } from '../../'
|
||||
import { html } from '../../helper/html'
|
||||
|
@ -130,7 +130,7 @@ export const createCssContext = ({ id }: { id: Readonly<string> }): DefaultConte
|
||||
;(className as HtmlEscapedString).callbacks = [addClassNameToContext]
|
||||
const promise = Promise.resolve(className)
|
||||
Object.assign(promise, cssClassName)
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
|
||||
promise.toString = cssJsxDomObject.toString
|
||||
return promise
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ export const SSG_DISABLED_RESPONSE = (() => {
|
||||
status: 404,
|
||||
headers: { [X_HONO_DISABLE_SSG_HEADER_KEY]: 'true' },
|
||||
})
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
})() as Response
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/** @jsxImportSource ../../jsx */
|
||||
import { Hono } from '../../hono'
|
||||
import { poweredBy } from '../../middleware/powered-by'
|
||||
|
@ -1,6 +1,6 @@
|
||||
/** @jsxImportSource ../../jsx */
|
||||
import { ErrorBoundary } from '../../jsx'
|
||||
import { Context } from '../../context'
|
||||
import { ErrorBoundary } from '../../jsx'
|
||||
import { streamSSE } from '.'
|
||||
|
||||
describe('SSE Streaming helper', () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { Context } from '../../context'
|
||||
import { StreamingApi } from '../../utils/stream'
|
||||
import { HtmlEscapedCallbackPhase, resolveCallback } from '../../utils/html'
|
||||
import { StreamingApi } from '../../utils/stream'
|
||||
|
||||
export interface SSEMessage {
|
||||
data: string | Promise<string>
|
||||
|
@ -1599,7 +1599,7 @@ describe('Request methods with custom middleware', () => {
|
||||
|
||||
app.use('*', async (c, next) => {
|
||||
const query = c.req.query('foo')
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
// @ts-ignore
|
||||
const param = c.req.param('foo') // This will cause a type error.
|
||||
const header = c.req.header('User-Agent')
|
||||
@ -2210,7 +2210,7 @@ describe('Lack returning response with a single handler', () => {
|
||||
describe('Context is not finalized', () => {
|
||||
it('should throw error - lack `await next()`', async () => {
|
||||
const app = new Hono()
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
// @ts-ignore
|
||||
app.use('*', () => {})
|
||||
app.get('/foo', (c) => {
|
||||
@ -2229,7 +2229,7 @@ describe('Context is not finalized', () => {
|
||||
app.use('*', async (_c, next) => {
|
||||
await next()
|
||||
})
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
// @ts-ignore
|
||||
app.get('/foo', () => {})
|
||||
app.onError((err, c) => {
|
||||
@ -2672,10 +2672,10 @@ describe('app.mount()', () => {
|
||||
},
|
||||
{
|
||||
// Force mocking!
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
// @ts-ignore
|
||||
waitUntil: 'waitUntil',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
// @ts-ignore
|
||||
passThroughOnException: 'passThroughOnException',
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { raw } from '../helper/html'
|
||||
import { escapeToBuffer, resolveCallbackSync, stringBufferToString } from '../utils/html'
|
||||
import type { HtmlEscaped, HtmlEscapedString, StringBufferWithCallbacks } from '../utils/html'
|
||||
import { DOM_RENDERER } from './constants'
|
||||
import type { Context } from './context'
|
||||
import { createContext, globalContexts, useContext } from './context'
|
||||
import { DOM_RENDERER } from './constants'
|
||||
import { domRenderers } from './intrinsic-element/common'
|
||||
import * as intrinsicElementTags from './intrinsic-element/components'
|
||||
import type {
|
||||
JSX as HonoJSX,
|
||||
IntrinsicElements as IntrinsicElementsDefined,
|
||||
} from './intrinsic-elements'
|
||||
import { normalizeIntrinsicElementKey, styleObjectForEach } from './utils'
|
||||
import * as intrinsicElementTags from './intrinsic-element/components'
|
||||
import { domRenderers } from './intrinsic-element/common'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type Props = Record<string, any>
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { JSDOM } from 'jsdom'
|
||||
// run tests by old style jsx default
|
||||
// hono/jsx/jsx-runtime and hono/jsx/dom/jsx-runtime are tested in their respective settings
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
||||
import type { JSXNode } from '..'
|
||||
import { Style, createCssContext, css, rawCssString } from '../../helper/css'
|
||||
import { minify } from '../../helper/css/common'
|
||||
|
@ -120,7 +120,6 @@ export const createCssJsxDomObjects: CreateCssJsxDomObjectsType = ({ id }) => {
|
||||
},
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const Style: FC<PropsWithChildren<void>> = ({ children }) =>
|
||||
({
|
||||
tag: 'style',
|
||||
@ -173,7 +172,6 @@ export const createCssContext = ({ id }: { id: Readonly<string> }): DefaultConte
|
||||
const [cssObject, Style] = createCssJsxDomObjects({ id })
|
||||
|
||||
const newCssClassNameObject = (cssClassName: CssClassName): string => {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
cssClassName.toString = cssObject.toString
|
||||
return cssClassName as unknown as string
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
* Provide hooks used only in jsx/dom
|
||||
*/
|
||||
|
||||
import { PERMALINK } from '../../constants'
|
||||
import type { Context } from '../../context'
|
||||
import { useContext } from '../../context'
|
||||
import { createContext } from '../context'
|
||||
import { useCallback, useState } from '../../hooks'
|
||||
import { PERMALINK } from '../../constants'
|
||||
import { createContext } from '../context'
|
||||
|
||||
type FormStatus =
|
||||
| {
|
||||
|
@ -29,9 +29,9 @@ import {
|
||||
useTransition,
|
||||
useViewTransition,
|
||||
} from '../hooks'
|
||||
import { useActionState, useFormStatus, useOptimistic } from './hooks'
|
||||
import { ErrorBoundary, Suspense } from './components'
|
||||
import { createContext } from './context'
|
||||
import { useActionState, useFormStatus, useOptimistic } from './hooks'
|
||||
import { Fragment, jsx } from './jsx-runtime'
|
||||
import { createPortal, flushSync } from './render'
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @jsxImportSource ../../ */
|
||||
import { JSDOM, ResourceLoader } from 'jsdom'
|
||||
import { useState } from '../../hooks'
|
||||
import { Suspense, render } from '..'
|
||||
import { useState } from '../../hooks'
|
||||
import { clearCache, composeRef } from './components'
|
||||
|
||||
describe('intrinsic element', () => {
|
||||
@ -10,7 +10,6 @@ describe('intrinsic element', () => {
|
||||
global.requestAnimationFrame = (cb) => setTimeout(cb)
|
||||
|
||||
CustomResourceLoader = class CustomResourceLoader extends ResourceLoader {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
fetch(url: string) {
|
||||
return url.includes('invalid')
|
||||
? Promise.reject('Invalid URL')
|
||||
|
@ -1,12 +1,12 @@
|
||||
import type { Props } from '../../base'
|
||||
import type { FC, JSXNode, PropsWithChildren, RefObject } from '../../types'
|
||||
import { createPortal, getNameSpaceContext } from '../render'
|
||||
import type { PreserveNodeType } from '../render'
|
||||
import { useContext } from '../../context'
|
||||
import { use, useCallback, useMemo, useState } from '../../hooks'
|
||||
import { FormContext, registerAction } from '../hooks'
|
||||
import { dataPrecedenceAttr, deDupeKeyMap, domRenderers } from '../../intrinsic-element/common'
|
||||
import type { IntrinsicElements } from '../../intrinsic-elements'
|
||||
import type { FC, JSXNode, PropsWithChildren, RefObject } from '../../types'
|
||||
import { FormContext, registerAction } from '../hooks'
|
||||
import type { PreserveNodeType } from '../render'
|
||||
import { createPortal, getNameSpaceContext } from '../render'
|
||||
|
||||
// this function is a testing utility and should not be exported to the user
|
||||
export const clearCache = () => {
|
||||
|
@ -663,7 +663,7 @@ const updateSync = (context: Context, node: NodeObject): void => {
|
||||
})
|
||||
try {
|
||||
build(context, node, undefined)
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
if (node.a) {
|
||||
|
@ -3,10 +3,10 @@
|
||||
* This module provides APIs for `hono/jsx/server`, which is compatible with `react-dom/server`.
|
||||
*/
|
||||
|
||||
import type { HtmlEscapedString } from '../../utils/html'
|
||||
import type { Child } from '../base'
|
||||
import { renderToReadableStream as renderToReadableStreamHono } from '../streaming'
|
||||
import version from './'
|
||||
import type { HtmlEscapedString } from '../../utils/html'
|
||||
|
||||
export interface RenderToStringOptions {
|
||||
identifierPrefix?: string
|
||||
|
@ -1059,7 +1059,6 @@ describe('default export', () => {
|
||||
'StrictMode',
|
||||
].forEach((key) => {
|
||||
it(key, () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect((DefaultExport as any)[key]).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
@ -8,6 +8,7 @@ import type { DOMAttributes } from './base'
|
||||
import { Children } from './children'
|
||||
import { ErrorBoundary } from './components'
|
||||
import { createContext, useContext } from './context'
|
||||
import { useActionState, useOptimistic } from './dom/hooks'
|
||||
import {
|
||||
createRef,
|
||||
forwardRef,
|
||||
@ -30,7 +31,6 @@ import {
|
||||
useTransition,
|
||||
useViewTransition,
|
||||
} from './hooks'
|
||||
import { useActionState, useOptimistic } from './dom/hooks'
|
||||
import { Suspense } from './streaming'
|
||||
|
||||
export {
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { raw } from '../../helper/html'
|
||||
import type { HtmlEscapedCallback, HtmlEscapedString } from '../../utils/html'
|
||||
import { JSXNode, getNameSpaceContext } from '../base'
|
||||
import { useContext } from '../context'
|
||||
import type { Child, Props } from '../base'
|
||||
import type { FC, PropsWithChildren } from '../types'
|
||||
import { raw } from '../../helper/html'
|
||||
import { dataPrecedenceAttr, deDupeKeyMap } from './common'
|
||||
import { PERMALINK } from '../constants'
|
||||
import { toArray } from '../children'
|
||||
import { PERMALINK } from '../constants'
|
||||
import { useContext } from '../context'
|
||||
import type { IntrinsicElements } from '../intrinsic-elements'
|
||||
import type { FC, PropsWithChildren } from '../types'
|
||||
import { dataPrecedenceAttr, deDupeKeyMap } from './common'
|
||||
|
||||
const metaTagMap: WeakMap<
|
||||
object,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Hono } from '../../hono'
|
||||
import { every, except, some } from '.'
|
||||
import type { MiddlewareHandler } from '../../types'
|
||||
import { every, except, some } from '.'
|
||||
|
||||
const nextMiddleware: MiddlewareHandler = async (_, next) => await next()
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
* Combine Middleware for Hono.
|
||||
*/
|
||||
|
||||
import type { Context } from '../../context'
|
||||
import type { MiddlewareHandler, Next } from '../../types'
|
||||
import { TrieRouter } from '../../router/trie-router'
|
||||
import { METHOD_NAME_ALL } from '../../router'
|
||||
import { compose } from '../../compose'
|
||||
import type { Context } from '../../context'
|
||||
import { METHOD_NAME_ALL } from '../../router'
|
||||
import { TrieRouter } from '../../router/trie-router'
|
||||
import type { MiddlewareHandler, Next } from '../../types'
|
||||
|
||||
type Condition = (c: Context) => boolean
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { compress } from '.'
|
||||
import { stream } from '../../helper/streaming'
|
||||
import { Hono } from '../../hono'
|
||||
import { compress } from '.'
|
||||
|
||||
describe('Compress Middleware', () => {
|
||||
const app = new Hono()
|
||||
|
@ -3,9 +3,9 @@
|
||||
* Context Storage Middleware for Hono.
|
||||
*/
|
||||
|
||||
import { AsyncLocalStorage } from 'node:async_hooks'
|
||||
import type { Context } from '../../context'
|
||||
import type { Env, MiddlewareHandler } from '../../types'
|
||||
import { AsyncLocalStorage } from 'node:async_hooks'
|
||||
|
||||
const asyncLocalStorage = new AsyncLocalStorage<Context>()
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Hono } from '../../hono'
|
||||
import { Context } from '../../context'
|
||||
import type { AddressType, GetConnInfo } from '../../helper/conninfo'
|
||||
import { Hono } from '../../hono'
|
||||
import { ipRestriction } from '.'
|
||||
import type { IPRestrictionRule } from '.'
|
||||
|
||||
@ -78,7 +78,7 @@ describe('isMatchForRule', () => {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await middleware(undefined as any, () => Promise.resolve())
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -79,7 +79,7 @@ function log(
|
||||
export const logger = (fn: PrintFunc = console.log): MiddlewareHandler => {
|
||||
return async function logger(c, next) {
|
||||
const { method } = c.req
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
||||
const path = getPath(c.req.raw)
|
||||
|
||||
log(fn, LogPrefix.Incoming, method, path)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Hono } from './quick'
|
||||
import { getRouterName } from '../helper/dev'
|
||||
import { Hono } from './quick'
|
||||
|
||||
describe('hono/quick preset', () => {
|
||||
it('Should have SmartRouter + LinearRouter', async () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Hono } from './tiny'
|
||||
import { getRouterName } from '../helper/dev'
|
||||
import { Hono } from './tiny'
|
||||
|
||||
describe('hono/tiny preset', () => {
|
||||
it('Should have PatternRouter', async () => {
|
||||
|
@ -31,7 +31,7 @@ export class PatternRouter<T> implements Router<T> {
|
||||
let re
|
||||
try {
|
||||
re = new RegExp(`^${parts.join('')}${endsWithWildcard ? '' : '/?$'}`)
|
||||
} catch (e) {
|
||||
} catch {
|
||||
throw new UnsupportedPathError()
|
||||
}
|
||||
this.routes.push([re, method, handler])
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
import type { ParamIndexMap, Result, Router } from '../../router'
|
||||
import {
|
||||
MESSAGE_MATCHER_IS_ALREADY_BUILT,
|
||||
@ -247,7 +246,7 @@ export class RegExpRouter<T> implements Router<T> {
|
||||
const routes: [string, HandlerWithMetadata<T>[]][] = []
|
||||
|
||||
let hasOwnRoute = method === METHOD_NAME_ALL
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
|
||||
;[this.middleware!, this.routes!].forEach((r) => {
|
||||
const ownRoute = r[method]
|
||||
? Object.keys(r[method]).map((path) => [path, r[method][path]])
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
import type { Result, Router } from '../../router'
|
||||
import { MESSAGE_MATCHER_IS_ALREADY_BUILT, UnsupportedPathError } from '../../router'
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import { expectTypeOf } from 'vitest'
|
||||
import { Context } from './context'
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import type { Context } from './context'
|
||||
import type { Hono } from './hono'
|
||||
import type { StatusCode } from './utils/http-status'
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { HonoRequest } from '../request'
|
||||
import { auth } from './basic-auth'
|
||||
|
||||
describe('auth', () => {
|
||||
|
@ -60,7 +60,7 @@ const verifySignature = async (
|
||||
signature[i] = signatureBinStr.charCodeAt(i)
|
||||
}
|
||||
return await crypto.subtle.verify(algorithm, secret, signature, new TextEncoder().encode(value))
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
import { decodeBase64Url, encodeBase64Url } from './encode'
|
||||
|
||||
const toURLBase64 = (base64String: string): string =>
|
||||
|
@ -108,7 +108,7 @@ export const decode = (token: string): { header: TokenHeader; payload: JWTPayloa
|
||||
header,
|
||||
payload,
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
throw new JwtTokenInvalid(token)
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ export class StreamingApi {
|
||||
input = this.encoder.encode(input)
|
||||
}
|
||||
await this.writer.write(input)
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Do nothing. If you want to handle errors, create a stream by yourself.
|
||||
}
|
||||
return this
|
||||
@ -67,7 +67,7 @@ export class StreamingApi {
|
||||
async close() {
|
||||
try {
|
||||
await this.writer.close()
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Do nothing. If you want to handle errors, create a stream by yourself.
|
||||
}
|
||||
this.closed = true
|
||||
|
Loading…
Reference in New Issue
Block a user