0
0
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:
Yusuke Wada 2022-07-10 18:50:06 +09:00 committed by GitHub
parent e30a7597b2
commit 8893e5c92c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 7 deletions

View File

@ -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>

View File

@ -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

View File

@ -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 {

View File

@ -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) {

View File

@ -13,7 +13,6 @@ declare global {
export type { Handler, Next } from './hono'
export { Context } from './context'
export type { Env } from './context'
export { Hono }
// Router