-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestLogsApi.js
More file actions
51 lines (45 loc) · 1.65 KB
/
testLogsApi.js
File metadata and controls
51 lines (45 loc) · 1.65 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
40
41
42
43
44
45
46
47
48
49
50
51
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] LOGS_API.md doc test starting...");
const pb = new BosBase(baseUrl);
await pb.collection("_superusers").authWithPassword(authEmail, authPassword);
console.log("[SUCCESS] Authenticated as superuser");
const logs = await pb.logs.getList(1, 5);
console.log("[SUCCESS] Logs returned:", logs?.items?.length ?? 0);
console.log("\n========== LOGS_API.md doc test completed ==========");
} catch (error) {
// Some BosBase builds may have request logs collection disabled.
// In such case the endpoint could respond with 400.
if (error?.response?.status === 400 && process.env.BOSBASE_RUN_LOGS !== "1") {
console.log(
"[SKIP] Logs API test skipped (set BOSBASE_RUN_LOGS=1 to enforce).",
);
return;
}
console.error("[ERROR] LOGS_API.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.headers) {
console.error("Headers:", JSON.stringify(error.response.headers, null, 2));
}
if (error.response.data?.message) {
console.error("Message:", error.response.data.message);
}
} else {
console.error(error);
}
process.exit(1);
}
}
main();