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