fix route_cache
This commit is contained in:
parent
7d760885ec
commit
c73678a7b6
|
|
@ -0,0 +1,9 @@
|
|||
import { apiContext } from "service-srv";
|
||||
|
||||
export const _ = {
|
||||
url: "/local-files",
|
||||
async api() {
|
||||
const { req, res } = apiContext(this);
|
||||
return "This is local-files.ts";
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import { initFrontEnd } from "../ws/sync/code/parts/init/frontend";
|
|||
import { gzipAsync } from "../ws/sync/entity/zlib";
|
||||
import { ensureLib } from "../ws/sync/code/utlis/ensure-lib";
|
||||
import { ensureFiles } from "../ws/sync/code/utlis/ensure-files";
|
||||
import { g } from "utils/global";
|
||||
|
||||
export const _ = {
|
||||
url: "/prod/:site_id/**",
|
||||
|
|
@ -135,6 +136,11 @@ export const _ = {
|
|||
});
|
||||
}
|
||||
case "route": {
|
||||
if (!g.route_cache) g.route_cache = {};
|
||||
if (g.route_cache[site_id]) {
|
||||
return await responseCompressed(req, g.route_cache[site_id]);
|
||||
}
|
||||
|
||||
const site = await _db.site.findFirst({
|
||||
where: { id: site_id },
|
||||
select: {
|
||||
|
|
@ -180,16 +186,14 @@ export const _ = {
|
|||
select: { url: true, id: true },
|
||||
});
|
||||
|
||||
return await responseCompressed(
|
||||
req,
|
||||
JSON.stringify({
|
||||
g.route_cache[site_id] = JSON.stringify({
|
||||
site: { ...site, api_url },
|
||||
urls,
|
||||
layout: layout
|
||||
? { id: layout.id, root: layout.content_tree }
|
||||
: undefined,
|
||||
}) as any
|
||||
);
|
||||
});
|
||||
return await responseCompressed(req, g.route_cache[site_id]);
|
||||
}
|
||||
case "page": {
|
||||
const page_id = pathname.split("/").pop() as string;
|
||||
|
|
|
|||
|
|
@ -47,48 +47,53 @@ export const ensureFiles = async (path: string, id_site: string) => {
|
|||
"ulimit -c 0; tailwindcss --watch -i ./app/css/global.css -o ./app/css/build.css --minify",
|
||||
},
|
||||
dependencies: {
|
||||
"@babel/runtime": "^7.24.6",
|
||||
"@floating-ui/core": "^1.6.2",
|
||||
"@floating-ui/react": "^0.26.16",
|
||||
"@noble/hashes": "^1.4.0",
|
||||
"@floating-ui/react": "^0.26.12",
|
||||
"@hookform/resolvers": "^3.3.4",
|
||||
"@paralleldrive/cuid2": "^2.2.2",
|
||||
"@radix-ui/react-compose-refs": "^1.0.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
||||
"@prisma/client": "^5.13.0",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
||||
"@radix-ui/react-label": "^2.0.2",
|
||||
"@radix-ui/react-navigation-menu": "^1.1.4",
|
||||
"@radix-ui/react-navigation-menu": "^1.2.0",
|
||||
"@radix-ui/react-popover": "^1.0.7",
|
||||
"@radix-ui/react-slider": "^1.1.2",
|
||||
"@radix-ui/react-slot": "^1.0.2",
|
||||
"@radix-ui/react-switch": "^1.0.3",
|
||||
"@radix-ui/react-switch": "^1.1.0",
|
||||
"@radix-ui/react-tabs": "^1.0.4",
|
||||
"@types/file-saver": "^2.0.7",
|
||||
"@types/autosize": "^4.0.3",
|
||||
"@types/lodash.capitalize": "^4.2.9",
|
||||
"@types/lodash.get": "^4.4.9",
|
||||
"@types/react": "^18.3.2",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/react": "^18.2.65",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"@wojtekmaj/react-qr-svg": "^1.0.0",
|
||||
"any-date-parser": "^1.5.4",
|
||||
"chart.js": "^4.4.3",
|
||||
autosize: "^6.0.1",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
clsx: "^2.1.1",
|
||||
clsx: "^2.1.0",
|
||||
"date-fns": "^3.3.1",
|
||||
dayjs: "^1.11.11",
|
||||
"embla-carousel-react": "^8.1.1",
|
||||
exceljs: "^4.4.0",
|
||||
"embla-carousel-react": "^8.0.2",
|
||||
jsqr: "^1.4.0",
|
||||
"lodash.capitalize": "^4.2.1",
|
||||
"lodash.get": "^4.4.2",
|
||||
"lucide-react": "^0.378.0",
|
||||
"lucide-react": "^0.314.0",
|
||||
"next-themes": "^0.3.0",
|
||||
prisma: "^5.13.0",
|
||||
quill: "^2.0.2",
|
||||
"quill-delta": "^5.1.0",
|
||||
react: "^18.3.1",
|
||||
react: "^18.2.0",
|
||||
"react-arborist": "^3.4.0",
|
||||
"react-chartjs-2": "^5.2.0",
|
||||
"react-data-grid": "^7.0.0-beta.44",
|
||||
"react-day-picker": "^8.10.1",
|
||||
"react-resizable-panels": "^2.0.19",
|
||||
"react-data-grid": "^7.0.0-beta.43",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-hook-form": "^7.51.0",
|
||||
"react-resizable-panels": "^2.0.11",
|
||||
"react-webcam": "^7.2.0",
|
||||
"read-excel-file": "^5.7.1",
|
||||
sonner: "^1.4.41",
|
||||
tabbable: "^6.2.0",
|
||||
"tailwind-merge": "^2.3.0",
|
||||
xlsx: "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
|
||||
"tailwind-merge": "^2.2.1",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
uuid: "^9.0.1",
|
||||
"xlsx": "npm:@e965/xlsx@^0.20.2-released.0",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
}),
|
||||
{ mode: 777 }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { g } from "utils/global";
|
||||
import { apiContext } from "../server/api/api-ctx";
|
||||
import { execQuery } from "../utils/query";
|
||||
import { DBArg, execQuery } from "../utils/query";
|
||||
|
||||
export const _ = {
|
||||
url: "/_dbs/:action",
|
||||
|
|
@ -8,7 +8,16 @@ export const _ = {
|
|||
const { req, res } = apiContext(this);
|
||||
|
||||
try {
|
||||
const result = await execQuery(req.params, g._db);
|
||||
const params = req.params as DBArg;
|
||||
|
||||
if (
|
||||
params.table === "page" &&
|
||||
["create", "update", "delete"].includes(params.action)
|
||||
) {
|
||||
g.route_cache = {};
|
||||
}
|
||||
|
||||
const result = await execQuery(params, g._db);
|
||||
res.send(result);
|
||||
} catch (e: any) {
|
||||
res.sendStatus(500);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ type SingleRoute = {
|
|||
args: string[];
|
||||
fn: (...arg: any[]) => Promise<any>;
|
||||
path: string;
|
||||
raw: any
|
||||
raw: any;
|
||||
};
|
||||
|
||||
export const g = global as unknown as {
|
||||
|
|
@ -59,4 +59,5 @@ export const g = global as unknown as {
|
|||
Y: typeof Y;
|
||||
syncronize: typeof syncronize;
|
||||
static_cache: any;
|
||||
route_cache: Record<string, any>;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue