@hasna/mementos 0.4.10 → 0.4.11
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/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +12 -6
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAkkCH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAkkCH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAkH9C"}
|
package/dist/server/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
// src/server/index.ts
|
|
5
5
|
import { existsSync as existsSync3 } from "fs";
|
|
6
|
-
import { dirname as dirname3, extname, join as join3 } from "path";
|
|
6
|
+
import { dirname as dirname3, extname, join as join3, resolve as resolve3, sep } from "path";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
|
|
9
9
|
// src/types/index.ts
|
|
@@ -2832,8 +2832,10 @@ async function findFreePort(start) {
|
|
|
2832
2832
|
return start;
|
|
2833
2833
|
}
|
|
2834
2834
|
function startServer(port) {
|
|
2835
|
+
const hostname = process.env["MEMENTOS_HOST"] ?? "127.0.0.1";
|
|
2835
2836
|
Bun.serve({
|
|
2836
2837
|
port,
|
|
2838
|
+
hostname,
|
|
2837
2839
|
async fetch(req) {
|
|
2838
2840
|
const url = new URL(req.url);
|
|
2839
2841
|
const { pathname } = url;
|
|
@@ -2842,7 +2844,7 @@ function startServer(port) {
|
|
|
2842
2844
|
}
|
|
2843
2845
|
if (pathname === "/api/health" || pathname === "/health") {
|
|
2844
2846
|
const profile = getActiveProfile();
|
|
2845
|
-
return json({ status: "ok", version: "0.1.0", profile: profile ?? "default", db_path: getDbPath2() });
|
|
2847
|
+
return json({ status: "ok", version: "0.1.0", profile: profile ?? "default", db_path: getDbPath2(), hostname });
|
|
2846
2848
|
}
|
|
2847
2849
|
if (pathname === "/api/profile" && req.method === "GET") {
|
|
2848
2850
|
const profile = getActiveProfile();
|
|
@@ -2892,9 +2894,13 @@ function startServer(port) {
|
|
|
2892
2894
|
const dashDir = resolveDashboardDir();
|
|
2893
2895
|
if (existsSync3(dashDir) && (req.method === "GET" || req.method === "HEAD")) {
|
|
2894
2896
|
if (pathname !== "/") {
|
|
2895
|
-
const
|
|
2896
|
-
|
|
2897
|
-
|
|
2897
|
+
const resolvedDash = resolve3(dashDir) + sep;
|
|
2898
|
+
const requestedPath = resolve3(join3(dashDir, pathname));
|
|
2899
|
+
if (requestedPath.startsWith(resolvedDash)) {
|
|
2900
|
+
const staticRes = serveStaticFile(requestedPath);
|
|
2901
|
+
if (staticRes)
|
|
2902
|
+
return staticRes;
|
|
2903
|
+
}
|
|
2898
2904
|
}
|
|
2899
2905
|
const indexRes = serveStaticFile(join3(dashDir, "index.html"));
|
|
2900
2906
|
if (indexRes)
|
|
@@ -2911,7 +2917,7 @@ function startServer(port) {
|
|
|
2911
2917
|
}
|
|
2912
2918
|
}
|
|
2913
2919
|
});
|
|
2914
|
-
console.log(`Mementos server listening on http
|
|
2920
|
+
console.log(`Mementos server listening on http://${hostname}:${port}`);
|
|
2915
2921
|
}
|
|
2916
2922
|
async function main() {
|
|
2917
2923
|
const requestedPort = parsePort();
|