Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions api/src/routes/artists/[slug]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TABLES } from '../../../../../shared/config';
import { handlePostgrestQuery, supabase } from '$lib/server/supabase';
import type { Artist } from '../../../../../shared/types/core';
import type { ArtistHydrated } from '../../../../../shared/types/hydrated';
import { json } from '@sveltejs/kit';

export async function GET({ params }) {
return handlePostgrestQuery<ArtistHydrated>(
Expand All @@ -12,8 +13,9 @@ export async function GET({ params }) {

export async function PATCH({ request, params }) {
const body: Partial<Artist> = await request.json();
return handlePostgrestQuery<Artist>(
async () => await supabase.from(TABLES.artists).update(body).eq('id', params.slug),
{ errorMessage: 'Failed to update artist details' }
);
const { error } = await supabase.from(TABLES.artists).update(body).eq('id', params.slug);
if (error) {
return json({ error: 'Failed to update artist details' }, { status: 500 });
}
return json({ success: true });
}
12 changes: 12 additions & 0 deletions api/src/routes/releases/[slug]/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { handlePostgrestQuery, supabase } from '$lib/server/supabase';
import { json } from '@sveltejs/kit';
import { TABLES } from '../../../../../shared/config';
import type { ReleaseHydrated } from '../../../../../shared/types/hydrated';

Expand All @@ -8,3 +9,14 @@ export async function GET({ params }) {
{ errorMessage: 'Failed to fetch release' }
);
}

export async function DELETE({ params }) {
const { error } = await supabase.from(TABLES.releases).delete().eq('id', params.slug);

if (error) {
console.error('Error deleting release:', error);
return json({ error: 'Failed to delete release' }, { status: 500 });
}

return json({ success: true });
}
11 changes: 5 additions & 6 deletions api/src/routes/tracks/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { json, type RequestHandler } from '@sveltejs/kit';
import { supabase } from '$lib/server/supabase';
import { pinata } from '$lib/server/pinata';
import { TABLES } from '../../../../shared/config';
import { formFieldNames } from '../../../../shared/types/forms';
import { parseFile } from 'music-metadata';
import fs from 'fs/promises';

Expand All @@ -26,11 +25,11 @@ export const POST: RequestHandler = async ({ request }) => {
try {
const formData = await request.formData();

const file = formData.get(formFieldNames.track.file) as File;
const artistId = formData.get(formFieldNames.track.artistID) as string;
const title = formData.get(formFieldNames.track.title) as string;
const artistName = formData.get(formFieldNames.track.artistName) as string;
const artistGroup = formData.get(formFieldNames.track.artistGroup) as string;
const file = formData.get('file') as File;
const artistId = formData.get('artistId') as string;
const title = formData.get('title') as string;
const artistName = formData.get('artistName') as string;
const artistGroup = formData.get('artistGroup') as string;

if (!file || !artistId || !title) {
return json({ error: 'Missing required fields' }, { status: 400 });
Expand Down
14 changes: 14 additions & 0 deletions api/src/routes/tracks/[slug]/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { supabase } from '$lib/server/supabase';
import { json, type RequestHandler } from '@sveltejs/kit';
import { TABLES } from '../../../../../shared/config';

export const DELETE: RequestHandler = async ({ params }) => {
const { error } = await supabase.from(TABLES.tracks).delete().eq('id', params.slug);

if (error) {
console.error('Error deleting track:', error);
return json({ error: 'Failed to delete track' }, { status: 500 });
}

return json({ success: true });
};
42 changes: 15 additions & 27 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading