mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: update API routes for paste options and recent pastes
This commit is contained in:
@@ -3,9 +3,11 @@ import type { LayoutServerLoad } from './$types';
|
||||
export const load: LayoutServerLoad = async ({ fetch, url }) => {
|
||||
try {
|
||||
const res = await fetch('/api/auth/info');
|
||||
const pasteOptionsRes = await fetch('/api/paste/info');
|
||||
const options = await res.json();
|
||||
return { options, url: url.href };
|
||||
const pasteOptions = await pasteOptionsRes.json();
|
||||
return { options, pasteOptions, url: url.href };
|
||||
} catch {
|
||||
return { options: null, url: url.href };
|
||||
return { options: null, pasteOptions: null, url: url.href };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, url }) => {
|
||||
try {
|
||||
const optionsRes = await fetch('/api/paste/create/options');
|
||||
const optionsRes = await fetch('/api/paste/info');
|
||||
const authInfo = await fetch('/api/auth/info');
|
||||
const options = await optionsRes.json();
|
||||
const auth = await authInfo.json();
|
||||
|
||||
@@ -13,7 +13,7 @@ export const load: PageServerLoad = async ({ params, fetch, url }) => {
|
||||
}
|
||||
const pasteData = (await paste.json()) as Paste;
|
||||
const pasteContent = await fetch(`/api/paste/${id}/raw`);
|
||||
const pasteOptions = await fetch('/api/paste/create/options');
|
||||
const pasteOptions = await fetch('/api/paste/info');
|
||||
const options = await pasteOptions.json();
|
||||
const content = await pasteContent.text();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user