Skip to content

Commit

Permalink
Merge pull request #147 from josefaidt/chore/admin-command-api-routes
Browse files Browse the repository at this point in the history
chore(app): command API routes to only be callable by admins
  • Loading branch information
josefaidt authored Jul 20, 2022
2 parents a08a34d + 987a6f1 commit be3839f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"sourceType": "module"
},
"env": {
"browser": false,
"browser": true,
"node": true
},
"plugins": [
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Command.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
const id = registration?.id
async function onDeleteCommand(event) {
async function onDeleteCommand() {
deleteCommandStep = DELETE_STEP_DELETING
let data
try {
const response = await fetch(`/api/commands/delete/${id}`, {
const response = await fetch(`/api/admin/commands/delete/${id}`, {
method: 'DELETE',
body: JSON.stringify({ id }),
})
Expand Down
6 changes: 4 additions & 2 deletions src/routes/admin/index.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
<script lang="ts">
import { Content, Grid, Row, Column, Button } from 'carbon-components-svelte'
import * as store from '$lib/store'
import Command from '$lib/Command.svelte'
Expand All @@ -10,7 +10,9 @@
isSyncing = true
let data
try {
const response = await fetch('/api/commands/sync', { method: 'POST' })
const response = await fetch('/api/admin/commands/sync', {
method: 'POST',
})
if (response.ok && response.status === 200) {
data = await response.json()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { commands } from '$discord/client'

/** @type {import('@sveltejs/kit').RequestHandler} */
export async function del({ request, params }) {
export async function del({ request }) {
const body = await request.json()
const unregistered = await commands.unregister(body.id)

Expand Down
File renamed without changes.

0 comments on commit be3839f

Please sign in to comment.