mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 12:21:57 +00:00
feat: Initial of the sdk
This commit is contained in:
38
compat/properties.ts
Normal file
38
compat/properties.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { YAML } from "../dependencies.ts";
|
||||
import { exists } from "../exists.ts";
|
||||
import { ResultType, Properties, ExpectedExports, Effects } from "../types.ts";
|
||||
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const asResult = (result: any) => ({ result: result as Properties })
|
||||
const noPropertiesFound: ResultType<Properties> = {
|
||||
result: {
|
||||
version: 2,
|
||||
data: {
|
||||
"Not Ready": {
|
||||
type: "string",
|
||||
value: "Could not find properties. The service might still be starting",
|
||||
qr: false,
|
||||
copyable: false,
|
||||
masked: false,
|
||||
description: "Fallback Message When Properties could not be found"
|
||||
}
|
||||
}
|
||||
}
|
||||
} as const
|
||||
/**
|
||||
* Default will pull from a file (start9/stats.yaml) expected to be made on the main volume
|
||||
* @param effects
|
||||
* @returns
|
||||
*/
|
||||
export const properties: ExpectedExports.properties = async (
|
||||
effects: Effects,
|
||||
) => {
|
||||
if (await exists(effects, { path: "start9/stats.yaml", volumeId: "main" }) === false) {
|
||||
return noPropertiesFound;
|
||||
}
|
||||
return await effects.readFile({
|
||||
path: "start9/stats.yaml",
|
||||
volumeId: "main",
|
||||
}).then(YAML.parse).then(asResult)
|
||||
};
|
||||
Reference in New Issue
Block a user