2024-02-21 01:47:37 +00:00
|
|
|
import { createPublisher } from '$lib/utils/db/publisherUtils.js';
|
2024-05-08 00:19:13 +00:00
|
|
|
import type { Publishers } from '$db/schema';
|
2024-02-21 01:47:37 +00:00
|
|
|
|
|
|
|
|
type PublisherCreate = {
|
|
|
|
|
publisher: Publishers;
|
|
|
|
|
externalId: string;
|
2024-05-08 00:19:13 +00:00
|
|
|
};
|
2024-02-21 01:47:37 +00:00
|
|
|
|
|
|
|
|
export async function POST({ request, locals }) {
|
|
|
|
|
const data: PublisherCreate = await request.json();
|
|
|
|
|
console.log('data', data);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
return await createPublisher(locals, data.publisher, data.externalId);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
return new Response('Could not create publisher', {
|
2024-05-08 00:19:13 +00:00
|
|
|
status: 500,
|
2024-02-21 01:47:37 +00:00
|
|
|
});
|
|
|
|
|
}
|
2024-05-08 00:19:13 +00:00
|
|
|
}
|