This repository has been archived on 2024-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
staxman-old/static/scripts/compose.ts

37 lines
701 B
TypeScript
Raw Normal View History

2023-11-30 09:14:32 +00:00
/**
* Checks if a specificied source is a valid arion-compose.nix file
* @param source Source to check
* @returns Result of the check
*/
export async function check_compose(source: string): Promise<CheckResult> {
const response = await fetch("/stack/_/check", {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "text/plain",
},
body: source
});
if (response.ok) {
return { ok: true };
} else {
return { ok: false, error: await response.json() };
}
}
export interface APIError {
/** Error code */
code: string;
/** Human readable error details */
message: string;
}
export type CheckResult = {
ok: true;
} | {
ok: false;
error: APIError;
}