@riligar/elysia-backup 1.8.0 → 1.8.1
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.
- package/README.md +6 -6
- package/package.json +1 -1
- package/src/core/config.js +1 -1
- package/src/index.js +7 -7
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ const app = new Elysia()
|
|
|
41
41
|
.use(
|
|
42
42
|
r2Backup({
|
|
43
43
|
sourceDir: './data',
|
|
44
|
-
configPath: './config.json',
|
|
44
|
+
configPath: './backup-config.json',
|
|
45
45
|
})
|
|
46
46
|
)
|
|
47
47
|
.listen(3000)
|
|
@@ -60,12 +60,12 @@ On first run, you'll be guided through an onboarding wizard to configure:
|
|
|
60
60
|
|
|
61
61
|
### Plugin Options
|
|
62
62
|
|
|
63
|
-
| Option | Type | Required | Description
|
|
64
|
-
| ------------ | ------ | -------- |
|
|
65
|
-
| `sourceDir` | string | ✅ | Local directory to backup
|
|
66
|
-
| `configPath` | string | ❌ | Path to save runtime config (default: `./config.json`) |
|
|
63
|
+
| Option | Type | Required | Description |
|
|
64
|
+
| ------------ | ------ | -------- | ------------------------------------------------------------- |
|
|
65
|
+
| `sourceDir` | string | ✅ | Local directory to backup |
|
|
66
|
+
| `configPath` | string | ❌ | Path to save runtime config (default: `./backup-config.json`) |
|
|
67
67
|
|
|
68
|
-
### Runtime Configuration (via UI or config.json)
|
|
68
|
+
### Runtime Configuration (via UI or backup-config.json)
|
|
69
69
|
|
|
70
70
|
| Option | Type | Description |
|
|
71
71
|
| ----------------- | -------- | ---------------------------------------------- |
|
package/package.json
CHANGED
package/src/core/config.js
CHANGED
|
@@ -43,7 +43,7 @@ export const saveConfig = async (configPath, config) => {
|
|
|
43
43
|
* @returns {Object} Configuration manager with get/set/save methods
|
|
44
44
|
*/
|
|
45
45
|
export const createConfigManager = initialConfig => {
|
|
46
|
-
const configPath = initialConfig.configPath || './config.json'
|
|
46
|
+
const configPath = initialConfig.configPath || './backup-config.json'
|
|
47
47
|
const savedConfig = loadConfig(configPath)
|
|
48
48
|
|
|
49
49
|
let config = { ...initialConfig, ...savedConfig }
|
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@ 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
|
+
import { html, Html } from '@elysiajs/html'
|
|
9
9
|
|
|
10
10
|
// Import core modules
|
|
11
11
|
import { createSessionManager } from './core/session.js'
|
|
@@ -32,11 +32,11 @@ const sessionManager = createSessionManager()
|
|
|
32
32
|
* @param {string} [config.prefix] - Optional prefix for S3 keys (e.g. 'backups/')
|
|
33
33
|
* @param {string} [config.cronSchedule] - Cron schedule expression
|
|
34
34
|
* @param {boolean} [config.cronEnabled] - Whether the cron schedule is enabled
|
|
35
|
-
* @param {string} [config.configPath] - Path to save runtime configuration (default: './config.json')
|
|
35
|
+
* @param {string} [config.configPath] - Path to save runtime configuration (default: './backup-config.json')
|
|
36
36
|
*/
|
|
37
37
|
export const r2Backup = initialConfig => app => {
|
|
38
38
|
// State to hold runtime configuration (allows UI updates)
|
|
39
|
-
const configPath = initialConfig.configPath || './config.json'
|
|
39
|
+
const configPath = initialConfig.configPath || './backup-config.json'
|
|
40
40
|
|
|
41
41
|
// Load saved config if exists
|
|
42
42
|
let savedConfig = {}
|
|
@@ -52,7 +52,7 @@ export const r2Backup = initialConfig => app => {
|
|
|
52
52
|
|
|
53
53
|
let config = { ...initialConfig, ...savedConfig }
|
|
54
54
|
|
|
55
|
-
// Helper to check if config.json exists and has required fields
|
|
55
|
+
// Helper to check if backup-config.json exists and has required fields
|
|
56
56
|
const hasValidConfig = () => {
|
|
57
57
|
if (!existsSync(configPath)) return false
|
|
58
58
|
try {
|
|
@@ -138,7 +138,7 @@ export const r2Backup = initialConfig => app => {
|
|
|
138
138
|
return
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
return LoginPage({ totpEnabled: !!config.auth?.totpSecret })
|
|
141
|
+
return Html(LoginPage({ totpEnabled: !!config.auth?.totpSecret }))
|
|
142
142
|
})
|
|
143
143
|
|
|
144
144
|
// AUTH: Login Endpoint
|
|
@@ -452,7 +452,7 @@ export const r2Backup = initialConfig => app => {
|
|
|
452
452
|
set.headers['Location'] = '/backup'
|
|
453
453
|
return
|
|
454
454
|
}
|
|
455
|
-
return OnboardingPage({ sourceDir: config.sourceDir })
|
|
455
|
+
return Html(OnboardingPage({ sourceDir: config.sourceDir }))
|
|
456
456
|
})
|
|
457
457
|
|
|
458
458
|
// ONBOARDING: Save Initial Config
|
|
@@ -535,7 +535,7 @@ export const r2Backup = initialConfig => app => {
|
|
|
535
535
|
|
|
536
536
|
const jobStatus = scheduler.getStatus(config.cronEnabled)
|
|
537
537
|
const hasAuth = !!(config.auth && config.auth.username && config.auth.password)
|
|
538
|
-
return DashboardPage({ config, jobStatus, hasAuth })
|
|
538
|
+
return Html(DashboardPage({ config, jobStatus, hasAuth }))
|
|
539
539
|
})
|
|
540
540
|
)
|
|
541
541
|
})
|