mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
init
This commit is contained in:
33
packages/server/src/router/router.runs.ts
Normal file
33
packages/server/src/router/router.runs.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createRunSchema, findRunsSchema } from '../repos/repos.js';
|
||||
import { publicProcedure, router } from './router.utils.js';
|
||||
|
||||
const create = publicProcedure.input(createRunSchema).mutation(async ({ input, ctx }) => {
|
||||
const { runtime } = ctx;
|
||||
const { repos } = runtime;
|
||||
const { runs } = repos;
|
||||
const id = await runs.create(input);
|
||||
return id;
|
||||
});
|
||||
|
||||
const find = publicProcedure.input(findRunsSchema).query(async ({ input, ctx }) => {
|
||||
const { runtime } = ctx;
|
||||
const { repos } = runtime;
|
||||
const { runs } = repos;
|
||||
const results = await runs.find(input);
|
||||
return results;
|
||||
});
|
||||
|
||||
const remove = publicProcedure.input(findRunsSchema).mutation(async ({ input, ctx }) => {
|
||||
const { runtime } = ctx;
|
||||
const { repos } = runtime;
|
||||
const { runs } = repos;
|
||||
await runs.remove(input);
|
||||
});
|
||||
|
||||
const runsRouter = router({
|
||||
create,
|
||||
find,
|
||||
remove,
|
||||
});
|
||||
|
||||
export { runsRouter };
|
||||
Reference in New Issue
Block a user