@isthatuzii/create-nano-app
Version:
Desktop application scaffolding tool for the Nano Framework
42 lines (36 loc) • 1.11 kB
text/typescript
interface ApiResponse<T = any> {
success: boolean;
data?: T;
message?: string;
}
interface SystemInfo {
platform: string;
arch: string;
version: string;
}
interface NotificationData {
title: string;
message: string;
}
const functions = {
getSystemInfo: async (): Promise<ApiResponse<SystemInfo>> => {
const response = await fetch("/api/system-info");
return await response.json();
},
sendNotification: async (data: NotificationData): Promise<ApiResponse> => {
const response = await fetch("/api/notify", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json();
},
greet: async (name: string): Promise<ApiResponse<string>> => {
const params = name ? `?name=${encodeURIComponent(name)}` : "";
const response = await fetch(`/api/greet${params}`);
return await response.json();
}
};
export default functions;