diff --git a/.gitignore b/.gitignore index be9534f..32cc058 100644 --- a/.gitignore +++ b/.gitignore @@ -174,4 +174,5 @@ dist # Finder (MacOS) folder config .DS_Store -app \ No newline at end of file +app/db +app/srv \ No newline at end of file diff --git a/app/db/.gitignore b/app/db/.gitignore deleted file mode 100644 index 11ddd8d..0000000 --- a/app/db/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -# Keep environment variables out of version control -.env diff --git a/app/db/db.ts b/app/db/db.ts deleted file mode 100644 index fcab163..0000000 --- a/app/db/db.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "@prisma/client"; diff --git a/app/db/package.json b/app/db/package.json deleted file mode 100644 index 5e06651..0000000 --- a/app/db/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "db", - "dependencies": { - "@prisma/client": "5.3.1", - "prisma": "^5.3.1" - } -} diff --git a/app/db/test.mjs b/app/db/test.mjs deleted file mode 100644 index 4bb6251..0000000 --- a/app/db/test.mjs +++ /dev/null @@ -1 +0,0 @@ -import { PrismaClient } from "@prisma/client"; diff --git a/app/srv/exports.d.ts b/app/srv/exports.d.ts deleted file mode 100644 index 1e5e69f..0000000 --- a/app/srv/exports.d.ts +++ /dev/null @@ -1,291 +0,0 @@ -declare module "pkgs/api/_prasi" { - export const _: { - url: string; - api(): Promise; - }; - export const getApiEntry: () => any; -} -declare module "pkgs/api/_web" { - export const _: { - url: string; - api(id: string, _: string): Promise; - }; -} -declare module "pkgs/utils/dir" { - export const dir: (path: string) => string; -} -declare module "app/db/db" { - -} -declare module "pkgs/utils/global" { - import { Logger } from "pino"; - import { RadixRouter } from "radix3"; - import { Database } from "bun:sqlite"; - type SingleRoute = { - url: string; - args: string[]; - fn: (...arg: any[]) => Promise; - path: string; - }; - export const g: { - - dburl: string; - datadir: string; - mode: "dev" | "prod"; - - log: Logger; - firebaseInit: boolean; - firebase: admin.app.App; - notif: { - db: Database; - }; - api: Record; - domains: null | Record; - web: Record; - cacheKey: number; - cache: null | { - site: { - id: string; - name: string; - favicon: string; - domain: string; - id_user: string; - created_at: Date | null; - id_org: string | null; - updated_at: Date | null; - responsive: string; - } | null; - pages: { - id: string; - name: string; - url: string; - content_tree: any; - id_site: string; - created_at: Date | null; - js_compiled: string | null; - js: string | null; - updated_at: Date | null; - id_folder: string | null; - is_deleted: boolean; - }[]; - npm: { - site: Record; - pages: Record>; - }; - comps: { - id: string; - name: string; - content_tree: any; - created_at: Date | null; - updated_at: Date | null; - type: string; - id_component_group: string | null; - props: any; - }[]; - }; - }>; - router: RadixRouter; - port: number; - frm: { - js: string; - etag: string; - }; - }; -} -declare module "pkgs/server/load-web" { - export const loadWeb: () => Promise; - export const loadWebCache: (site_id: string, ts: number | string) => Promise; -} -declare module "pkgs/api/_deploy" { - export const _: { - url: string; - api(action: ({ - type: "check"; - } | { - type: "db-update"; - url: string; - } | { - type: "db-pull"; - } | { - type: "restart"; - } | { - type: "domain-add"; - domain: string; - } | { - type: "domain-del"; - domain: string; - } | { - type: "deploy-del"; - ts: string; - } | { - type: "deploy"; - dlurl: string; - } | { - type: "deploy-status"; - } | { - type: "redeploy"; - ts: string; - }) & { - id_site: string; - }): Promise<"ok" | { - now: number; - current: any; - deploys: any; - domains: any; - db: { - url: any; - }; - } | { - now: number; - current: any; - deploys: any; - domains?: undefined; - db?: undefined; - }>; - }; - export const downloadFile: (url: string, filePath: string, progress?: (rec: number, total: number) => void) => Promise; -} -declare module "pkgs/api/_upload" { - export const _: { - url: string; - api(body: any): Promise; - }; -} -declare module "pkgs/server/serve-web" { - export const serveWeb: (url: URL, req: Request) => Promise; - export const generateIndexHtml: (base_url: string, site_id: string) => string; -} -declare module "pkgs/api/_file" { - export const _: { - url: string; - api(): Promise; - }; -} -declare module "pkgs/api/_notif" { - export const _: { - url: string; - api(action: string, data: { - type: "register"; - token: string; - id: string; - } | { - type: "send"; - id: string; - body: string; - title: string; - data?: any; - }): Promise<{ - result: string; - error?: undefined; - totalDevice?: undefined; - } | { - error: string; - result?: undefined; - totalDevice?: undefined; - } | { - result: string; - totalDevice: any; - error?: undefined; - }>; - }; -} -declare module "pkgs/api/_api_frm" { - export const _: { - url: string; - api(): Promise; - }; -} -declare module "pkgs/api/_proxy" { - export const _: { - url: string; - api(arg: { - url: string; - method: "POST" | "GET"; - headers: any; - body: any; - }): Promise; - }; -} -declare module "pkgs/api/_dbs" { - export const _: { - url: string; - api(dbName: any, action?: string): Promise; - }; -} -declare module "app/srv/exports" { - export const _web: { - name: string; - url: string; - path: string; - args: string[]; - handler: Promise; - }; - export const _deploy: { - name: string; - url: string; - path: string; - args: string[]; - handler: Promise; - }; - export const _upload: { - name: string; - url: string; - path: string; - args: string[]; - handler: Promise; - }; - export const _prasi: { - name: string; - url: string; - path: string; - args: any[]; - handler: Promise; - }; - export const _file: { - name: string; - url: string; - path: string; - args: any[]; - handler: Promise; - }; - export const _notif: { - name: string; - url: string; - path: string; - args: string[]; - handler: Promise; - }; - export const _api_frm: { - name: string; - url: string; - path: string; - args: any[]; - handler: Promise; - }; - export const _proxy: { - name: string; - url: string; - path: string; - args: string[]; - handler: Promise; - }; - export const _dbs: { - name: string; - url: string; - path: string; - args: string[]; - handler: Promise; - }; -} diff --git a/app/srv/exports.ts b/app/srv/exports.ts deleted file mode 100644 index 4c1c2ba..0000000 --- a/app/srv/exports.ts +++ /dev/null @@ -1,63 +0,0 @@ -export const _web = { - name: "_web", - url: "/_web/:id/**", - path: "app/srv/api/_web.ts", - args: ["id","_"], - handler: import("../../pkgs/api/_web") -} -export const _deploy = { - name: "_deploy", - url: "/_deploy", - path: "app/srv/api/_deploy.ts", - args: ["action"], - handler: import("../../pkgs/api/_deploy") -} -export const _upload = { - name: "_upload", - url: "/_upload", - path: "app/srv/api/_upload.ts", - args: ["body"], - handler: import("../../pkgs/api/_upload") -} -export const _prasi = { - name: "_prasi", - url: "/_prasi/**", - path: "app/srv/api/_prasi.ts", - args: [], - handler: import("../../pkgs/api/_prasi") -} -export const _file = { - name: "_file", - url: "/_file/**", - path: "app/srv/api/_file.ts", - args: [], - handler: import("../../pkgs/api/_file") -} -export const _notif = { - name: "_notif", - url: "/_notif/:action/:token", - path: "app/srv/api/_notif.ts", - args: ["action","data"], - handler: import("../../pkgs/api/_notif") -} -export const _api_frm = { - name: "_api_frm", - url: "/_api_frm", - path: "app/srv/api/_api_frm.ts", - args: [], - handler: import("../../pkgs/api/_api_frm") -} -export const _proxy = { - name: "_proxy", - url: "/_proxy/*", - path: "app/srv/api/_proxy.ts", - args: ["arg"], - handler: import("../../pkgs/api/_proxy") -} -export const _dbs = { - name: "_dbs", - url: "/_dbs/:dbName/:action", - path: "app/srv/api/_dbs.ts", - args: ["dbName","action"], - handler: import("../../pkgs/api/_dbs") -} \ No newline at end of file diff --git a/pkgs/index.ts b/pkgs/index.ts index 58d49f1..3558ccc 100644 --- a/pkgs/index.ts +++ b/pkgs/index.ts @@ -11,6 +11,7 @@ import { createLogger } from "./utils/logger"; import { dirAsync, existsAsync } from "fs-jetpack"; import { dir } from "utils/dir"; import { $ } from "execa"; + g.mode = process.argv.includes("dev") ? "dev" : "prod"; g.datadir = g.mode === "prod" ? "../data" : ".data";