diff --git a/apps/monograph/app/utils/env.ts b/apps/monograph/app/utils/env.ts
index 6c19ec228..e6cd1db92 100644
--- a/apps/monograph/app/utils/env.ts
+++ b/apps/monograph/app/utils/env.ts
@@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+import { readFileSync } from "node:fs";
+
const p = "process" in globalThis ? globalThis.process : ({ env: {} } as any);
export const API_HOST =
import.meta.env.API_HOST || p.env.API_HOST || `https://api.notesnook.com`;
@@ -26,3 +28,23 @@ export const PUBLIC_URL =
`http://localhost:${import.meta.env.PORT || p.env.PORT || 5173}`;
export const COMPATIBILITY_VERSION = 1;
export const INSTANCE_NAME = p.env.INSTANCE_NAME || "default";
+
+export function readSecrets(
+ names: T[]
+): Record {
+ const result: Record = {} as Record<
+ T,
+ string | undefined
+ >;
+ for (const name of names) result[name] = readSecret(name);
+ return result;
+}
+
+export function readSecret(name: string): string | undefined {
+ const value = process.env[name];
+ if (value) return value;
+ const file = process.env[`${name}_FILE`];
+ if (file) {
+ return readFileSync(file, "utf-8");
+ }
+}
diff --git a/apps/monograph/app/utils/storage/kv.ts b/apps/monograph/app/utils/storage/kv.ts
index 341301728..4dcc4c707 100644
--- a/apps/monograph/app/utils/storage/kv.ts
+++ b/apps/monograph/app/utils/storage/kv.ts
@@ -18,10 +18,16 @@ along with this program. If not, see .
*/
import WorkersKVREST from "@sagi.io/workers-kv";
+import { readSecrets } from "../env";
-const cfAccountId = process.env.CLOUDFLARE_ACCOUNT_ID!;
-const cfAuthToken = process.env.CLOUDFLARE_AUTH_TOKEN!;
-const namespaceId = process.env.CLOUDFLARE_KV_NAMESPACE_ID!;
+const env = readSecrets([
+ "CLOUDFLARE_ACCOUNT_ID",
+ "CLOUDFLARE_AUTH_TOKEN",
+ "CLOUDFLARE_KV_NAMESPACE_ID"
+]);
+const cfAccountId = env.CLOUDFLARE_ACCOUNT_ID;
+const cfAuthToken = env.CLOUDFLARE_AUTH_TOKEN;
+const namespaceId = env.CLOUDFLARE_KV_NAMESPACE_ID;
if (!cfAccountId || !cfAuthToken || !namespaceId)
throw new Error(
diff --git a/apps/monograph/package-lock.json b/apps/monograph/package-lock.json
index a3956a1b4..d0567ae38 100644
--- a/apps/monograph/package-lock.json
+++ b/apps/monograph/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@notesnook/monograph",
- "version": "1.2.5",
+ "version": "1.2.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@notesnook/monograph",
- "version": "1.2.5",
+ "version": "1.2.6",
"dependencies": {
"@emotion/cache": "11.11.0",
"@emotion/react": "11.11.1",
@@ -76,6 +76,7 @@
"@streetwriters/kysely": "^0.27.4",
"@streetwriters/showdown": "^3.0.9-alpha",
"@types/mime-db": "^1.43.5",
+ "alfaaz": "^1.1.0",
"async-mutex": "0.5.0",
"dayjs": "1.11.13",
"dom-serializer": "^2.0.0",
@@ -163,9 +164,6 @@
"@tiptap/extension-placeholder": "2.6.6",
"@tiptap/extension-subscript": "2.6.6",
"@tiptap/extension-superscript": "2.6.6",
- "@tiptap/extension-table": "2.6.6",
- "@tiptap/extension-table-cell": "2.6.6",
- "@tiptap/extension-table-header": "2.6.6",
"@tiptap/extension-table-row": "2.6.6",
"@tiptap/extension-task-item": "2.6.6",
"@tiptap/extension-task-list": "2.6.6",
diff --git a/apps/monograph/package.json b/apps/monograph/package.json
index bbd58668e..8a6192cdd 100644
--- a/apps/monograph/package.json
+++ b/apps/monograph/package.json
@@ -1,6 +1,6 @@
{
"name": "@notesnook/monograph",
- "version": "1.2.5",
+ "version": "1.2.6",
"private": true,
"sideEffects": false,
"type": "module",
diff --git a/apps/monograph/server.ts b/apps/monograph/server.ts
index f32fec68a..8f5430a76 100644
--- a/apps/monograph/server.ts
+++ b/apps/monograph/server.ts
@@ -31,10 +31,10 @@ const remix = createRequestHandler(
build as unknown as ServerBuild,
Bun.env.NODE_ENV
);
-process.env.PORT = process.env.PORT || "3000";
export default {
- port: process.env.PORT,
+ port: process.env.PORT || "3000",
+ hostname: process.env.HOST || "localhost",
async fetch(request) {
// First we need to send handle static files
const { pathname } = new URL(request.url);