1+ import { websitesApi } from '@databuddy/auth' ;
12import { and , chQuery , eq , isNull , websites } from '@databuddy/db' ;
23import { createDrizzleCache , redis } from '@databuddy/redis' ;
34import { TRPCError } from '@trpc/server' ;
@@ -88,7 +89,7 @@ export const websitesRouter = createTRPCRouter({
8889 ) ;
8990 return ctx . db . query . websites . findMany ( {
9091 where,
91- orderBy : ( websites , { desc } ) => [ desc ( websites . createdAt ) ] ,
92+ orderBy : ( table , { desc } ) => [ desc ( table . createdAt ) ] ,
9293 } ) ;
9394 } ,
9495 } ) ;
@@ -102,15 +103,15 @@ export const websitesRouter = createTRPCRouter({
102103 key : cacheKey ,
103104 ttl : 60 ,
104105 tables : [ 'websites' ] ,
105- queryFn : async ( ) => authorizeWebsiteAccess ( ctx , input . id , 'read' ) ,
106+ queryFn : ( ) => authorizeWebsiteAccess ( ctx , input . id , 'read' ) ,
106107 } ) ;
107108 } ) ,
108109
109110 create : protectedProcedure
110111 . input ( createWebsiteSchema )
111112 . mutation ( async ( { ctx, input } ) => {
112113 if ( input . organizationId ) {
113- const { success } = await ctx . auth . api . hasPermission ( {
114+ const { success } = await websitesApi . hasPermission ( {
114115 headers : ctx . headers ,
115116 body : { permissions : { website : [ 'create' ] } } ,
116117 } ) ;
@@ -254,14 +255,10 @@ export const websitesRouter = createTRPCRouter({
254255 transfer : protectedProcedure
255256 . input ( transferWebsiteSchema )
256257 . mutation ( async ( { ctx, input } ) => {
257- const website = await authorizeWebsiteAccess (
258- ctx ,
259- input . websiteId ,
260- 'update'
261- ) ;
258+ await authorizeWebsiteAccess ( ctx , input . websiteId , 'update' ) ;
262259
263260 if ( input . organizationId ) {
264- const { success } = await ctx . auth . api . hasPermission ( {
261+ const { success } = await websitesApi . hasPermission ( {
265262 headers : ctx . headers ,
266263 body : { permissions : { website : [ 'create' ] } } ,
267264 } ) ;
0 commit comments