mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 03:55:38 -04:00
Migrate from Node.js built-ins to Bun-native APIs (#1)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"use server";
|
||||
|
||||
import crypto from "node:crypto";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { headers } from "next/headers";
|
||||
import { auth } from "@/lib/auth/server";
|
||||
@@ -56,7 +55,9 @@ export async function saveWebhookConnection(
|
||||
};
|
||||
}
|
||||
|
||||
const token = crypto.randomBytes(32).toString("hex");
|
||||
const token = Buffer.from(
|
||||
crypto.getRandomValues(new Uint8Array(32)),
|
||||
).toString("hex");
|
||||
const now = new Date();
|
||||
|
||||
const connection = db
|
||||
@@ -103,7 +104,9 @@ export async function regenerateWebhookToken(provider: "plex" | "jellyfin") {
|
||||
throw new Error("Invalid provider");
|
||||
}
|
||||
|
||||
const newToken = crypto.randomBytes(32).toString("hex");
|
||||
const newToken = Buffer.from(
|
||||
crypto.getRandomValues(new Uint8Array(32)),
|
||||
).toString("hex");
|
||||
|
||||
const connection = db
|
||||
.update(webhookConnections)
|
||||
|
||||
@@ -19,17 +19,17 @@ async function getAdminSession() {
|
||||
|
||||
export async function createBackupAction(): Promise<BackupInfo> {
|
||||
await getAdminSession();
|
||||
return createBackup();
|
||||
return await createBackup();
|
||||
}
|
||||
|
||||
export async function listBackupsAction(): Promise<BackupInfo[]> {
|
||||
await getAdminSession();
|
||||
return listBackups();
|
||||
return await listBackups();
|
||||
}
|
||||
|
||||
export async function deleteBackupAction(filename: string): Promise<void> {
|
||||
await getAdminSession();
|
||||
deleteBackup(filename);
|
||||
await deleteBackup(filename);
|
||||
}
|
||||
|
||||
export async function setScheduledBackupAction(
|
||||
|
||||
@@ -57,7 +57,7 @@ export default async function SettingsPage() {
|
||||
? getSetting("registrationOpen") === "true"
|
||||
: false;
|
||||
|
||||
const backups = isAdmin ? listBackups() : [];
|
||||
const backups = isAdmin ? await listBackups() : [];
|
||||
const scheduledBackupsEnabled = isAdmin
|
||||
? getSetting("scheduledBackups") === "true"
|
||||
: false;
|
||||
|
||||
Reference in New Issue
Block a user