This commit is contained in:
Rizky 2023-10-16 12:44:02 +00:00
parent d4b30272c3
commit 2fef5e11ed
5 changed files with 61 additions and 60 deletions

110
app/srv/exports.d.ts vendored
View File

@ -6,26 +6,18 @@ declare module "app/srv/api/npm-size" {
api(mode: "site" | "page", id: string): Promise<string>;
};
}
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<any>;
};
}
declare module "app/srv/api/site-dts" {
export const _: {
url: string;
api(site_id: string): Promise<string>;
};
}
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<void>;
};
}
declare module "app/srv/api/local-ip" {
export const _: {
url: string;
api(): Promise<string[]>;
};
}
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<any>;
};
}
declare module "app/srv/api/site-dts" {
declare module "app/srv/api/npm" {
export const _: {
url: string;
api(site_id: string): Promise<string>;
api(mode: "site" | "page", id: string): Promise<void>;
};
}
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<string[]>;
};
}
declare module "app/srv/exports" {
@ -620,33 +620,19 @@ declare module "app/srv/exports" {
args: string[];
handler: Promise<typeof import("app/srv/api/npm-size")>;
};
export const login: {
name: string;
url: string;
path: string;
args: string[];
handler: Promise<typeof import("app/srv/api/auth/login")>;
};
export const session: {
name: string;
url: string;
path: string;
args: any[];
handler: Promise<typeof import("app/srv/api/session")>;
handler: Promise<typeof import("app/srv/api/auth/session")>;
};
export const npm: {
export const site_dts: {
name: string;
url: string;
path: string;
args: string[];
handler: Promise<typeof import("app/srv/api/npm")>;
};
export const local_ip: {
name: string;
url: string;
path: string;
args: any[];
handler: Promise<typeof import("app/srv/api/local-ip")>;
handler: Promise<typeof import("app/srv/api/site-dts")>;
};
export const npm_bundle: {
name: string;
@ -655,12 +641,26 @@ declare module "app/srv/exports" {
args: string[];
handler: Promise<typeof import("app/srv/api/npm-bundle")>;
};
export const site_dts: {
export const npm: {
name: string;
url: string;
path: string;
args: string[];
handler: Promise<typeof import("app/srv/api/site-dts")>;
handler: Promise<typeof import("app/srv/api/npm")>;
};
export const login: {
name: string;
url: string;
path: string;
args: string[];
handler: Promise<typeof import("app/srv/api/auth/login")>;
};
export const local_ip: {
name: string;
url: string;
path: string;
args: any[];
handler: Promise<typeof import("app/srv/api/local-ip")>;
};
export const _upload: {
name: string;
@ -676,13 +676,6 @@ declare module "app/srv/exports" {
args: any[];
handler: Promise<any>;
};
export const _file: {
name: string;
url: string;
path: string;
args: any[];
handler: Promise<any>;
};
export const _api_frm: {
name: string;
url: string;
@ -697,4 +690,11 @@ declare module "app/srv/exports" {
args: string[];
handler: Promise<any>;
};
export const _file: {
name: string;
url: string;
path: string;
args: any[];
handler: Promise<any>;
};
}

View File

@ -1,4 +1,5 @@
git reset --hard
git pull
bun run build
bun run deploy
bun run deploy
pm2 restart prasi:4550

View File

@ -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";

View File

@ -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)) {

View File

@ -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<void>((resolve) => {
const parcel = spawn({
cmd: args,