@elysiajs/static
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -38,3 +38,3 @@ import type { Elysia } from 'elysia'; | ||
}) => (app: Elysia) => Elysia<import("elysia").ElysiaInstance<{ | ||
store: {}; | ||
store: Record<typeof import("elysia").SCHEMA, {}>; | ||
request: {}; | ||
@@ -41,0 +41,0 @@ schema: {}; |
@@ -38,20 +38,20 @@ import { readdirSync, existsSync } from 'fs'; | ||
return; | ||
app.get(`/${join(prefix, file.replace(`${path}/`, ''))}`, () => new Response(Bun.file(file))); | ||
const response = new Response(Bun.file(file)); | ||
app.get(`/${join(prefix, file.replace(`${path}/`, ''))}`, () => response.clone()); | ||
}); | ||
else { | ||
else | ||
app.get(`${prefix}/*`, ({ params }) => { | ||
const file = `${path}/${params['*']}`; | ||
if (shouldIgnore(file)) | ||
return new Response('Not Found', { | ||
return new Response('NOT_FOUND', { | ||
status: 404 | ||
}); | ||
return existsSync(file) | ||
? new Response(Bun.file(file)) | ||
: new Response('Not Found', { | ||
status: 404 | ||
}); | ||
if (existsSync(file)) | ||
return new Response(Bun.file(file)); | ||
return new Response('NOT_FOUND', { | ||
status: 404 | ||
}); | ||
}); | ||
} | ||
return app; | ||
}; | ||
export default staticPlugin; |
{ | ||
"name": "@elysiajs/static", | ||
"description": "Plugin for Elysia for serving static folder", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": { | ||
@@ -39,9 +39,10 @@ "name": "saltyAom", | ||
"bun-types": "^0.2.2", | ||
"elysia": "^0.1.2", | ||
"eslint": "^8.26.0", | ||
"elysia": "^0.1.0-rc.5", | ||
"mitata": "^0.1.6", | ||
"typescript": "^4.8.4" | ||
}, | ||
"peerDependencies": { | ||
"elysia": ">= 0.1.0-rc.5" | ||
"elysia": ">= 0.1.0" | ||
} | ||
} |
@@ -89,8 +89,9 @@ import type { Elysia } from 'elysia' | ||
app.get( | ||
`/${join(prefix, file.replace(`${path}/`, ''))}`, | ||
() => new Response(Bun.file(file)) | ||
const response = new Response(Bun.file(file)) | ||
app.get(`/${join(prefix, file.replace(`${path}/`, ''))}`, () => | ||
response.clone() | ||
) | ||
}) | ||
else { | ||
else | ||
app.get(`${prefix}/*`, ({ params }) => { | ||
@@ -100,13 +101,12 @@ const file = `${path}/${(params as any)['*']}` | ||
if (shouldIgnore(file)) | ||
return new Response('Not Found', { | ||
return new Response('NOT_FOUND', { | ||
status: 404 | ||
}) | ||
return existsSync(file) | ||
? new Response(Bun.file(file)) | ||
: new Response('Not Found', { | ||
status: 404 | ||
}) | ||
if (existsSync(file)) return new Response(Bun.file(file)) | ||
return new Response('NOT_FOUND', { | ||
status: 404 | ||
}) | ||
}) | ||
} | ||
@@ -113,0 +113,0 @@ return app |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9535
6
198