17 lines
514 B
TypeScript
17 lines
514 B
TypeScript
|
|
import PocketBase from "pocketbase";
|
||
|
|
|
||
|
|
const url = process.env.NEXT_PUBLIC_POCKETBASE_URL || "http://127.0.0.1:8090";
|
||
|
|
|
||
|
|
export async function getAdminPocketBase() {
|
||
|
|
const email = process.env.PB_ADMIN_EMAIL;
|
||
|
|
const password = process.env.PB_ADMIN_PASSWORD;
|
||
|
|
|
||
|
|
if (!email || !password) {
|
||
|
|
throw new Error("PB_ADMIN_EMAIL and PB_ADMIN_PASSWORD are required for server API operations.");
|
||
|
|
}
|
||
|
|
|
||
|
|
const pb = new PocketBase(url);
|
||
|
|
await pb.collection("_superusers").authWithPassword(email, password);
|
||
|
|
return pb;
|
||
|
|
}
|