Skip to content

Commit 8736e66

Browse files
nchopraharitabh-z01
authored andcommitted
fix: circulary dep issue with trpc router creation
1 parent 346336c commit 8736e66

File tree

8 files changed

+22
-21
lines changed

8 files changed

+22
-21
lines changed

apps/desktop/src/trpc/router.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1-
import { initTRPC } from "@trpc/server";
2-
import superjson from "superjson";
31
import { z } from "zod";
42
import { vocabularyRouter } from "./routers/vocabulary";
53
import { transcriptionsRouter } from "./routers/transcriptions";
64
import { modelsRouter } from "./routers/models";
75
import { settingsRouter } from "./routers/settings";
86
import { updaterRouter } from "./routers/updater";
97
import { recordingRouter } from "./routers/recording";
10-
import type { Context } from "./context";
8+
import { createRouter, procedure } from "./trpc";
119

12-
const t = initTRPC.context<Context>().create({
13-
isServer: true,
14-
transformer: superjson,
15-
});
16-
17-
export const router = t.router({
10+
export const router = createRouter({
1811
// Test procedures
19-
greeting: t.procedure.input(z.object({ name: z.string() })).query((req) => {
12+
greeting: procedure.input(z.object({ name: z.string() })).query((req) => {
2013
return {
2114
text: `Hello ${req.input.name}`,
2215
timestamp: new Date(), // Date objects require transformation
2316
};
2417
}),
2518

2619
// Example of a simple procedure without input
27-
ping: t.procedure.query(() => {
20+
ping: procedure.query(() => {
2821
return {
2922
message: "pong",
3023
timestamp: new Date(),
3124
};
3225
}),
3326

3427
// Example mutation
35-
echo: t.procedure.input(z.object({ message: z.string() })).mutation((req) => {
28+
echo: procedure.input(z.object({ message: z.string() })).mutation((req) => {
3629
return {
3730
echo: req.input.message,
3831
timestamp: new Date(),
@@ -58,7 +51,4 @@ export const router = t.router({
5851
recording: recordingRouter,
5952
});
6053

61-
export const procedure = t.procedure;
62-
export const createRouter = t.router;
63-
6454
export type AppRouter = typeof router;

apps/desktop/src/trpc/routers/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { observable } from "@trpc/server/observable";
22
import { z } from "zod";
3-
import { createRouter, procedure } from "../router";
3+
import { createRouter, procedure } from "../trpc";
44
import type { Model, DownloadProgress } from "../../constants/models";
55
import type { DownloadedModel } from "../../db/schema";
66

apps/desktop/src/trpc/routers/recording.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { observable } from "@trpc/server/observable";
2-
import { createRouter, procedure } from "../router";
2+
import { createRouter, procedure } from "../trpc";
33
import type { RecordingState } from "../../types/recording";
44

55
export const recordingRouter = createRouter({

apps/desktop/src/trpc/routers/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { observable } from "@trpc/server/observable";
22
import { z } from "zod";
3-
import { createRouter, procedure } from "../router";
3+
import { createRouter, procedure } from "../trpc";
44

55
// FormatterConfig schema
66
const FormatterConfigSchema = z.object({

apps/desktop/src/trpc/routers/transcriptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { z } from "zod";
22
import { dialog } from "electron";
33
import * as fs from "node:fs";
44
import * as path from "node:path";
5-
import { createRouter, procedure } from "../router";
5+
import { createRouter, procedure } from "../trpc";
66
import {
77
getTranscriptions,
88
getTranscriptionById,

apps/desktop/src/trpc/routers/updater.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { observable } from "@trpc/server/observable";
22
import { z } from "zod";
3-
import { createRouter, procedure } from "../router";
3+
import { createRouter, procedure } from "../trpc";
44

55
// Download progress type from electron-updater
66
interface DownloadProgress {

apps/desktop/src/trpc/routers/vocabulary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { z } from "zod";
2-
import { createRouter, procedure } from "../router";
2+
import { createRouter, procedure } from "../trpc";
33
import {
44
getVocabulary,
55
getVocabularyById,

apps/desktop/src/trpc/trpc.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { initTRPC } from "@trpc/server";
2+
import superjson from "superjson";
3+
import type { Context } from "./context";
4+
5+
const t = initTRPC.context<Context>().create({
6+
isServer: true,
7+
transformer: superjson,
8+
});
9+
10+
export const procedure = t.procedure;
11+
export const createRouter = t.router;

0 commit comments

Comments
 (0)