1
1
import { serveStatic as baseServeStatic } from '../../middleware/serve-static'
2
2
import type { ServeStaticOptions as BaseServeStaticOptions } from '../../middleware/serve-static'
3
- import type { Env , MiddlewareHandler } from '../../types'
3
+ import type { DefaultEnv , Env , MiddlewareHandler } from '../../types'
4
4
import { getContentFromKVAsset } from './utils'
5
5
6
- export type ServeStaticOptions < E extends Env = Env > = BaseServeStaticOptions < E > & {
6
+ export type ServeStaticOptions < E extends Env = DefaultEnv > = BaseServeStaticOptions < E > & {
7
7
// namespace is KVNamespace
8
8
namespace ?: unknown
9
9
manifest : object | string
@@ -18,9 +18,9 @@ export type ServeStaticOptions<E extends Env = Env> = BaseServeStaticOptions<E>
18
18
* please consider using Cloudflare Pages. You can start to create the Cloudflare Pages
19
19
* application with the `npm create hono@latest` command.
20
20
*/
21
- export const serveStatic = < E extends Env = Env > (
21
+ export const serveStatic = < E extends Env = DefaultEnv > (
22
22
options : ServeStaticOptions < E >
23
- ) : MiddlewareHandler => {
23
+ ) : MiddlewareHandler < E > => {
24
24
return async function serveStatic ( c , next ) {
25
25
const getContent = async ( path : string ) => {
26
26
return getContentFromKVAsset ( path , {
@@ -30,11 +30,12 @@ export const serveStatic = <E extends Env = Env>(
30
30
namespace : options . namespace
31
31
? options . namespace
32
32
: c . env
33
- ? c . env . __STATIC_CONTENT
33
+ ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ ( c . env as any ) . __STATIC_CONTENT
34
35
: undefined ,
35
36
} )
36
37
}
37
- return baseServeStatic ( {
38
+ return baseServeStatic < E > ( {
38
39
...options ,
39
40
getContent,
40
41
} ) ( c , next )
0 commit comments