Skip to content

Commit

Permalink
hotfix 02
Browse files Browse the repository at this point in the history
  • Loading branch information
Moonded committed Aug 27, 2024
1 parent 5e59f53 commit 1a21701
Show file tree
Hide file tree
Showing 14 changed files with 393 additions and 318 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.ts",
"type": "module",
"scripts": {
"dev": "prisma migrate deploy & node --no-warnings --import=tsx --env-file=.env --watch src/index.ts --watch src/swaggerDocument.yml"
"dev": "prisma migrate deploy & node --no-warnings --import=tsx --env-file=.env --watch src/index.ts"
},
"author": "Sebastian 'Moonded' Danielzik",
"license": "ISC",
Expand Down
22 changes: 13 additions & 9 deletions src/api/bot/commands/quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ import { prisma, getLatestRelease } from "utils";
const router = express.Router();

router.post("/", async (req, res) => {
const data = req.body as { quote: string; responder: string };

try {
const quote = await prisma.quotes.create({
data: {
quote: data.quote,
responder: data.responder,
},
});
return res.send(quote);
const data = req.body as { quote: string; responder: string };

try {
const quote = await prisma.quotes.create({
data: {
quote: data.quote,
responder: data.responder,
},
});
return res.send(quote);
} catch (e) {
return res.sendStatus(500);
}
} catch (e) {
return res.sendStatus(500);
}
Expand Down
28 changes: 16 additions & 12 deletions src/api/bot/commands/trivia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import { prisma } from "utils";
const router = express.Router();

router.post("/", async (req, res) => {
const data = req.body as {
question: string;
answer: string;
};

try {
const newTrivia = await prisma.trivia.create({
data: {
question: data.question,
answer: data.answer,
},
});
return res.send(newTrivia);
const data = req.body as {
question: string;
answer: string;
};

try {
const newTrivia = await prisma.trivia.create({
data: {
question: data.question,
answer: data.answer,
},
});
return res.send(newTrivia);
} catch (e) {
return res.sendStatus(500);
}
} catch (e) {
return res.sendStatus(500);
}
Expand Down
84 changes: 44 additions & 40 deletions src/api/bot/commands/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,51 @@ import { prisma } from "utils";
const router = express.Router();

router.put("/", async (req, res) => {
const data = req.body as {
user: string;
id: string;
nexusmods: string;
github: string;
theme: string;
description: string;
style: string;
timezone: string;
country: string;
};

try {
const user = await prisma.user.upsert({
where: {
userid: data.id,
},
update: {
userid: data.id,
user: data.user,
nexusmods: data.nexusmods,
github: data.github,
theme: data.theme,
description: data.description,
style: data.style,
timezone: data.timezone,
country: data.country,
},
create: {
userid: data.id,
user: data.user,
nexusmods: data.nexusmods,
github: data.github,
theme: data.theme,
description: data.description,
style: data.style,
timezone: data.timezone,
country: data.country,
},
});
return res.send(user);
const data = req.body as {
user: string;
id: string;
nexusmods: string;
github: string;
theme: string;
description: string;
style: string;
timezone: string;
country: string;
};

try {
const user = await prisma.user.upsert({
where: {
userid: data.id,
},
update: {
userid: data.id,
user: data.user,
nexusmods: data.nexusmods,
github: data.github,
theme: data.theme,
description: data.description,
style: data.style,
timezone: data.timezone,
country: data.country,
},
create: {
userid: data.id,
user: data.user,
nexusmods: data.nexusmods,
github: data.github,
theme: data.theme,
description: data.description,
style: data.style,
timezone: data.timezone,
country: data.country,
},
});
return res.send(user);
} catch (e) {
return res.sendStatus(500);
}
} catch (e) {
return res.sendStatus(500);
}
Expand Down
40 changes: 22 additions & 18 deletions src/api/bot/dev/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@ import { prisma } from "utils";
const router = express.Router();

router.get("/", async (req, res) => {
const data = req.query.q as {
id: string;
};
try {
const data = req.query.q as {
id: string;
};

console.log(data);
console.log(data);

if (!data) {
// FIND ALL USERS
const User = await prisma.user.findMany();
if (!data) {
// FIND ALL USERS
const User = await prisma.user.findMany();

return res.send(User);
} else {
// FIND USER BY ID
try {
const User = await prisma.user.findUnique({
where: {
userid: data.id,
},
});
return res.send(User);
} catch (e) {
return res.sendStatus(500);
} else {
// FIND USER BY ID
try {
const User = await prisma.user.findUnique({
where: {
userid: data.id,
},
});
return res.send(User);
} catch (e) {
return res.sendStatus(500);
}
}
} catch (e) {
return res.sendStatus(500);
}
});

Expand Down
Loading

0 comments on commit 1a21701

Please sign in to comment.