Update more path variables

This commit is contained in:
Rory& 2025-10-11 04:08:46 +02:00
parent e8c5c988bb
commit ef9b4f5be7
5 changed files with 14 additions and 14 deletions

Binary file not shown.

View File

@ -209,9 +209,9 @@ export async function initRateLimits(app: Router) {
...error, ...error,
}), }),
); );
app.use("/guilds/:id", rateLimit(routes.guild)); app.use("/guilds/:guild_id", rateLimit(routes.guild));
app.use("/webhooks/:id", rateLimit(routes.webhook)); app.use("/webhooks/:webhook_id", rateLimit(routes.webhook));
app.use("/channels/:id", rateLimit(routes.channel)); app.use("/channels/:channel_id", rateLimit(routes.channel));
app.use("/auth/login", rateLimit(routes.auth.login)); app.use("/auth/login", rateLimit(routes.auth.login));
app.use( app.use(
"/auth/register", "/auth/register",

View File

@ -37,7 +37,7 @@ router.get(
}), }),
async (req: Request, res: Response) => { async (req: Request, res: Response) => {
const app = await Application.findOneOrFail({ const app = await Application.findOneOrFail({
where: { id: req.params.id }, where: { id: req.params.id }, // ...huh? there's no ID in the path...
relations: ["bot", "owner"], relations: ["bot", "owner"],
select: { select: {
owner: Object.fromEntries( owner: Object.fromEntries(

View File

@ -23,7 +23,7 @@ import { Request, Response, Router } from "express";
const router: Router = Router({ mergeParams: true }); const router: Router = Router({ mergeParams: true });
router.get( router.get(
"/:id", "/:user_id",
route({ route({
responses: { responses: {
200: { 200: {
@ -35,25 +35,25 @@ router.get(
}, },
}), }),
async (req: Request, res: Response) => { async (req: Request, res: Response) => {
const { id } = req.params; const { user_id } = req.params;
const note = await Note.findOneOrFail({ const note = await Note.findOneOrFail({
where: { where: {
owner: { id: req.user_id }, owner: { id: req.user_id },
target: { id: id }, target: { id: user_id },
}, },
}); });
return res.json({ return res.json({
note: note?.content, note: note?.content,
note_user_id: id, note_user_id: user_id,
user_id: req.user_id, user_id: req.user_id,
}); });
}, },
); );
router.put( router.put(
"/:id", "/:user_id",
route({ route({
requestBody: "UserNoteUpdateSchema", requestBody: "UserNoteUpdateSchema",
responses: { responses: {
@ -64,9 +64,9 @@ router.put(
}, },
}), }),
async (req: Request, res: Response) => { async (req: Request, res: Response) => {
const { id } = req.params; const { user_id } = req.params;
const owner = await User.findOneOrFail({ where: { id: req.user_id } }); const owner = await User.findOneOrFail({ where: { id: req.user_id } });
const target = await User.findOneOrFail({ where: { id: id } }); //if noted user does not exist throw const target = await User.findOneOrFail({ where: { id: user_id } }); //if noted user does not exist throw
const { note } = req.body; const { note } = req.body;
if (note && note.length) { if (note && note.length) {

View File

@ -72,7 +72,7 @@ router.get(
); );
router.put( router.put(
"/:id", "/:user_id",
route({ route({
requestBody: "RelationshipPutSchema", requestBody: "RelationshipPutSchema",
responses: { responses: {
@ -90,7 +90,7 @@ router.put(
req, req,
res, res,
await User.findOneOrFail({ await User.findOneOrFail({
where: { id: req.params.id }, where: { id: req.params.user_id },
relations: ["relationships", "relationships.to"], relations: ["relationships", "relationships.to"],
select: userProjection, select: userProjection,
}), }),
@ -134,7 +134,7 @@ router.post(
); );
router.delete( router.delete(
"/:id", "/:user_id",
route({ route({
responses: { responses: {
204: {}, 204: {},