-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathfs.ts
More file actions
52 lines (45 loc) · 1.58 KB
/
fs.ts
File metadata and controls
52 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { container } from "../../di/container";
import { MAIN_TOKENS } from "../../di/tokens";
import {
fileExistsOutput,
listRepoFilesInput,
listRepoFilesOutput,
readAbsoluteFileInput,
readRepoFileInput,
readRepoFileOutput,
writeRepoFileInput,
} from "../../services/fs/schemas";
import type { FsService } from "../../services/fs/service";
import { publicProcedure, router } from "../trpc";
const getService = () => container.get<FsService>(MAIN_TOKENS.FsService);
export const fsRouter = router({
listRepoFiles: publicProcedure
.input(listRepoFilesInput)
.output(listRepoFilesOutput)
.query(({ input }) =>
getService().listRepoFiles(input.repoPath, input.query, input.limit),
),
readRepoFile: publicProcedure
.input(readRepoFileInput)
.output(readRepoFileOutput)
.query(({ input }) =>
getService().readRepoFile(input.repoPath, input.filePath),
),
readAbsoluteFile: publicProcedure
.input(readAbsoluteFileInput)
.output(readRepoFileOutput)
.query(({ input }) => getService().readAbsoluteFile(input.filePath)),
fileExists: publicProcedure
.input(readAbsoluteFileInput)
.output(fileExistsOutput)
.query(({ input }) => getService().fileExists(input.filePath)),
readFileAsBase64: publicProcedure
.input(readAbsoluteFileInput)
.output(readRepoFileOutput)
.query(({ input }) => getService().readFileAsBase64(input.filePath)),
writeRepoFile: publicProcedure
.input(writeRepoFileInput)
.mutation(({ input }) =>
getService().writeRepoFile(input.repoPath, input.filePath, input.content),
),
});