ework-web 0.10.22 → 0.10.24
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/package.json +1 -1
- package/src/db.ts +31 -11
- package/src/index.ts +2 -2
package/package.json
CHANGED
package/src/db.ts
CHANGED
|
@@ -375,7 +375,8 @@ class MysqlDriver implements AsyncDatabase {
|
|
|
375
375
|
try {
|
|
376
376
|
await pool.query(stmt);
|
|
377
377
|
} catch (e) {
|
|
378
|
-
|
|
378
|
+
const errno = (e as { errno?: number }).errno;
|
|
379
|
+
if (errno === 1061 || errno === 30000) continue;
|
|
379
380
|
throw e;
|
|
380
381
|
}
|
|
381
382
|
}
|
|
@@ -456,10 +457,17 @@ export function getDB(): AsyncDatabase {
|
|
|
456
457
|
export async function getConfigAll(): Promise<Record<string, string>> {
|
|
457
458
|
try {
|
|
458
459
|
const driver = getDB();
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
460
|
+
try {
|
|
461
|
+
const rows = await driver.all<{ akey: string; value: string }>("SELECT akey, value FROM {{config}}");
|
|
462
|
+
const out: Record<string, string> = {};
|
|
463
|
+
for (const r of rows) out[r.akey] = r.value;
|
|
464
|
+
return out;
|
|
465
|
+
} catch {
|
|
466
|
+
const rows = await driver.all<{ key: string; value: string }>("SELECT key, value FROM {{config}}");
|
|
467
|
+
const out: Record<string, string> = {};
|
|
468
|
+
for (const r of rows) out[r.key] = r.value;
|
|
469
|
+
return out;
|
|
470
|
+
}
|
|
463
471
|
} catch {
|
|
464
472
|
return {};
|
|
465
473
|
}
|
|
@@ -467,13 +475,25 @@ export async function getConfigAll(): Promise<Record<string, string>> {
|
|
|
467
475
|
|
|
468
476
|
export async function setConfig(key: string, value: string): Promise<void> {
|
|
469
477
|
const now = new Date().toISOString();
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
"
|
|
473
|
-
|
|
474
|
-
|
|
478
|
+
try {
|
|
479
|
+
await getDB().run(
|
|
480
|
+
"INSERT INTO {{config}} (akey, value, updated_at) VALUES (?, ?, ?) " +
|
|
481
|
+
"ON CONFLICT(akey) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at",
|
|
482
|
+
[key, value, now]
|
|
483
|
+
);
|
|
484
|
+
} catch {
|
|
485
|
+
await getDB().run(
|
|
486
|
+
"INSERT INTO {{config}} (key, value, updated_at) VALUES (?, ?, ?) " +
|
|
487
|
+
"ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at",
|
|
488
|
+
[key, value, now]
|
|
489
|
+
);
|
|
490
|
+
}
|
|
475
491
|
}
|
|
476
492
|
|
|
477
493
|
export async function deleteConfig(key: string): Promise<void> {
|
|
478
|
-
|
|
494
|
+
try {
|
|
495
|
+
await getDB().run("DELETE FROM {{config}} WHERE akey = ?", [key]);
|
|
496
|
+
} catch {
|
|
497
|
+
await getDB().run("DELETE FROM {{config}} WHERE key = ?", [key]);
|
|
498
|
+
}
|
|
479
499
|
}
|
package/src/index.ts
CHANGED
|
@@ -128,8 +128,6 @@ async function refreshOpencodeClient(): Promise<void> {
|
|
|
128
128
|
await refreshOpencodeClient();
|
|
129
129
|
setInterval(refreshOpencodeClient, 10_000);
|
|
130
130
|
|
|
131
|
-
void autoWireAllProjects(`http://${cfg.host}:${cfg.port}`);
|
|
132
|
-
|
|
133
131
|
async function autoWireDaemon(projectId: number, origin: string): Promise<void> {
|
|
134
132
|
if (!cfg.autowireActive) {
|
|
135
133
|
log.info("autoWireDaemon: skipped (WORK_AUTOWIRE_ACTIVE=false)", { projectId });
|
|
@@ -181,6 +179,8 @@ async function autoWireAllProjects(origin: string): Promise<void> {
|
|
|
181
179
|
}
|
|
182
180
|
}
|
|
183
181
|
|
|
182
|
+
void autoWireAllProjects(`http://${cfg.host}:${cfg.port}`);
|
|
183
|
+
|
|
184
184
|
const SEC_HEADERS: Record<string, string> = {
|
|
185
185
|
"content-security-policy": `default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'`,
|
|
186
186
|
"x-content-type-options": "nosniff",
|