@riligar/elysia-sqlite 1.1.4 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +14 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riligar/elysia-sqlite",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Plugin ElysiaJS para gerenciamento de bancos de dados SQLite",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -69,8 +69,14 @@ export const sqliteAdmin = ({ dbPath, prefix = "/admin", configPath = "./sqlite-
69
69
  return { session };
70
70
  })
71
71
  .onBeforeHandle(({ path, set, session, body }) => {
72
+ // Enforce trailing slash for root to ensure relative assets work
73
+ if (path === prefix) {
74
+ set.redirect = prefix + '/';
75
+ return;
76
+ }
77
+
72
78
  // Permitir assets e HTML principal
73
- if (path.includes('/assets/') || path === prefix || path === prefix + '/') return;
79
+ if (path.includes('/assets/') || path === prefix + '/') return;
74
80
  if (path.endsWith('index.html')) return;
75
81
 
76
82
  // Rotas Públicas de API
@@ -239,8 +245,13 @@ export const sqliteAdmin = ({ dbPath, prefix = "/admin", configPath = "./sqlite-
239
245
  .get("/assets/*", async ({ params }) => {
240
246
  const filePath = join(uiPath, "assets", params["*"]);
241
247
  const file = Bun.file(filePath);
242
- if (!(await file.exists()))
243
- return new Response("Not found", { status: 404 });
248
+ const exists = await file.exists();
249
+
250
+ if (!exists) {
251
+ console.log(`[SQLite Admin] Asset not found: ${filePath}`);
252
+ return new Response("Not found", { status: 404 });
253
+ }
254
+
244
255
  const ext = filePath.substring(filePath.lastIndexOf("."));
245
256
  return new Response(file, {
246
257
  headers: {