@@ -34,45 +34,45 @@ router.post("/create", async (req,res): Promise<any> => {
3434 return res . status ( 401 ) . json ( { error : "Unauthorized" } ) ;
3535 }
3636
37- // const isproject = await prismaClient.project.findUnique({
38- // where:{
39- // name: zreq.data?.name
40- // }
41- // })
42-
43- // if(isproject){
44- // return res.status(401).json({ error: "Project already Exist" });
45- // }
46-
47- // const project = await prismaClient.project.create({
48- // data:{
49- // name: zreq.data?.name || "",
50- // githubUrl: zreq.data?.githubUrl || "",
51- // userToProject: {
52- // create:{
53- // userId: user?.id
54- // }
55- // }
56- // }
57- // })
58-
59- // const memory = await createMemory(`${project.id}_${zreq.data?.name}` || "")
60- // const pipe = await createPipe(`${project.id}_${zreq.data?.name}` || "", memory.name || "")
61- // const questionagent = await prismaClient.questionAgent.create({
62- // data:{
63- // memoryName: memory.name,
64- // pipename: pipe.name,
65- // pipeDescription: pipe.description,
66- // projectId: project.id
67- // }
68- // })
37+ const isproject = await prismaClient . project . findUnique ( {
38+ where :{
39+ name : zreq . data ?. name
40+ }
41+ } )
42+
43+ if ( isproject ) {
44+ return res . status ( 401 ) . json ( { error : "Project already Exist" } ) ;
45+ }
46+
47+ const project = await prismaClient . project . create ( {
48+ data :{
49+ name : zreq . data ?. name || "" ,
50+ githubUrl : zreq . data ?. githubUrl || "" ,
51+ userToProject : {
52+ create :{
53+ userId : user ?. id
54+ }
55+ }
56+ }
57+ } )
58+
59+ const memory = await createMemory ( `${ project . id } _${ zreq . data ?. name } ` || "" )
60+ const pipe = await createPipe ( `${ project . id } _${ zreq . data ?. name } ` || "" , memory . name || "" )
61+ const questionagent = await prismaClient . questionAgent . create ( {
62+ data :{
63+ memoryName : memory . name ,
64+ pipename : pipe . name ,
65+ pipeDescription : pipe . description ,
66+ projectId : project . id
67+ }
68+ } )
6969
70- // await indexGithubRepo(project.id,zreq.data?.githubUrl || '', questionagent.memoryName || "", zreq.data?.githubToken || '')
71- // await pollCommits(project.id)
72- // await pollPullRequests(project.id)
70+ await indexGithubRepo ( project . id , zreq . data ?. githubUrl || '' , questionagent . memoryName || "" , zreq . data ?. githubToken || '' )
71+ await pollCommits ( project . id )
72+ await pollPullRequests ( project . id )
73+
74+ res . json ( { message : 'Success' , project} )
7375
74- //res.json({message: 'Success',project})
75- res . json ( { message : 'Success' } )
7676} )
7777
7878
0 commit comments