diff --git a/apps/api-hono/src/trpc/index.export.ts b/apps/api-hono/src/trpc/index.export.ts deleted file mode 100644 index 060326e..0000000 --- a/apps/api-hono/src/trpc/index.export.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { appRouter } from '@/trpc/index' - -export type AppRouter = typeof appRouter diff --git a/apps/api-hono/src/trpc/shared-export/trpc.ts b/apps/api-hono/src/trpc/shared-export/trpc.ts new file mode 100644 index 0000000..161e47f --- /dev/null +++ b/apps/api-hono/src/trpc/shared-export/trpc.ts @@ -0,0 +1,3 @@ +import type { appRouter } from '@/trpc' + +export type AppRouter = typeof appRouter diff --git a/apps/api-hono/tsup.config.ts b/apps/api-hono/tsup.config.ts index 31b5716..56f3cb9 100644 --- a/apps/api-hono/tsup.config.ts +++ b/apps/api-hono/tsup.config.ts @@ -1,10 +1,11 @@ import { defineConfig } from 'tsup' export default defineConfig({ - entry: ['src/trpc/index.export.ts'], - format: ['cjs', 'esm'], - dts: true, + entry: ['src/trpc/shared-export/trpc.ts'], + dts: { + only: true, + }, splitting: false, - sourcemap: true, clean: true, + outDir: '../app/app/generated/trpc', }) diff --git a/apps/app/app/generated/trpc/trpc.d.ts b/apps/app/app/generated/trpc/trpc.d.ts new file mode 100644 index 0000000..6ce5896 --- /dev/null +++ b/apps/app/app/generated/trpc/trpc.d.ts @@ -0,0 +1,158 @@ +import * as _trpc_server from '@trpc/server'; +import * as _trpc_server_unstable_core_do_not_import from '@trpc/server/unstable-core-do-not-import'; + +declare const appRouter: _trpc_server_unstable_core_do_not_import.BuiltRouter<{ + ctx: { + req: Request; + resHeaders: Headers; + user: { + id: string; + email: string; + createdAt: Date; + updatedAt: Date; + }; + } | { + req: Request; + resHeaders: Headers; + user: null; + }; + meta: object; + errorShape: { + data: { + code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_KEY; + httpStatus: number; + path?: string; + stack?: string; + }; + message: string; + code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_NUMBER; + }; + transformer: false; +}, _trpc_server_unstable_core_do_not_import.DecorateCreateRouterOptions<{ + example: _trpc_server_unstable_core_do_not_import.BuiltRouter<{ + ctx: { + req: Request; + resHeaders: Headers; + user: { + id: string; + email: string; + createdAt: Date; + updatedAt: Date; + }; + } | { + req: Request; + resHeaders: Headers; + user: null; + }; + meta: object; + errorShape: { + data: { + code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_KEY; + httpStatus: number; + path?: string; + stack?: string; + }; + message: string; + code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_NUMBER; + }; + transformer: false; + }, { + hello: _trpc_server.TRPCQueryProcedure<{ + input: void; + output: string; + }>; + list: _trpc_server.TRPCQueryProcedure<{ + input: void; + output: { + id: string; + name: string; + }[]; + }>; + create: _trpc_server.TRPCMutationProcedure<{ + input: { + name: string; + }; + output: { + id: string; + name: string; + }; + }>; + }>; + auth: _trpc_server_unstable_core_do_not_import.BuiltRouter<{ + ctx: { + req: Request; + resHeaders: Headers; + user: { + id: string; + email: string; + createdAt: Date; + updatedAt: Date; + }; + } | { + req: Request; + resHeaders: Headers; + user: null; + }; + meta: object; + errorShape: { + data: { + code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_KEY; + httpStatus: number; + path?: string; + stack?: string; + }; + message: string; + code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_NUMBER; + }; + transformer: false; + }, { + isSignedIn: _trpc_server.TRPCQueryProcedure<{ + input: void; + output: { + isSignedIn: boolean; + }; + }>; + signupWithEmail: _trpc_server.TRPCMutationProcedure<{ + input: { + email: string; + }; + output: { + ok: true; + }; + }>; + signInWithEmail: _trpc_server.TRPCMutationProcedure<{ + input: { + email: string; + }; + output: { + ok: boolean; + }; + }>; + signInVerification: _trpc_server.TRPCMutationProcedure<{ + input: { + token: string; + }; + output: { + ok: true; + } | { + ok: false; + attemptExceeded: boolean; + }; + }>; + signUpVerification: _trpc_server.TRPCMutationProcedure<{ + input: { + token: string; + }; + output: { + ok: true; + } | { + ok: false; + attemptExceeded: boolean; + }; + }>; + }>; +}>>; + +type AppRouter = typeof appRouter; + +export type { AppRouter }; diff --git a/apps/app/app/lib/trpcClient.ts b/apps/app/app/lib/trpcClient.ts index c7d97b2..f2753e7 100644 --- a/apps/app/app/lib/trpcClient.ts +++ b/apps/app/app/lib/trpcClient.ts @@ -1,3 +1,3 @@ +import type { AppRouter } from '@/generated/trpc/trpc' import { createTRPCReact } from '@trpc/react-query' -import type { AppRouter } from '../../types/trpc' export const trpc = createTRPCReact() diff --git a/apps/app/types/trpc.d.ts b/apps/app/types/trpc.d.ts deleted file mode 100644 index a10a6c2..0000000 --- a/apps/app/types/trpc.d.ts +++ /dev/null @@ -1,177 +0,0 @@ -import type * as _trpc_server from '@trpc/server' -import type * as _trpc_server_unstable_core_do_not_import from '@trpc/server/unstable-core-do-not-import' - -declare const appRouter: _trpc_server_unstable_core_do_not_import.BuiltRouter< - { - ctx: - | { - req: Request - resHeaders: Headers - user: { - id: string - email: string - createdAt: Date - updatedAt: Date - } - } - | { - req: Request - resHeaders: Headers - user: null - } - meta: object - errorShape: { - data: { - code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_KEY - httpStatus: number - path?: string - stack?: string - } - message: string - code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_NUMBER - } - transformer: false - }, - _trpc_server_unstable_core_do_not_import.DecorateCreateRouterOptions<{ - example: _trpc_server_unstable_core_do_not_import.BuiltRouter< - { - ctx: - | { - req: Request - resHeaders: Headers - user: { - id: string - email: string - createdAt: Date - updatedAt: Date - } - } - | { - req: Request - resHeaders: Headers - user: null - } - meta: object - errorShape: { - data: { - code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_KEY - httpStatus: number - path?: string - stack?: string - } - message: string - code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_NUMBER - } - transformer: false - }, - { - hello: _trpc_server.TRPCQueryProcedure<{ - input: undefined - output: string - }> - list: _trpc_server.TRPCQueryProcedure<{ - input: undefined - output: { - id: string - name: string - }[] - }> - create: _trpc_server.TRPCMutationProcedure<{ - input: { - name: string - } - output: { - id: string - name: string - } - }> - } - > - auth: _trpc_server_unstable_core_do_not_import.BuiltRouter< - { - ctx: - | { - req: Request - resHeaders: Headers - user: { - id: string - email: string - createdAt: Date - updatedAt: Date - } - } - | { - req: Request - resHeaders: Headers - user: null - } - meta: object - errorShape: { - data: { - code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_KEY - httpStatus: number - path?: string - stack?: string - } - message: string - code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_NUMBER - } - transformer: false - }, - { - isSignedIn: _trpc_server.TRPCQueryProcedure<{ - input: undefined - output: { - isSignedIn: boolean - } - }> - signupWithEmail: _trpc_server.TRPCMutationProcedure<{ - input: { - email: string - } - output: { - ok: true - } - }> - signInWithEmail: _trpc_server.TRPCMutationProcedure<{ - input: { - email: string - } - output: { - ok: boolean - } - }> - signInVerification: _trpc_server.TRPCMutationProcedure<{ - input: { - token: string - } - output: - | { - ok: true - } - | { - ok: false - attemptExceeded: boolean - } - }> - signUpVerification: _trpc_server.TRPCMutationProcedure<{ - input: { - token: string - } - output: - | { - ok: true - } - | { - ok: false - attemptExceeded: boolean - } - }> - } - > - }> -> - -type AppRouter = typeof appRouter - -export type { AppRouter }