mirror of
https://github.com/honojs/hono.git
synced 2024-12-01 11:51:01 +01:00
refactor(context): do not use exported Env
(#352)
* refactor(context): do not use exported `Env` * do not export env
This commit is contained in:
parent
e30a7597b2
commit
8893e5c92c
@ -4,8 +4,7 @@ import { isAbsoluteURL } from './utils/url'
|
||||
|
||||
type Headers = Record<string, string>
|
||||
export type Data = string | ArrayBuffer | ReadableStream
|
||||
|
||||
export type Env = Record<string, any>
|
||||
type Env = Record<string, any>
|
||||
|
||||
export class Context<RequestParamKeyType extends string = string, E = Env> {
|
||||
req: Request<RequestParamKeyType>
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { compose } from './compose'
|
||||
import { Context } from './context'
|
||||
import type { Env } from './context'
|
||||
import { extendRequestPrototype } from './request'
|
||||
import type { Router } from './router'
|
||||
import { METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE } from './router'
|
||||
import { TrieRouter } from './router/trie-router' // Default Router
|
||||
import { getPathFromURL, mergePath } from './utils/url'
|
||||
|
||||
type Env = Record<string, any>
|
||||
export type Handler<RequestParamKeyType extends string = string, E = Env> = (
|
||||
c: Context<RequestParamKeyType, E>,
|
||||
next: Next
|
||||
|
@ -4,7 +4,6 @@
|
||||
import { Hono } from './hono'
|
||||
export type { Handler, Next } from './hono'
|
||||
export { Context } from './context'
|
||||
export type { Env } from './context'
|
||||
|
||||
declare module './hono' {
|
||||
interface Hono {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { Context, Env } from '../../context'
|
||||
import type { Context } from '../../context'
|
||||
import type { Handler, Next } from '../../hono'
|
||||
import { getContentFromKVAsset } from '../../utils/cloudflare'
|
||||
import { getFilePath } from '../../utils/filepath'
|
||||
@ -14,7 +14,7 @@ export type ServeStaticOptions = {
|
||||
const DEFAULT_DOCUMENT = 'index.html'
|
||||
|
||||
// This middleware is available only on Cloudflare Workers.
|
||||
export const serveStatic = (options: ServeStaticOptions = { root: '' }): Handler<string, Env> => {
|
||||
export const serveStatic = (options: ServeStaticOptions = { root: '' }): Handler => {
|
||||
return async (c: Context, next: Next): Promise<Response | undefined> => {
|
||||
// Do nothing if Response is already set
|
||||
if (c.res && c.finalized) {
|
||||
|
@ -13,7 +13,6 @@ declare global {
|
||||
|
||||
export type { Handler, Next } from './hono'
|
||||
export { Context } from './context'
|
||||
export type { Env } from './context'
|
||||
export { Hono }
|
||||
|
||||
// Router
|
||||
|
Loading…
Reference in New Issue
Block a user