From be6a9e36afc9ab540201ffa7b2b33247b8554003 Mon Sep 17 00:00:00 2001 From: Rizky Date: Tue, 14 May 2024 12:50:25 +0700 Subject: [PATCH] fix --- pkgs/api/_notif.ts | 8 +++++++- pkgs/utils/deploy.ts | 10 ++++++++++ pkgs/utils/global.ts | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pkgs/api/_notif.ts b/pkgs/api/_notif.ts index 8ee54f8..3be3952 100644 --- a/pkgs/api/_notif.ts +++ b/pkgs/api/_notif.ts @@ -1,5 +1,6 @@ import { Database } from "bun:sqlite"; import admin from "firebase-admin"; +import { listAsync } from "fs-jetpack"; import { apiContext } from "service-srv"; import { dir } from "utils/dir"; @@ -14,12 +15,17 @@ export const _ = { | { type: "send"; id: string; body: string; title: string; data?: any } ) { const { req } = apiContext(this); + + if (action === "list") { + return await listAsync(dir("public")); + } + if (!g.firebaseInit) { g.firebaseInit = true; try { g.firebase = admin.initializeApp({ - credential: admin.credential.cert(dir("firebase-admin.json")), + credential: admin.credential.cert(dir("public/firebase-admin.json")), }); g.notif = { db: new Database(dir(`${g.datadir}/notif.sqlite`)), diff --git a/pkgs/utils/deploy.ts b/pkgs/utils/deploy.ts index 81e2fe7..b934a29 100644 --- a/pkgs/utils/deploy.ts +++ b/pkgs/utils/deploy.ts @@ -1,5 +1,6 @@ import { dirAsync, + exists, existsAsync, read, removeAsync, @@ -37,6 +38,15 @@ export const deploy = { ); if (g.deploy.gz) { + if (exists(dir("public"))) { + await removeAsync(dir("public")); + if (g.deploy.gz.public) { + await dirAsync(dir("public")); + for (const [k, v] of Object.entries(g.deploy.gz.public)) { + await writeAsync(dir(`public/${k}`), v); + } + } + } for (const page of g.deploy.gz.layouts) { if (page.is_default_layout) { g.deploy.layout = page.content_tree; diff --git a/pkgs/utils/global.ts b/pkgs/utils/global.ts index 687e57b..ac1dcd8 100644 --- a/pkgs/utils/global.ts +++ b/pkgs/utils/global.ts @@ -88,8 +88,9 @@ export const g = global as unknown as { gz: null | { layouts: SinglePage[]; pages: SinglePage[]; - site: {}; + site: any; comps: { id: string; content_tree: true }[]; + public: Record; code: { server: Record; site: Record;