Skip to content

Commit

Permalink
Update eslint and added dlete event sql query
Browse files Browse the repository at this point in the history
  • Loading branch information
Draikth committed Jul 24, 2024
1 parent 06a020a commit 3515d89
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 161 deletions.
17 changes: 17 additions & 0 deletions database/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ export const getEvent = cache(async (sessionToken: string, eventId: number) => {
return event;
});

export const deleteEvent = cache(
async (sessionToken: string, eventId: number) => {
const [event] = await sql<SiteEvent[]>`
DELETE FROM events USING sessions
WHERE
events.user_id = sessions.user_id
AND events.id = ${eventId}
AND sessions.token = ${sessionToken}
AND sessions.expiry_timestamp > now()
RETURNING
events.*
`;

return event;
},
);

export const getEventsInsecure = cache(async () => {
const events = await sql<SiteEvent[]>`
SELECT
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@types/node": "^20.14.10",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"eslint-config-upleveled": "^8.6.3",
"eslint-config-upleveled": "^8.6.13",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"libpg-query": "^16.2.0",
Expand Down
Loading

0 comments on commit 3515d89

Please sign in to comment.