0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-22 11:17:33 +01:00

feat: move http-exception out of utils (#883)

This commit is contained in:
Yusuke Wada 2023-02-11 18:05:50 +09:00 committed by GitHub
parent 401ea08129
commit 39e855f0a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 23 additions and 24 deletions

View File

@ -1,6 +1,7 @@
import { compose } from './compose.ts'
import { Context } from './context.ts'
import type { ExecutionContext } from './context.ts'
import { HTTPException } from './http-exception.ts'
import type { Router } from './router.ts'
import { METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE, METHODS } from './router.ts'
import { RegExpRouter } from './router/reg-exp-router/index.ts'
@ -18,7 +19,6 @@ import type {
OnHandlerInterface,
TypeResponse,
} from './types.ts'
import { HTTPException } from './utils/http-exception.ts'
import { getPathFromURL, mergePath } from './utils/url.ts'
type Methods = typeof METHODS[number] | typeof METHOD_NAME_ALL_LOWERCASE

View File

@ -1,5 +1,5 @@
import type { StatusCode } from './http-status'
import { getStatusText } from './http-status'
import type { StatusCode } from './utils/http-status.ts'
import { getStatusText } from './utils/http-status.ts'
type HTTPExceptionOptions = {
res?: Response

View File

@ -1,8 +1,8 @@
import { HTTPException } from '../../http-exception.ts'
import type { HonoRequest } from '../../request.ts'
import type { MiddlewareHandler } from '../../types.ts'
import { timingSafeEqual } from '../../utils/buffer.ts'
import { decodeBase64 } from '../../utils/encode.ts'
import { HTTPException } from '../../utils/http-exception.ts'
const CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/
const USER_PASS_REGEXP = /^([^:]*):(.*)$/

View File

@ -1,6 +1,6 @@
import { HTTPException } from '../../http-exception.ts'
import type { MiddlewareHandler } from '../../types.ts'
import { timingSafeEqual } from '../../utils/buffer.ts'
import { HTTPException } from '../../utils/http-exception.ts'
const TOKEN_STRINGS = '[A-Za-z0-9._~+/-]+=*'
const PREFIX = 'Bearer'

View File

@ -1,5 +1,5 @@
import { HTTPException } from '../../http-exception.ts'
import type { MiddlewareHandler } from '../../types.ts'
import { HTTPException } from '../../utils/http-exception.ts'
import { Jwt } from '../../utils/jwt/index.ts'
import type { AlgorithmTypes } from '../../utils/jwt/types.ts'

View File

@ -33,6 +33,11 @@
"import": "./dist/index.js",
"require": "./dist/cjs/index.js"
},
"./http-exception": {
"types": "./dist/types/http-exception.d.ts",
"import": "./dist/http-exception.js",
"require": "./dist/cjs/http-exception.js"
},
"./basic-auth": {
"types": "./dist/types/middleware/basic-auth/index.d.ts",
"import": "./dist/middleware/basic-auth/index.js",
@ -161,6 +166,9 @@
},
"typesVersions": {
"*": {
"http-exception": [
"./dist/types/http-exception"
],
"basic-auth": [
"./dist/types/middleware/basic-auth"
],
@ -203,15 +211,6 @@
"pretty-json": [
"./dist/types/middleware/pretty-json"
],
"serve-static": [
"./dist/types/middleware/serve-static/index.d.ts"
],
"serve-static.bun": [
"./dist/types/middleware/serve-static/bun.d.ts"
],
"serve-static.module": [
"./dist/types/middleware/serve-static/module.d.ts"
],
"validator": [
"./dist/types/validator/index.d.ts"
],
@ -315,4 +314,4 @@
"engines": {
"node": ">=16.0.0"
}
}
}

View File

@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { Context } from './context'
import { Hono } from './hono'
import { HTTPException } from './http-exception'
import { logger } from './middleware/logger'
import { poweredBy } from './middleware/powered-by'
import { RegExpRouter } from './router/reg-exp-router'
import { TrieRouter } from './router/trie-router'
import type { Handler, Next } from './types'
import { HTTPException } from './utils/http-exception'
import type { Expect, Equal } from './utils/types'
describe('GET Request', () => {

View File

@ -1,6 +1,7 @@
import { compose } from './compose'
import { Context } from './context'
import type { ExecutionContext } from './context'
import { HTTPException } from './http-exception'
import type { Router } from './router'
import { METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE, METHODS } from './router'
import { RegExpRouter } from './router/reg-exp-router'
@ -18,7 +19,6 @@ import type {
OnHandlerInterface,
TypeResponse,
} from './types'
import { HTTPException } from './utils/http-exception'
import { getPathFromURL, mergePath } from './utils/url'
type Methods = typeof METHODS[number] | typeof METHOD_NAME_ALL_LOWERCASE

View File

@ -1,5 +1,5 @@
import type { StatusCode } from './http-status.ts'
import { getStatusText } from './http-status.ts'
import type { StatusCode } from './utils/http-status'
import { getStatusText } from './utils/http-status'
type HTTPExceptionOptions = {
res?: Response

View File

@ -1,8 +1,8 @@
import { HTTPException } from '../../http-exception'
import type { HonoRequest } from '../../request'
import type { MiddlewareHandler } from '../../types'
import { timingSafeEqual } from '../../utils/buffer'
import { decodeBase64 } from '../../utils/encode'
import { HTTPException } from '../../utils/http-exception'
const CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/
const USER_PASS_REGEXP = /^([^:]*):(.*)$/

View File

@ -1,6 +1,6 @@
import { HTTPException } from '../../http-exception'
import type { MiddlewareHandler } from '../../types'
import { timingSafeEqual } from '../../utils/buffer'
import { HTTPException } from '../../utils/http-exception'
const TOKEN_STRINGS = '[A-Za-z0-9._~+/-]+=*'
const PREFIX = 'Bearer'

View File

@ -1,5 +1,5 @@
import { HTTPException } from '../../http-exception'
import type { MiddlewareHandler } from '../../types'
import { HTTPException } from '../../utils/http-exception'
import { Jwt } from '../../utils/jwt'
import type { AlgorithmTypes } from '../../utils/jwt/types'

View File

@ -1,10 +1,10 @@
import { Hono } from '../src'
import { HTTPException } from '../src/http-exception'
import { basicAuth } from '../src/middleware/basic-auth'
import { bearerAuth } from '../src/middleware/bearer-auth'
import { etag } from '../src/middleware/etag'
import { poweredBy } from '../src/middleware/powered-by'
import { prettyJSON } from '../src/middleware/pretty-json'
import { HTTPException } from '../src/utils/http-exception'
const app = new Hono()