From 2fef5e11edbaedf3a61f0836560c6787e929f9b2 Mon Sep 17 00:00:00 2001 From: Rizky Date: Mon, 16 Oct 2023 12:44:02 +0000 Subject: [PATCH] fix --- app/srv/exports.d.ts | 110 ++++++++++++++++++------------------- deploy.sh | 3 +- pkgs/core/index.ts | 4 +- pkgs/core/server/create.ts | 1 - pkgs/core/utils/parcel.ts | 3 +- 5 files changed, 61 insertions(+), 60 deletions(-) diff --git a/app/srv/exports.d.ts b/app/srv/exports.d.ts index 9ccc2273..1bb28505 100644 --- a/app/srv/exports.d.ts +++ b/app/srv/exports.d.ts @@ -6,26 +6,18 @@ declare module "app/srv/api/npm-size" { api(mode: "site" | "page", id: string): Promise; }; } -declare module "app/srv/api/auth/login" { - export const _: { - url: string; - api(username: string, password: string): Promise<{ - status: string; - session: any; - reason?: undefined; - } | { - status: string; - reason: string; - session?: undefined; - }>; - }; -} -declare module "app/srv/api/session" { +declare module "app/srv/api/auth/session" { export const _: { url: string; api(): Promise; }; } +declare module "app/srv/api/site-dts" { + export const _: { + url: string; + api(site_id: string): Promise; + }; +} declare module "app/srv/global" { import { site, user } from "dbgen"; import { ExecaChildProcess } from "execa"; @@ -52,18 +44,6 @@ declare module "app/srv/global" { }; }; } -declare module "app/srv/api/npm" { - export const _: { - url: string; - api(mode: "site" | "page", id: string): Promise; - }; -} -declare module "app/srv/api/local-ip" { - export const _: { - url: string; - api(): Promise; - }; -} declare module "app/web/src/utils/types/ws" { export type WS_MSG = WS_MSG_GET_COMP | WS_MSG_SET_COMP | WS_MSG_GET_PAGE | WS_MSG_SET_PAGE | WS_MSG_SV_LOCAL | WS_MSG_SVDIFF_REMOTE | WS_MSG_DIFF_LOCAL | WS_MSG_UNDO | WS_MSG_REDO | WS_MSG_NEW_COMP | WS_SITE_JS | { type: "ping"; @@ -606,10 +586,30 @@ declare module "app/srv/api/npm-bundle" { api(mode: "site" | "page", id: string): Promise; }; } -declare module "app/srv/api/site-dts" { +declare module "app/srv/api/npm" { export const _: { url: string; - api(site_id: string): Promise; + api(mode: "site" | "page", id: string): Promise; + }; +} +declare module "app/srv/api/auth/login" { + export const _: { + url: string; + api(username: string, password: string): Promise<{ + status: string; + session: any; + reason?: undefined; + } | { + status: string; + reason: string; + session?: undefined; + }>; + }; +} +declare module "app/srv/api/local-ip" { + export const _: { + url: string; + api(): Promise; }; } declare module "app/srv/exports" { @@ -620,33 +620,19 @@ declare module "app/srv/exports" { args: string[]; handler: Promise; }; - export const login: { - name: string; - url: string; - path: string; - args: string[]; - handler: Promise; - }; export const session: { name: string; url: string; path: string; args: any[]; - handler: Promise; + handler: Promise; }; - export const npm: { + export const site_dts: { name: string; url: string; path: string; args: string[]; - handler: Promise; - }; - export const local_ip: { - name: string; - url: string; - path: string; - args: any[]; - handler: Promise; + handler: Promise; }; export const npm_bundle: { name: string; @@ -655,12 +641,26 @@ declare module "app/srv/exports" { args: string[]; handler: Promise; }; - export const site_dts: { + export const npm: { name: string; url: string; path: string; args: string[]; - handler: Promise; + handler: Promise; + }; + export const login: { + name: string; + url: string; + path: string; + args: string[]; + handler: Promise; + }; + export const local_ip: { + name: string; + url: string; + path: string; + args: any[]; + handler: Promise; }; export const _upload: { name: string; @@ -676,13 +676,6 @@ declare module "app/srv/exports" { args: any[]; handler: Promise; }; - export const _file: { - name: string; - url: string; - path: string; - args: any[]; - handler: Promise; - }; export const _api_frm: { name: string; url: string; @@ -697,4 +690,11 @@ declare module "app/srv/exports" { args: string[]; handler: Promise; }; + export const _file: { + name: string; + url: string; + path: string; + args: any[]; + handler: Promise; + }; } diff --git a/deploy.sh b/deploy.sh index b599a084..e9644e63 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,4 +1,5 @@ git reset --hard git pull bun run build -bun run deploy \ No newline at end of file +bun run deploy +pm2 restart prasi:4550 \ No newline at end of file diff --git a/pkgs/core/index.ts b/pkgs/core/index.ts index fa080425..6acfac85 100644 --- a/pkgs/core/index.ts +++ b/pkgs/core/index.ts @@ -11,7 +11,6 @@ import { preparePrisma } from "./utils/prisma"; g.status = "init"; - await createLogger(); g.api = {}; g.mode = process.argv.includes("dev") ? "dev" : "prod"; @@ -31,9 +30,10 @@ if (g.db) { }); } -createServer(); await parcelBuild(); +await createServer(); await generateAPIFrm(); await prepareApiRoutes(); await prepareAPITypes(); + g.status = "ready"; diff --git a/pkgs/core/server/create.ts b/pkgs/core/server/create.ts index 4411585c..d53dc82a 100644 --- a/pkgs/core/server/create.ts +++ b/pkgs/core/server/create.ts @@ -16,7 +16,6 @@ const cache = { export type WSData = { url: URL }; export const createServer = async () => { - await waitUntil(() => g.status !== "init"); g.router = createRouter({ strictTrailingSlash: false }); for (const route of Object.values(g.api)) { diff --git a/pkgs/core/utils/parcel.ts b/pkgs/core/utils/parcel.ts index bd63330d..c7a39e6e 100644 --- a/pkgs/core/utils/parcel.ts +++ b/pkgs/core/utils/parcel.ts @@ -15,8 +15,9 @@ export const parcelBuild = async () => { "--dist-dir", dir.path(`app/static`), ]; - g.log.info(`Building web with parcel`); if (g.mode === "dev") { + g.log.info(`Building web with parcel`); + await new Promise((resolve) => { const parcel = spawn({ cmd: args,