More events team nonsense
This commit is contained in:
@@ -3,13 +3,12 @@ import { jsonError } from "../../common.js";
|
||||
export async function onRequestDelete(context: RequestContext) {
|
||||
const path = decodeURIComponent(context.params.id as string);
|
||||
|
||||
if (typeof path !== "string") return jsonError("Invalid path", 400);
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"DELETE FROM short_links WHERE path = ? AND user = ?;",
|
||||
)
|
||||
.bind(path, context.data.current_user.id)
|
||||
.run();
|
||||
await context.data.prisma.shortLink.delete({
|
||||
where: {
|
||||
path,
|
||||
user: context.data.current_user.id,
|
||||
},
|
||||
});
|
||||
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
@@ -39,15 +38,15 @@ export async function onRequestPatch(context: RequestContext) {
|
||||
|
||||
if (path.length > 256) return jsonError("Path is too long", 400);
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"UPDATE short_links SET path = ? WHERE path = ? AND user = ?;",
|
||||
)
|
||||
.bind(
|
||||
await context.data.prisma.shortLink.update({
|
||||
data: {
|
||||
path,
|
||||
decodeURIComponent(context.params.id as string),
|
||||
context.data.current_user.id,
|
||||
)
|
||||
.run();
|
||||
},
|
||||
where: {
|
||||
path: decodeURIComponent(context.params.id as string),
|
||||
user: context.data.current_user.id,
|
||||
},
|
||||
});
|
||||
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
|
||||
Reference in New Issue
Block a user