@heybejs/core 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Router } from "../router";
|
|
2
|
+
import { needsInstaller } from "./installer";
|
|
2
3
|
|
|
3
4
|
const PROXY_HEADERS = ["CF-Connecting-IP", "Fly-Client-IP", "X-Forwarded-For"];
|
|
4
5
|
|
|
5
6
|
// PB apis/health.go
|
|
6
7
|
export function registerHealthRoutes(router: Router): void {
|
|
7
8
|
router.route("GET", "/api/health", (e) => {
|
|
8
|
-
let data = {};
|
|
9
|
+
let data: Record<string, unknown> = {};
|
|
9
10
|
if (e.hasSuperuserAuth()) {
|
|
10
11
|
const headers = [
|
|
11
12
|
...e.app.settings.current().trustedProxy.headers,
|
|
@@ -18,6 +19,7 @@ export function registerHealthRoutes(router: Router): void {
|
|
|
18
19
|
headers.find((h) => (e.req.headers.get(h) ?? "") !== "") ?? "",
|
|
19
20
|
};
|
|
20
21
|
}
|
|
22
|
+
if (needsInstaller(e.app)) data.needsSetup = true;
|
|
21
23
|
return e.json(200, { message: "API is healthy.", code: 200, data });
|
|
22
24
|
});
|
|
23
25
|
}
|
|
@@ -5,7 +5,7 @@ import { internalRecords } from "../../records/internal";
|
|
|
5
5
|
|
|
6
6
|
const TOKEN_DURATION_SECONDS = 30 * 60;
|
|
7
7
|
|
|
8
|
-
function needsInstaller(app: App): boolean {
|
|
8
|
+
export function needsInstaller(app: App): boolean {
|
|
9
9
|
const row = app.db.get<{ total: number }>(
|
|
10
10
|
"SELECT COUNT(*) AS total FROM _superusers WHERE email != ?",
|
|
11
11
|
[INSTALLER_EMAIL],
|