File tree Expand file tree Collapse file tree 4 files changed +16
-13
lines changed Expand file tree Collapse file tree 4 files changed +16
-13
lines changed Original file line number Diff line number Diff line change 1+ # 1.4.3 - 13 Oct 2025
2+ Bug fix:
3+ - remove stat cache
4+
15# 1.4.2 - 13 Oct 2025
26Improvement:
37- better caching mechanism
Original file line number Diff line number Diff line change @@ -5,11 +5,8 @@ import { staticPlugin } from '../src/index'
55import html from '../public/html/index.html'
66
77const app = new Elysia ( )
8- . get ( '' , html )
98 . use (
10- staticPlugin ( {
11- alwaysStatic : true
12- } )
9+ await staticPlugin ( )
1310 )
1411 . listen ( 3000 )
1512
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < title > Home!!</ title >
5+ </ head >
6+ < body >
7+ < h1 > A!</ h1 >
8+ </ body >
9+ </ html >
Original file line number Diff line number Diff line change @@ -50,7 +50,6 @@ export async function staticPlugin<const Prefix extends string = '/prefix'>({
5050
5151 const [ fs , path ] = builtinModule
5252
53- const statCache = new LRUCache < string , Stats > ( )
5453 const fileCache = new LRUCache < string , Response > ( )
5554
5655 if ( prefix === path . sep ) prefix = '' as Prefix
@@ -256,14 +255,8 @@ export async function staticPlugin<const Prefix extends string = '/prefix'>({
256255 if ( cache ) return cache . clone ( )
257256
258257 try {
259- let fileStat = statCache . get ( pathName )
260- if ( ! fileStat )
261- try {
262- fileStat = await fs . stat ( pathName )
263- statCache . set ( pathName , fileStat )
264- } catch {
265- throw new NotFoundError ( )
266- }
258+ const fileStat = await fs . stat ( pathName ) . catch ( ( ) => null )
259+ if ( ! fileStat ) throw new NotFoundError ( )
267260
268261 if ( ! indexHTML && fileStat . isDirectory ( ) )
269262 throw new NotFoundError ( )
You can’t perform that action at this time.
0 commit comments