Skip to content

Commit 932517a

Browse files
committed
feat: Replace @elysiajs/html with custom HTML response handling.
1 parent 72e5a4f commit 932517a

File tree

4 files changed

+97
-20
lines changed

4 files changed

+97
-20
lines changed

demo/bun.lock

Lines changed: 86 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dev": "bun --watch run index.js"
99
},
1010
"dependencies": {
11-
"@riligar/elysia-backup": "^1.1.0",
11+
"@riligar/elysia-backup": "^1.8.2",
1212
"elysia": "^1.4.19"
1313
}
1414
}

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
},
4343
"license": "MIT",
4444
"peerDependencies": {
45-
"elysia": ">=1.0.0",
46-
"@elysiajs/html": ">=1.0.0"
45+
"elysia": ">=1.0.0"
4746
},
4847
"dependencies": {
4948
"cron": "^3.5.0",

src/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { authenticator } from 'otplib'
55
import QRCode from 'qrcode'
66
import { writeFile } from 'node:fs/promises'
77
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+
})
913

1014
// Import core modules
1115
import { createSessionManager } from './core/session.js'
@@ -76,7 +80,7 @@ export const r2Backup = initialConfig => app => {
7680
// Setup initial cron schedule
7781
scheduler.setup(config.cronSchedule, config.cronEnabled !== false)
7882

79-
return app.use(html({ autoDoctype: 'full' })).group('/backup', app => {
83+
return app.group('/backup', app => {
8084
// Authentication Middleware
8185
const authMiddleware = context => {
8286
// Skip auth entirely if no valid config (needs onboarding)
@@ -138,7 +142,7 @@ export const r2Backup = initialConfig => app => {
138142
return
139143
}
140144

141-
return LoginPage({ totpEnabled: !!config.auth?.totpSecret })
145+
return htmlResponse(LoginPage({ totpEnabled: !!config.auth?.totpSecret }))
142146
})
143147

144148
// AUTH: Login Endpoint
@@ -452,7 +456,7 @@ export const r2Backup = initialConfig => app => {
452456
set.headers['Location'] = '/backup'
453457
return
454458
}
455-
return OnboardingPage({ sourceDir: config.sourceDir })
459+
return htmlResponse(OnboardingPage({ sourceDir: config.sourceDir }))
456460
})
457461

458462
// ONBOARDING: Save Initial Config
@@ -535,7 +539,7 @@ export const r2Backup = initialConfig => app => {
535539

536540
const jobStatus = scheduler.getStatus(config.cronEnabled)
537541
const hasAuth = !!(config.auth && config.auth.username && config.auth.password)
538-
return DashboardPage({ config, jobStatus, hasAuth })
542+
return htmlResponse(DashboardPage({ config, jobStatus, hasAuth }))
539543
})
540544
)
541545
})

0 commit comments

Comments
 (0)