Skip to content

Commit

Permalink
formatting the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Celesca committed Nov 7, 2024
1 parent c624b89 commit 4e9d5aa
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions src/controllers/skillController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,69 @@ import { prisma } from "../prisma"; // Prisma client

export const skillController = new Elysia({ prefix: "/skill" })

.post(
"/create",
async ({ body, error }) => {
const { skillName } = body;
.post(
"/create",
async ({ body, error }) => {
const { skillName } = body;

const existingSkill = await prisma.skills.findUnique({
where: { Skill_Name: skillName },
});
const existingSkill = await prisma.skills.findUnique({
where: { Skill_Name: skillName },
});

if (existingSkill) {
return error(409, "Skill already exists");
}
if (existingSkill) {
return error(409, "Skill already exists");
}

const newSkill = await prisma.skills.create({
data: {
Skill_Name: skillName,
const newSkill = await prisma.skills.create({
data: {
Skill_Name: skillName,
},
});

return newSkill;
},
});
{
body: t.Object({
skillName: t.String(),
}),
}
)

return newSkill;
},
{
body: t.Object({
skillName: t.String(),
}),
}
)
// Add skill to user
.post(
"/add-to-user",
async ({ body, error }) => {
const { userID, skillName } = body;

// Add skill to user
.post(
"/add-to-user",
async ({ body, error }) => {
const { userID, skillName } = body;
const skill = await prisma.skills.findUnique({
where: { Skill_Name: skillName },
});

const skill = await prisma.skills.findUnique({
where: { Skill_Name: skillName },
});
if (!skill) {
return error(404, "Skill not found");
}

if (!skill) {
return error(404, "Skill not found");
}
const user = await prisma.user.findUnique({
where: { UserID: userID },
});

const user = await prisma.user.findUnique({
where: { UserID: userID },
});
if (!user) {
return error(404, "User not found");
}

if (!user) {
return error(404, "User not found");
}
const userSkill = await prisma.userSkills.create({
data: {
UserID: userID,
Skill_ID: skill.Skill_ID,
},
});

const userSkill = await prisma.userSkills.create({
data: {
UserID: userID,
Skill_ID: skill.Skill_ID,
return userSkill;
},
});

return userSkill;
},
{
body: t.Object({
userID: t.String(),
skillName: t.String(),
}),
}
);
{
body: t.Object({
userID: t.String(),
skillName: t.String(),
}),
}
);

0 comments on commit 4e9d5aa

Please sign in to comment.