initial commit ??

This commit is contained in:
bootunloader
2024-09-11 02:57:43 +03:00
commit 33cbeaa9a3
186 changed files with 17269 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import Surreal from "surrealdb.js";
export type { QueryResult } from "surrealdb.js/script/types";
try {
if (document || window) {
throw new Error("SurrealDB needs a NodeJS environment to run.");
}
} catch (err) {}
const CONFIG = {
url: process.env.SURREAL_URL ?? "",
user: process.env.SURREAL_USER ?? "",
pass: process.env.SURREAL_PASS ?? "",
ns: process.env.SURREAL_NS ?? "",
db: process.env.SURREAL_DB ?? "",
} as const;
// for (let key in CONFIG) {
// if (
// !CONFIG[key as keyof typeof CONFIG] ||
// CONFIG[key as keyof typeof CONFIG] === ""
// ) {
// throw new Error(`Missing configuration for ${key}`);
// }
// }
let _surreal =
CONFIG.url.length > 0
? new Surreal(`http://${CONFIG.url}/rpc`, {
auth: { user: CONFIG.user, pass: CONFIG.pass },
ns: CONFIG.ns,
db: CONFIG.db,
})
: undefined;
export const surreal = _surreal as Surreal;