diff --git a/src/server/package.json b/src/server/package.json index 65317a6..446c9c8 100644 --- a/src/server/package.json +++ b/src/server/package.json @@ -8,6 +8,7 @@ }, "scripts": { "dev": "tsx watch --env-file=.env ./main.ts", + "dev:debug": "tsx --inspect-brk --env-file=.env ./main.ts", "build": "tsc", "postinstall": "pnpm db:generate", "check:type": "tsc --noEmit --skipLibCheck", diff --git a/src/server/trpc/trpc.ts b/src/server/trpc/trpc.ts index e92fc96..b2551eb 100644 --- a/src/server/trpc/trpc.ts +++ b/src/server/trpc/trpc.ts @@ -119,7 +119,7 @@ const isSystemAdmin = isUser.unstable_pipe(async (opts) => { }); export const systemAdminProcedure = t.procedure.use(prom).use(isSystemAdmin); -export const workspaceProcedure = protectProedure +export const workspaceProcedure = publicProcedure .input( z.object({ workspaceId: z.string().cuid2(), @@ -127,7 +127,7 @@ export const workspaceProcedure = protectProedure ) .use(createWorkspacePermissionMiddleware()); -export const workspaceAdminProcedure = protectProedure +export const workspaceAdminProcedure = publicProcedure .input( z.object({ workspaceId: z.string().cuid2(), @@ -135,7 +135,7 @@ export const workspaceAdminProcedure = protectProedure ) .use(createWorkspacePermissionMiddleware([ROLES.owner, ROLES.admin])); -export const workspaceOwnerProcedure = protectProedure +export const workspaceOwnerProcedure = publicProcedure .input( z.object({ workspaceId: z.string().cuid2(), @@ -145,6 +145,7 @@ export const workspaceOwnerProcedure = protectProedure /** * Create a trpc middleware which help user check workspace permission + * NOTE: this middleware already include user auth, so we dont need use it under protectProedure which will trigger user auth twice. */ function createWorkspacePermissionMiddleware(roles: ROLES[] = []) { return isUser.unstable_pipe(async (opts) => {