@@ -4,44 +4,47 @@ import { prisma } from "~/db.server";
44import { createLoaderPATApiRoute } from "~/services/routeBuilders/apiBuilder.server" ;
55
66// Identity-only: lists projects across the caller's orgs, so no authorization gate.
7- export const loader = createLoaderPATApiRoute ( { } , async ( { authentication } ) => {
8- const projects = await prisma . project . findMany ( {
9- where : {
10- organization : {
11- deletedAt : null ,
12- members : {
13- some : {
14- userId : authentication . userId ,
7+ export const loader = createLoaderPATApiRoute (
8+ { identityOnly : true } ,
9+ async ( { authentication } ) => {
10+ const projects = await prisma . project . findMany ( {
11+ where : {
12+ organization : {
13+ deletedAt : null ,
14+ members : {
15+ some : {
16+ userId : authentication . userId ,
17+ } ,
1518 } ,
1619 } ,
20+ version : "V3" ,
21+ deletedAt : null ,
22+ } ,
23+ include : {
24+ organization : true ,
25+ defaultWorkerGroup : { select : { name : true } } ,
1726 } ,
18- version : "V3" ,
19- deletedAt : null ,
20- } ,
21- include : {
22- organization : true ,
23- defaultWorkerGroup : { select : { name : true } } ,
24- } ,
25- } ) ;
27+ } ) ;
2628
27- if ( ! projects ) {
28- return json ( { error : "Projects not found" } , { status : 404 } ) ;
29- }
29+ if ( ! projects ) {
30+ return json ( { error : "Projects not found" } , { status : 404 } ) ;
31+ }
3032
31- const result : GetProjectsResponseBody = projects . map ( ( project ) => ( {
32- id : project . id ,
33- externalRef : project . externalRef ,
34- name : project . name ,
35- slug : project . slug ,
36- createdAt : project . createdAt ,
37- defaultRegion : project . defaultWorkerGroup ?. name ?? null ,
38- organization : {
39- id : project . organization . id ,
40- title : project . organization . title ,
41- slug : project . organization . slug ,
42- createdAt : project . organization . createdAt ,
43- } ,
44- } ) ) ;
33+ const result : GetProjectsResponseBody = projects . map ( ( project ) => ( {
34+ id : project . id ,
35+ externalRef : project . externalRef ,
36+ name : project . name ,
37+ slug : project . slug ,
38+ createdAt : project . createdAt ,
39+ defaultRegion : project . defaultWorkerGroup ?. name ?? null ,
40+ organization : {
41+ id : project . organization . id ,
42+ title : project . organization . title ,
43+ slug : project . organization . slug ,
44+ createdAt : project . organization . createdAt ,
45+ } ,
46+ } ) ) ;
4547
46- return json ( result ) ;
47- } ) ;
48+ return json ( result ) ;
49+ }
50+ ) ;
0 commit comments