mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
* sdk tweaks * switch back to deeppartial * WIP, update comments * reinstall chesterton's fence --------- Co-authored-by: Aiden McClelland <me@drbonez.dev>
28 lines
977 B
TypeScript
28 lines
977 B
TypeScript
import { ExposedStorePaths } from "../../../base/lib/types"
|
|
import {
|
|
PathBuilder,
|
|
extractJsonPath,
|
|
pathBuilder,
|
|
} from "../../../base/lib/util/PathBuilder"
|
|
|
|
/**
|
|
* @description Use this function to determine which Store values to expose and make available to other services running on StartOS. Store values not exposed here will be kept private. Use the type safe pathBuilder to traverse your Store's structure.
|
|
* @example
|
|
* In this example, we expose the hypothetical Store values "adminPassword" and "nameLastUpdatedAt".
|
|
*
|
|
* ```
|
|
export const exposedStore = setupExposeStore<Store>((pathBuilder) => [
|
|
pathBuilder.adminPassword
|
|
pathBuilder.nameLastUpdatedAt,
|
|
])
|
|
* ```
|
|
*/
|
|
export const setupExposeStore = <Store extends Record<string, any>>(
|
|
fn: (pathBuilder: PathBuilder<Store>) => PathBuilder<Store, any>[],
|
|
) => {
|
|
return fn(pathBuilder<Store>()).map(
|
|
(x) => extractJsonPath(x) as string,
|
|
) as ExposedStorePaths
|
|
}
|
|
export { ExposedStorePaths }
|