mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-04-02 05:23:21 +00:00
feat: Initial of the sdk
This commit is contained in:
29
compat/getConfig.ts
Normal file
29
compat/getConfig.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
import { YAML } from "../dependencies.ts";
|
||||
import { matches } from "../dependencies.ts";
|
||||
import { ExpectedExports } from "../types.ts";
|
||||
import { ConfigSpec } from "../types.ts";
|
||||
|
||||
const { any, string, dictionary } = matches;
|
||||
|
||||
const matchConfig = dictionary([string, any]);
|
||||
|
||||
export const getConfig = (spec: ConfigSpec): ExpectedExports.getConfig => async (effects) => {
|
||||
const config = await effects
|
||||
.readFile({
|
||||
path: "start9/config.yaml",
|
||||
volumeId: "main",
|
||||
})
|
||||
.then((x) => YAML.parse(x))
|
||||
.then((x) => matchConfig.unsafeCast(x))
|
||||
.catch((e) => {
|
||||
effects.info(`Got error ${e} while trying to read the config`);
|
||||
return undefined;
|
||||
});
|
||||
return {
|
||||
result: {
|
||||
config,
|
||||
spec,
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user