-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestFilesGuide.js
More file actions
39 lines (34 loc) · 1.25 KB
/
testFilesGuide.js
File metadata and controls
39 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import BosBase from "bosbase";
const baseUrl = process.env.BOSBASE_BASE_URL ?? "http://127.0.0.1:8090";
const authEmail =
process.env.BOSBASE_EMAIL ??
process.env.BOSBASE_SUPERUSER_EMAIL ??
"try@bosbase.com";
const authPassword =
process.env.BOSBASE_PASSWORD ??
process.env.BOSBASE_SUPERUSER_PASSWORD ??
"bosbasepass";
async function main() {
try {
console.log("[INFO] FILES.md doc test starting...");
const pb = new BosBase(baseUrl);
await pb.collection("_superusers").authWithPassword(authEmail, authPassword);
console.log("[SUCCESS] Authenticated as superuser");
const demoUrl = pb.files.getURL({ id: "demo", collectionName: "demo", collectionId: "demo" }, "hello.txt");
console.log("[SUCCESS] Built file URL:", demoUrl || "(empty)");
console.log("\n========== FILES.md doc test completed ==========");
} catch (error) {
console.error("[ERROR] FILES.md doc test failed:");
if (error?.response) {
console.error("Status:", error.response.status);
console.error("Data:", JSON.stringify(error.response.data, null, 2));
if (error.response.data?.message) {
console.error("Message:", error.response.data.message);
}
} else {
console.error(error);
}
process.exit(1);
}
}
main();