ui/fix: Insane amount
This commit is contained in:
17
src/routes/sources/new.ts
Normal file
17
src/routes/sources/new.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { getUserDetails, uniqueName } from '$lib/common';
|
||||
import * as db from '$lib/database';
|
||||
import { ErrorHandler } from '$lib/database';
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
|
||||
export const post: RequestHandler = async (event) => {
|
||||
const { teamId, status, body } = await getUserDetails(event);
|
||||
if (status === 401) return { status, body };
|
||||
|
||||
const name = uniqueName();
|
||||
try {
|
||||
const { id } = await db.newSource({ teamId, name });
|
||||
return { status: 201, body: { id } };
|
||||
} catch (e) {
|
||||
return ErrorHandler(e);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user