chore(nx/client): set up proxy to client

This commit is contained in:
Elian Doran 2025-04-23 10:06:37 +03:00
parent 4e8ab98db1
commit 5308a089b8
No known key found for this signature in database
3 changed files with 128 additions and 98 deletions

View File

@ -3,118 +3,114 @@
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@anthropic-ai/sdk": "0.39.0",
"@braintree/sanitize-url": "7.1.1",
"@triliumnext/express-partial-content": "1.0.1",
"@triliumnext/turndown-plugin-gfm": "0.0.1",
"archiver": "7.0.1",
"async-mutex": "0.5.0",
"axios": "1.8.4",
"better-sqlite3": "11.9.1",
"chardet": "2.1.0",
"cheerio": "1.0.0",
"chokidar": "4.0.3",
"cls-hooked": "4.2.2",
"compression": "1.8.0",
"cookie-parser": "1.4.7",
"csrf-csrf": "3.1.0",
"dayjs": "1.11.13",
"debounce": "2.2.0",
"ejs": "3.1.10",
"electron-debug": "4.1.0",
"electron-window-state": "5.0.3",
"escape-html": "1.0.3",
"express": "4.21.2", "express": "4.21.2",
"express-openid-connect": "^2.17.1", "express-openid-connect": "^2.17.1",
"express-rate-limit": "7.5.0", "express-rate-limit": "7.5.0",
"express-session": "1.18.1", "express-session": "1.18.1",
"serve-favicon": "2.5.0", "fs-extra": "11.3.0",
"cookie-parser": "1.4.7",
"helmet": "8.1.0", "helmet": "8.1.0",
"turndown": "7.2.0", "html": "1.0.0",
"compression": "1.8.0", "html2plaintext": "2.1.4",
"i18next": "25.0.0", "i18next": "25.0.0",
"i18next-fs-backend": "2.6.0", "i18next-fs-backend": "2.6.0",
"tmp": "0.2.3",
"jsdom": "26.1.0",
"better-sqlite3": "11.9.1",
"safe-compare": "1.1.4",
"debounce": "2.2.0",
"chardet": "2.1.0",
"rand-token": "1.0.1",
"sanitize-filename": "1.6.3",
"sanitize-html": "2.16.0",
"time2fa": "^1.3.0",
"axios": "1.8.4",
"xml2js": "0.6.2",
"swagger-jsdoc": "6.2.8",
"strip-bom": "5.0.0",
"cls-hooked": "4.2.2",
"ejs": "3.1.10",
"cheerio": "1.0.0",
"multer": "1.4.5-lts.2",
"dayjs": "1.11.13",
"chokidar": "4.0.3",
"archiver": "7.0.1",
"jimp": "1.6.0",
"image-type": "5.2.0", "image-type": "5.2.0",
"supertest": "7.1.0",
"async-mutex": "0.5.0",
"striptags": "3.2.0",
"@braintree/sanitize-url": "7.1.1",
"html": "1.0.0",
"csrf-csrf": "3.1.0",
"@triliumnext/express-partial-content": "1.0.1",
"session-file-store": "1.5.0",
"is-svg": "5.1.0",
"stream-throttle": "0.1.3",
"marked": "15.0.8",
"webpack": "5.99.6",
"js-yaml": "4.1.0",
"fs-extra": "11.3.0",
"escape-html": "1.0.3",
"ws": "8.18.1",
"ini": "5.0.0", "ini": "5.0.0",
"unescape": "1.0.1",
"html2plaintext": "2.1.4",
"normalize-strings": "1.1.1",
"is-animated": "2.0.2", "is-animated": "2.0.2",
"is-svg": "5.1.0",
"jimp": "1.6.0",
"js-yaml": "4.1.0",
"jsdom": "26.1.0",
"marked": "15.0.8",
"mime-types": "3.0.1", "mime-types": "3.0.1",
"@triliumnext/turndown-plugin-gfm": "0.0.1", "multer": "1.4.5-lts.2",
"yauzl": "3.2.0", "normalize-strings": "1.1.1",
"electron-debug": "4.1.0",
"electron-window-state": "5.0.3",
"swagger-ui-express": "5.0.1",
"ollama": "0.5.14", "ollama": "0.5.14",
"openai": "4.95.1", "openai": "4.95.1",
"@anthropic-ai/sdk": "0.39.0" "rand-token": "1.0.1",
"safe-compare": "1.1.4",
"sanitize-filename": "1.6.3",
"sanitize-html": "2.16.0",
"serve-favicon": "2.5.0",
"session-file-store": "1.5.0",
"stream-throttle": "0.1.3",
"strip-bom": "5.0.0",
"striptags": "3.2.0",
"supertest": "7.1.0",
"swagger-jsdoc": "6.2.8",
"swagger-ui-express": "5.0.1",
"time2fa": "^1.3.0",
"tmp": "0.2.3",
"turndown": "7.2.0",
"unescape": "1.0.1",
"webpack": "5.99.6",
"ws": "8.18.1",
"xml2js": "0.6.2",
"yauzl": "3.2.0"
}, },
"devDependencies": { "devDependencies": {
"@electron/remote": "2.1.2",
"@excalidraw/excalidraw": "0.18.0",
"@highlightjs/cdn-assets": "11.11.1",
"@types/archiver": "6.0.3",
"@types/better-sqlite3": "7.6.13",
"@types/cheerio": "0.22.35",
"@types/cls-hooked": "4.3.9",
"@types/compression": "1.7.5",
"@types/cookie-parser": "1.4.8",
"@types/debounce": "1.2.4",
"@types/ejs": "3.1.5",
"@types/escape-html": "1.0.4",
"@types/express-session": "1.18.1",
"@types/fs-extra": "11.0.4",
"@types/html": "1.0.4",
"@types/ini": "4.1.1",
"@types/js-yaml": "4.0.9",
"@types/jsdom": "21.1.7",
"@types/mime-types": "2.1.4",
"@types/multer": "1.4.12",
"@types/safe-compare": "1.1.2",
"@types/sanitize-html": "2.15.0",
"@types/sax": "1.2.7",
"@types/serve-favicon": "2.5.7",
"@types/session-file-store": "1.2.5",
"@types/stream-throttle": "0.1.4",
"@types/supertest": "6.0.3",
"@types/swagger-ui-express": "4.1.8",
"@types/tmp": "0.2.6",
"@types/turndown": "5.0.5",
"@types/ws": "8.18.1",
"@types/xml2js": "0.4.14",
"autocomplete.js": "0.38.1",
"boxicons": "2.1.4",
"codemirror": "5.65.19",
"electron": "35.1.5",
"express-http-proxy": "2.1.1",
"jquery": "3.7.1",
"jquery-hotkeys": "0.2.2", "jquery-hotkeys": "0.2.2",
"jquery.fancytree": "2.38.5", "jquery.fancytree": "2.38.5",
"jquery": "3.7.1",
"katex": "0.16.22", "katex": "0.16.22",
"autocomplete.js": "0.38.1", "normalize.css": "8.0.1"
"boxicons": "2.1.4",
"normalize.css": "8.0.1",
"codemirror": "5.65.19",
"@highlightjs/cdn-assets": "11.11.1",
"@excalidraw/excalidraw": "0.18.0",
"electron": "35.1.5",
"@electron/remote": "2.1.2",
"@types/cookie-parser": "1.4.8",
"@types/jsdom": "21.1.7",
"@types/better-sqlite3": "7.6.13",
"@types/safe-compare": "1.1.2",
"@types/debounce": "1.2.4",
"@types/xml2js": "0.4.14",
"@types/swagger-ui-express": "4.1.8",
"@types/cls-hooked": "4.3.9",
"@types/ejs": "3.1.5",
"@types/cheerio": "0.22.35",
"@types/multer": "1.4.12",
"@types/archiver": "6.0.3",
"@types/supertest": "6.0.3",
"@types/serve-favicon": "2.5.7",
"@types/compression": "1.7.5",
"@types/tmp": "0.2.6",
"@types/js-yaml": "4.0.9",
"@types/html": "1.0.4",
"@types/session-file-store": "1.2.5",
"@types/fs-extra": "11.0.4",
"@types/ini": "4.1.1",
"@types/turndown": "5.0.5",
"@types/sanitize-html": "2.15.0",
"@types/stream-throttle": "0.1.4",
"@types/mime-types": "2.1.4",
"@types/sax": "1.2.7",
"@types/express-session": "1.18.1",
"@types/escape-html": "1.0.4",
"@types/ws": "8.18.1"
}, },
"nx": { "nx": {
"targets": { "targets": {
@ -138,5 +134,5 @@
} }
} }
} }
} }
} }

View File

@ -4,6 +4,7 @@ import { fileURLToPath } from "url";
import express from "express"; import express from "express";
import { isDev, isElectron } from "../services/utils.js"; import { isDev, isElectron } from "../services/utils.js";
import type serveStatic from "serve-static"; import type serveStatic from "serve-static";
import proxy from "express-http-proxy";
const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<unknown, Record<string, unknown>>>) => { const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<unknown, Record<string, unknown>>>) => {
if (!isDev) { if (!isDev) {
@ -19,8 +20,8 @@ async function register(app: express.Application) {
const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), ".."); const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
if (isDev) { if (isDev) {
app.use(`/${assetPath}/app/doc_notes`, persistentCacheStatic(path.join(srcRoot, "public/app/doc_notes"))); app.use(`/${assetPath}/app/doc_notes`, persistentCacheStatic(path.join(srcRoot, "public/app/doc_notes")));
app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, "../../client/build"))); app.use(`/${assetPath}/app`, proxy("localhost:4200"));
app.use(`/${assetPath}/app-dist`, persistentCacheStatic(path.join(srcRoot, "../../client/build"))); app.use(`/${assetPath}/app-dist`, proxy("localhost:4200"));
app.use(`/${assetPath}/stylesheets`, persistentCacheStatic(path.join(srcRoot, "../../client/stylesheets"))); app.use(`/${assetPath}/stylesheets`, persistentCacheStatic(path.join(srcRoot, "../../client/stylesheets")));
app.use(`/${assetPath}/libraries`, persistentCacheStatic(path.join(srcRoot, "../../client/libraries"))); app.use(`/${assetPath}/libraries`, persistentCacheStatic(path.join(srcRoot, "../../client/libraries")));
} else { } else {
@ -31,7 +32,7 @@ async function register(app: express.Application) {
app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(srcRoot, "public/fonts"))); app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(srcRoot, "public/fonts")));
app.use(`/assets/vX/fonts`, express.static(path.join(srcRoot, "public/fonts"))); app.use(`/assets/vX/fonts`, express.static(path.join(srcRoot, "public/fonts")));
app.use(`/${assetPath}/images`, persistentCacheStatic(path.join(srcRoot, "..", "images"))); app.use(`/${assetPath}/images`, persistentCacheStatic(path.join(srcRoot, "..", "images")));
app.use(`/assets/vX/images`, express.static(path.join(srcRoot, "..", "images"))); app.use(`/assets/vX/images`, express.static(path.join(srcRoot, "..", "images")));
app.use(`/assets/vX/stylesheets`, express.static(path.join(srcRoot, "public/stylesheets"))); app.use(`/assets/vX/stylesheets`, express.static(path.join(srcRoot, "public/stylesheets")));
app.use(`/${assetPath}/libraries`, persistentCacheStatic(path.join(srcRoot, "public/libraries"))); app.use(`/${assetPath}/libraries`, persistentCacheStatic(path.join(srcRoot, "public/libraries")));
app.use(`/assets/vX/libraries`, express.static(path.join(srcRoot, "..", "libraries"))); app.use(`/assets/vX/libraries`, express.static(path.join(srcRoot, "..", "libraries")));

33
package-lock.json generated
View File

@ -316,6 +316,7 @@
"boxicons": "2.1.4", "boxicons": "2.1.4",
"codemirror": "5.65.19", "codemirror": "5.65.19",
"electron": "35.1.5", "electron": "35.1.5",
"express-http-proxy": "2.1.1",
"jquery": "3.7.1", "jquery": "3.7.1",
"jquery-hotkeys": "0.2.2", "jquery-hotkeys": "0.2.2",
"jquery.fancytree": "2.38.5", "jquery.fancytree": "2.38.5",
@ -14780,6 +14781,13 @@
"license": "MIT", "license": "MIT",
"optional": true "optional": true
}, },
"node_modules/es6-promise": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==",
"dev": true,
"license": "MIT"
},
"node_modules/es6-promise-pool": { "node_modules/es6-promise-pool": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/es6-promise-pool/-/es6-promise-pool-2.5.0.tgz", "resolved": "https://registry.npmjs.org/es6-promise-pool/-/es6-promise-pool-2.5.0.tgz",
@ -15349,6 +15357,31 @@
"url": "https://opencollective.com/express" "url": "https://opencollective.com/express"
} }
}, },
"node_modules/express-http-proxy": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/express-http-proxy/-/express-http-proxy-2.1.1.tgz",
"integrity": "sha512-4aRQRqDQU7qNPV5av0/hLcyc0guB9UP71nCYrQEYml7YphTo8tmWf3nDZWdTJMMjFikyz9xKXaURor7Chygdwg==",
"dev": true,
"license": "MIT",
"dependencies": {
"debug": "^3.0.1",
"es6-promise": "^4.1.1",
"raw-body": "^2.3.0"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/express-http-proxy/node_modules/debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/express-openid-connect": { "node_modules/express-openid-connect": {
"version": "2.18.0", "version": "2.18.0",
"resolved": "https://registry.npmjs.org/express-openid-connect/-/express-openid-connect-2.18.0.tgz", "resolved": "https://registry.npmjs.org/express-openid-connect/-/express-openid-connect-2.18.0.tgz",