mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-28 11:49:39 -05:00
update client
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
{
|
||||
"name": "monitor_client",
|
||||
"name": "@monitor/client",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"main": "dist/lib.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "^4.29.19",
|
||||
"axios": "^1.4.0"
|
||||
|
||||
@@ -19,8 +19,8 @@ export type LoginOptions = {
|
||||
secret?: string;
|
||||
};
|
||||
|
||||
export async function MonitorClient(base_url: string) {
|
||||
let jwt = "";
|
||||
export function MonitorClient(base_url: string, token?: string) {
|
||||
let jwt = token ?? "";
|
||||
|
||||
const auth = async <R extends AuthRequest>(
|
||||
request: R
|
||||
@@ -40,12 +40,14 @@ export async function MonitorClient(base_url: string) {
|
||||
params: { username: options.username, password: options.password },
|
||||
});
|
||||
jwt = res.jwt;
|
||||
return res.jwt;
|
||||
} else if (options.secret) {
|
||||
const res = await auth({
|
||||
type: "LoginWithSecret",
|
||||
params: { username: options.username, secret: options.secret },
|
||||
});
|
||||
jwt = res.jwt;
|
||||
return res.jwt;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"target": "ESNext",
|
||||
"module": "CommonJS",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"outDir": "build"
|
||||
"outDir": "dist",
|
||||
"declaration": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user