plugins: ctx.fileStats

Massimo Melina committed May 21, 2023 at 12:23 UTC 0de65c123f0bc83e347deffbcf9c9ef01b7221f6
1 file changed +1
src/serveFile.ts
+1
@@ -67,6 +67,7 @@ export async function serveFile(ctx: Koa.Context, source:string, mime?:string, c
67 const stats = await promisify(stat)(source) // using fs's function instead of fs/promises, because only the former is supported by pkg
68 ctx.set('Last-Modified', stats.mtime.toUTCString())
69 ctx.fileSource = source
70 + ctx.fileStats = stats
71 ctx.status = HTTP_OK
72 if (ctx.fresh)
73 return ctx.status = HTTP_NOT_MODIFIED