refactor: clean code
This commit is contained in:
@@ -5,7 +5,7 @@ import { getPocketBase } from "@/repository/pocketbase";
|
||||
export const notifyTest = async (channel: string) => {
|
||||
const pb = getPocketBase();
|
||||
|
||||
const resp = await pb.send("/api/notify/test", {
|
||||
const resp = await pb.send<BaseResponse>("/api/notify/test", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getPocketBase } from "@/repository/pocketbase";
|
||||
export const get = async () => {
|
||||
const pb = getPocketBase();
|
||||
|
||||
const resp = await pb.send("/api/statistics/get", {
|
||||
const resp = await pb.send<BaseResponse<Statistics>>("/api/statistics/get", {
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
@@ -14,5 +14,5 @@ export const get = async () => {
|
||||
throw new ClientResponseError({ status: resp.code, response: resp, data: {} });
|
||||
}
|
||||
|
||||
return resp.data as Statistics;
|
||||
return resp;
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { ClientResponseError, type RecordSubscription } from "pocketbase";
|
||||
import { ClientResponseError } from "pocketbase";
|
||||
|
||||
import { WORKFLOW_TRIGGERS, type WorkflowModel } from "@/domain/workflow";
|
||||
import { WORKFLOW_TRIGGERS } from "@/domain/workflow";
|
||||
import { getPocketBase } from "@/repository/pocketbase";
|
||||
|
||||
export const run = async (id: string) => {
|
||||
const pb = getPocketBase();
|
||||
|
||||
const resp = await pb.send("/api/workflow/run", {
|
||||
const resp = await pb.send<BaseResponse>("/api/workflow/run", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -23,15 +23,3 @@ export const run = async (id: string) => {
|
||||
|
||||
return resp;
|
||||
};
|
||||
|
||||
export const subscribe = async (id: string, cb: (e: RecordSubscription<WorkflowModel>) => void) => {
|
||||
const pb = getPocketBase();
|
||||
|
||||
return pb.collection("workflow").subscribe(id, cb);
|
||||
};
|
||||
|
||||
export const unsubscribe = async (id: string) => {
|
||||
const pb = getPocketBase();
|
||||
|
||||
return pb.collection("workflow").unsubscribe(id);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user