2023-10-13 11:47:57 +00:00
|
|
|
import { Store } from "indexed_kv";
|
2023-11-20 00:33:38 +00:00
|
|
|
import { Static, t } from "elysia";
|
2023-10-13 11:47:57 +00:00
|
|
|
import { db } from "./db.ts";
|
|
|
|
|
2023-11-20 00:33:38 +00:00
|
|
|
export const workerInstanceSchema = t.Object({
|
|
|
|
key: t.String(),
|
|
|
|
name: t.Nullable(t.String()),
|
|
|
|
sdUrl: t.String(),
|
|
|
|
sdAuth: t.Nullable(t.Object({
|
|
|
|
user: t.String(),
|
|
|
|
password: t.String(),
|
|
|
|
})),
|
|
|
|
lastOnlineTime: t.Optional(t.Number()),
|
|
|
|
lastError: t.Optional(t.Object({
|
|
|
|
message: t.String(),
|
|
|
|
time: t.Number(),
|
|
|
|
})),
|
|
|
|
});
|
2023-10-13 11:47:57 +00:00
|
|
|
|
2023-11-20 00:33:38 +00:00
|
|
|
export type WorkerInstance = Static<typeof workerInstanceSchema>;
|
2023-10-13 11:47:57 +00:00
|
|
|
|
|
|
|
export const workerInstanceStore = new Store<WorkerInstance>(db, "workerInstances", {
|
|
|
|
indices: {},
|
|
|
|
});
|