-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from ruru-m07/main
Refactor code and fix bugs close #19
- Loading branch information
Showing
78 changed files
with
17,590 additions
and
3,391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
DATABASE_URL="postgresql://ruru-m07:qNUHdS2pTj4z@ep-crimson-rain-a18rwix8-pooler.ap-southeast-1.aws.neon.tech/cocola_DB?sslmode=require&pgbouncer=true" | ||
DIRECT_URL="postgresql://ruru-m07:qNUHdS2pTj4z@ep-crimson-rain-a18rwix8.ap-southeast-1.aws.neon.tech/cocola_DB?sslmode=require" | ||
MONGODB_URL='mongodb+srv://cocola:[email protected]/cocola?retryWrites=true&w=majority' | ||
|
||
AUTH_SECRET=2e1d8c3da161567ec57e934a6f3fb35b | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"workbench.colorTheme": "Tokyo Night", | ||
"workbench.startupEditor": "none", | ||
"files.autoSave": "afterDelay", | ||
"glassit.alpha": 245, | ||
"glassit.force_sway": true, | ||
"workbench.iconTheme": "material-icon-theme", | ||
"[typescriptreact]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[javascriptreact]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"hediet.vscode-drawio.resizeImages": null, | ||
"[html]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"tabnine.experimentalAutoImports": true, | ||
"[jsonc]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"javascript.updateImportsOnFileMove.enabled": "always", | ||
"typescript.updateImportsOnFileMove.enabled": "always", | ||
"[less]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[css]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"glassit.step": 500, | ||
"bitoAI.codeCompletion.enableCommentToCode": true, | ||
"bitoAI.codeCompletion.enableAutoCompletion": true, | ||
"cmake.options.statusBarVisibility": "hidden" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
|
||
export const findImageUrlByUserName = async (userName: string) => { | ||
const user = await db.user.findUnique({ | ||
where: { | ||
username: userName, | ||
}, | ||
}); | ||
let image = user?.image; | ||
return image; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
|
||
export const fetchrepo = async (username: string, repository: string) => { | ||
if (!username && !repository) { | ||
return { error: "Invalid user!" }; | ||
} | ||
|
||
const repo = await db.repository.findFirst({ | ||
where: { | ||
name: repository, | ||
author: username, | ||
}, | ||
}); | ||
console.log(repo) | ||
return { repo: repo }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
|
||
export const create = async () => { | ||
const commitresult = await db.commit.create({ | ||
data: { | ||
commitId: "3", | ||
title: "Initial Commit", | ||
description: " Initial Commit of the repository", | ||
branch: "master", | ||
repositoryId: "65c339bbf67715e59d92337d", | ||
}, | ||
}); | ||
return { | ||
success: "create commit Successfully! 🎉", | ||
commitresult: commitresult, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"use server"; | ||
|
||
import * as z from "zod"; | ||
|
||
import { db } from "@/lib/db"; | ||
import { RepoSchema } from "@/schemas"; | ||
import { User } from "@prisma/client"; | ||
|
||
export const create = async ( | ||
values: z.infer<typeof RepoSchema>, | ||
user: User | ||
) => { | ||
const validatedFields = RepoSchema.safeParse(values); | ||
|
||
if (!validatedFields.success) { | ||
return { error: "Invalid fields!" }; | ||
} | ||
|
||
const { name, description, visibility, branch } = validatedFields.data; | ||
|
||
if (!user?.username) { | ||
return { error: "Invalid user!" }; | ||
} | ||
const existingRepo = await db.repository.findFirst({ | ||
where: { | ||
name: name, | ||
author: user?.username, | ||
}, | ||
}); | ||
|
||
console.log(existingRepo); | ||
|
||
if (existingRepo) { | ||
return { error: "Repository already exist with this name!" }; | ||
} | ||
|
||
if (user?.username && user?.id) { | ||
const repository = await db.repository.create({ | ||
data: { | ||
name: name, | ||
description: description, | ||
Visibility: visibility, | ||
author: user?.username, | ||
authorId: user?.id, | ||
DefualtBranch: branch, | ||
}, | ||
}); | ||
|
||
await db.branch.create({ | ||
data: { | ||
name: branch, | ||
repositoryId: repository.id, | ||
}, | ||
}); | ||
return { success: "Repository create Successfully! 🎉" }; | ||
} else { | ||
return { error: "Invalid user!" }; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
import { User } from "@prisma/client"; | ||
|
||
export const fetchRepo = async ( | ||
username: string, | ||
repository: string, | ||
user?: User | null | ||
) => { | ||
if (!username || !repository) { | ||
return { error: "Invalid user or repository!" }; | ||
} | ||
|
||
let repo; | ||
|
||
if (user?.username === username) { | ||
repo = await db.repository.findFirst({ | ||
where: { | ||
name: repository, | ||
author: username, | ||
}, | ||
}); | ||
} else { | ||
repo = await db.repository.findFirst({ | ||
where: { | ||
name: repository, | ||
author: username, | ||
Visibility: "public", | ||
}, | ||
}); | ||
} | ||
|
||
if (!repo) { | ||
return { error: "Repository not found!", statuscode: 404 }; | ||
} | ||
|
||
const branches = await db.branch.findMany({ | ||
where: { | ||
repositoryId: repo.id, | ||
}, | ||
}); | ||
|
||
return { repo, branchCount: branches.length }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
|
||
export const whoami = async (currentUser: any) => { | ||
const { ...userdata } = await db.user.findUnique({ | ||
where: { email: currentUser?.email as string | undefined }, | ||
select: { | ||
id: true, | ||
name: true, | ||
email: true, | ||
emailVerified: true, | ||
image: true, | ||
password: false, | ||
role: true, | ||
isTwoFactorEnabled: true, | ||
username: true, | ||
lname: true, | ||
displayName: true, | ||
profileImage: true, | ||
coverImage: true, | ||
bio: true, | ||
dateOfBirth: true, | ||
gender: true, | ||
phone: true, | ||
street: true, | ||
city: true, | ||
state: true, | ||
zipcode: true, | ||
country: true, | ||
facebook: true, | ||
twitter: true, | ||
instagram: true, | ||
linkedin: true, | ||
website: true, | ||
createdAt: true, | ||
updatedAt: true, | ||
accounts: true, | ||
twoFactorConfirmation: true, | ||
_count: true, | ||
}, | ||
}); | ||
|
||
return { userdata }; | ||
}; |
Oops, something went wrong.
3cd88f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cocola – ./
cocola-git-main-rurus-projects-df5b2283.vercel.app
cocola.vercel.app
cocola-rurus-projects-df5b2283.vercel.app