Files
mini-loader/packages/server/src/router/router.secrets.ts
Morten Olsen 74a3d0f925 init
2024-01-11 11:17:27 +01:00

43 lines
976 B
TypeScript

import { z } from 'zod';
import { publicProcedure, router } from './router.utils.js';
import { findSecretsSchema, setSecretSchema } from '../repos/secrets/secrets.schemas.js';
const find = publicProcedure.input(findSecretsSchema).query(async ({ input, ctx }) => {
const { runtime } = ctx;
const { repos } = runtime;
const { secrets } = repos;
const result = await secrets.find(input);
return result;
});
const set = publicProcedure.input(setSecretSchema).mutation(async ({ input, ctx }) => {
const { runtime } = ctx;
const { repos } = runtime;
const { secrets } = repos;
await secrets.set(input);
});
const remove = publicProcedure
.input(
z.object({
id: z.string(),
}),
)
.mutation(async ({ input, ctx }) => {
const { runtime } = ctx;
const { repos } = runtime;
const { secrets } = repos;
await secrets.remove(input.id);
});
const secretsRouter = router({
find,
set,
remove,
});
export { secretsRouter };