@riligar/elysia-backup 1.8.2 → 1.9.0

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 +2 -3
  2. package/src/index.js +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riligar/elysia-backup",
3
- "version": "1.8.2",
3
+ "version": "1.9.0",
4
4
  "description": "Elysia plugin for R2/S3 backup with a built-in UI dashboard",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -42,8 +42,7 @@
42
42
  },
43
43
  "license": "MIT",
44
44
  "peerDependencies": {
45
- "elysia": ">=1.0.0",
46
- "@elysiajs/html": ">=1.0.0"
45
+ "elysia": ">=1.0.0"
47
46
  },
48
47
  "dependencies": {
49
48
  "cron": "^3.5.0",
package/src/index.js CHANGED
@@ -5,7 +5,11 @@ import { authenticator } from 'otplib'
5
5
  import QRCode from 'qrcode'
6
6
  import { writeFile } from 'node:fs/promises'
7
7
  import { readFileSync, existsSync } from 'node:fs'
8
- import { html } from '@elysiajs/html'
8
+ // Helper to return HTML responses with proper Content-Type
9
+ const htmlResponse = content =>
10
+ new Response(content, {
11
+ headers: { 'Content-Type': 'text/html; charset=utf-8' },
12
+ })
9
13
 
10
14
  // Import core modules
11
15
  import { createSessionManager } from './core/session.js'
@@ -76,7 +80,7 @@ export const r2Backup = initialConfig => app => {
76
80
  // Setup initial cron schedule
77
81
  scheduler.setup(config.cronSchedule, config.cronEnabled !== false)
78
82
 
79
- return app.use(html({ autoDoctype: 'full' })).group('/backup', app => {
83
+ return app.group('/backup', app => {
80
84
  // Authentication Middleware
81
85
  const authMiddleware = context => {
82
86
  // Skip auth entirely if no valid config (needs onboarding)
@@ -138,7 +142,7 @@ export const r2Backup = initialConfig => app => {
138
142
  return
139
143
  }
140
144
 
141
- return LoginPage({ totpEnabled: !!config.auth?.totpSecret })
145
+ return htmlResponse(LoginPage({ totpEnabled: !!config.auth?.totpSecret }))
142
146
  })
143
147
 
144
148
  // AUTH: Login Endpoint
@@ -452,7 +456,7 @@ export const r2Backup = initialConfig => app => {
452
456
  set.headers['Location'] = '/backup'
453
457
  return
454
458
  }
455
- return OnboardingPage({ sourceDir: config.sourceDir })
459
+ return htmlResponse(OnboardingPage({ sourceDir: config.sourceDir }))
456
460
  })
457
461
 
458
462
  // ONBOARDING: Save Initial Config
@@ -535,7 +539,7 @@ export const r2Backup = initialConfig => app => {
535
539
 
536
540
  const jobStatus = scheduler.getStatus(config.cronEnabled)
537
541
  const hasAuth = !!(config.auth && config.auth.username && config.auth.password)
538
- return DashboardPage({ config, jobStatus, hasAuth })
542
+ return htmlResponse(DashboardPage({ config, jobStatus, hasAuth }))
539
543
  })
540
544
  )
541
545
  })