Initialize client forms
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import type {
|
||||
BUN_SQLITE_WGUI_CLIENTS,
|
||||
BUN_SQLITE_WGUI_HOSTS,
|
||||
} from "@/db/types/db";
|
||||
import type { PagePropsType, PageQueryObject, TableType } from "@/src/types";
|
||||
import BunSQLite from "@moduletrace/bun-sqlite";
|
||||
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
|
||||
|
||||
const server: BunextPageServerFn<PagePropsType> = async ({
|
||||
req,
|
||||
url,
|
||||
query,
|
||||
}) => {
|
||||
const page_query = query as PageQueryObject;
|
||||
|
||||
const host_record_res = await BunSQLite.select<
|
||||
BUN_SQLITE_WGUI_HOSTS,
|
||||
TableType
|
||||
>({ table: "hosts", targetId: page_query.host_id });
|
||||
|
||||
const host_clients = await BunSQLite.select<
|
||||
BUN_SQLITE_WGUI_CLIENTS,
|
||||
TableType
|
||||
>({
|
||||
table: "clients",
|
||||
query: {
|
||||
query: {
|
||||
host_id: {
|
||||
value: page_query.host_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
props: {
|
||||
host: host_record_res.singleRes || null,
|
||||
clients: host_clients.payload || null,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default server;
|
||||
Reference in New Issue
Block a user