From 05578f05e51c20bfc2bd6ac5a79a53e2b568bb0e Mon Sep 17 00:00:00 2001 From: CodeMyst Date: Tue, 22 Oct 2024 22:14:10 +0200 Subject: [PATCH] fix: uppercase http method names --- client/src/lib/Editor.svelte | 2 +- client/src/lib/api/auth.ts | 4 +-- client/src/lib/api/meta.ts | 8 ++--- client/src/lib/api/paste.ts | 30 +++++++++---------- client/src/lib/api/settings.ts | 8 ++--- client/src/lib/api/user.ts | 8 ++--- client/src/routes/[paste]/+page.ts | 2 +- .../routes/[paste]/history/[history]/+page.ts | 2 +- client/src/routes/~[user]/+page.ts | 8 ++--- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/client/src/lib/Editor.svelte b/client/src/lib/Editor.svelte index b0a119e0..b3eb41f1 100755 --- a/client/src/lib/Editor.svelte +++ b/client/src/lib/Editor.svelte @@ -287,7 +287,7 @@ const preview = async () => { const res = await fetch("/internal/highlight", { - method: "post", + method: "POST", body: JSON.stringify({ content: getContent(), language: getSelectedLang().name, diff --git a/client/src/lib/api/auth.ts b/client/src/lib/api/auth.ts index a6c61d3b..b8f7f1a4 100755 --- a/client/src/lib/api/auth.ts +++ b/client/src/lib/api/auth.ts @@ -8,7 +8,7 @@ export const createAccount = async (username: string): Promise => }; const res = await fetch(`${env.PUBLIC_API_BASE}/auth/register`, { - method: "post", + method: "POST", credentials: "include", headers: { "Content-Type": "application/json" @@ -23,7 +23,7 @@ export const createAccount = async (username: string): Promise => export const getSelf = async (fetchFunc: FetchFunc): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/auth/self`, { - method: "get", + method: "GET", credentials: "include" }); diff --git a/client/src/lib/api/meta.ts b/client/src/lib/api/meta.ts index 449fa233..56075841 100755 --- a/client/src/lib/api/meta.ts +++ b/client/src/lib/api/meta.ts @@ -21,7 +21,7 @@ export interface AppStats { export const getVersion = async (fetchFunc: FetchFunc): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/meta/version`, { - method: "get" + method: "GET" }); if (res.ok) return (await res.json()).version; @@ -31,7 +31,7 @@ export const getVersion = async (fetchFunc: FetchFunc): Promise => { export const getReleases = async (fetchFunc: FetchFunc): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/meta/releases`, { - method: "get" + method: "GET" }); if (res.ok) return await res.json(); @@ -41,7 +41,7 @@ export const getReleases = async (fetchFunc: FetchFunc): Promise => { export const getActivePastes = async (fetchFunc: FetchFunc): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/meta/active_pastes`, { - method: "get" + method: "GET" }); if (res.ok) return (await res.json()).count; @@ -51,7 +51,7 @@ export const getActivePastes = async (fetchFunc: FetchFunc): Promise => export const getAppStats = async (fetchFunc: FetchFunc): Promise<[AppStats | null, number]> => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/meta/stats`, { - method: "get" + method: "GET" }); if (res.ok) return [await res.json(), res.status]; diff --git a/client/src/lib/api/paste.ts b/client/src/lib/api/paste.ts index d548c8f0..391d3740 100755 --- a/client/src/lib/api/paste.ts +++ b/client/src/lib/api/paste.ts @@ -152,7 +152,7 @@ export const expiresInToLongString = (exp: ExpiresIn): string => { export const createPaste = async (createInfo: PasteCreateInfo): Promise => { const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/`, { - method: "post", + method: "POST", credentials: "include", headers: { "Content-Type": "application/json" @@ -167,7 +167,7 @@ export const createPaste = async (createInfo: PasteCreateInfo): Promise => { const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}/tags`, { - method: "patch", + method: "PATCH", credentials: "include", headers: { "Content-Type": "application/json" @@ -182,7 +182,7 @@ export const editPasteTags = async (id: string, tags: string[]): Promise => { const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}`, { - method: "patch", + method: "PATCH", credentials: "include", headers: { "Content-Type": "application/json" @@ -200,7 +200,7 @@ export const getPaste = async ( id: string ): Promise<[Paste | null, number]> => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}`, { - method: "get", + method: "GET", credentials: "include" }); @@ -214,7 +214,7 @@ export const getPasteHistoryCompact = async ( id: string ): Promise<{ id: string; editedAt: string }[]> => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/history_compact`, { - method: "get", + method: "GET", credentials: "include" }); @@ -229,7 +229,7 @@ export const getPasteAtEdit = async ( historyId: string ): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/history/${historyId}`, { - method: "get", + method: "GET", credentials: "include" }); @@ -244,7 +244,7 @@ export const getPasteDiff = async ( historyId: string ): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/history/${historyId}/diff`, { - method: "get", + method: "GET", credentials: "include" }); @@ -255,7 +255,7 @@ export const getPasteDiff = async ( export const deletePaste = async (id: string): Promise => { const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}`, { - method: "delete", + method: "DELETE", credentials: "include" }); @@ -264,7 +264,7 @@ export const deletePaste = async (id: string): Promise => { export const starPaste = async (id: string): Promise => { const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}/star`, { - method: "post", + method: "POST", credentials: "include" }); @@ -273,7 +273,7 @@ export const starPaste = async (id: string): Promise => { export const pinPaste = async (id: string): Promise => { const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}/pin`, { - method: "post", + method: "POST", credentials: "include" }); @@ -282,7 +282,7 @@ export const pinPaste = async (id: string): Promise => { export const isPasteStarred = async (fetchFunc: FetchFunc, id: string): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/star`, { - method: "get", + method: "GET", credentials: "include" }); @@ -293,7 +293,7 @@ export const isPasteStarred = async (fetchFunc: FetchFunc, id: string): Promise< export const togglePrivatePaste = async (id: string): Promise => { const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}/private`, { - method: "post", + method: "POST", credentials: "include" }); @@ -305,7 +305,7 @@ export const getPasteStats = async ( id: string ): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/stats`, { - method: "get", + method: "GET", credentials: "include" }); @@ -316,7 +316,7 @@ export const getPasteStats = async ( export const getPasteLangs = async (fetchFunc: FetchFunc, id: string): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/langs`, { - method: "get", + method: "GET", credentials: "include" }); @@ -337,7 +337,7 @@ export const getUserPastes = async ( `?page=${page}` + `&pageSize=${pageSize}`, { - method: "get", + method: "GET", credentials: "include" } ); diff --git a/client/src/lib/api/settings.ts b/client/src/lib/api/settings.ts index 8916755d..268d109d 100644 --- a/client/src/lib/api/settings.ts +++ b/client/src/lib/api/settings.ts @@ -20,7 +20,7 @@ export const getSettings = async ( fetchFunc: FetchFunc ): Promise<[settings: Settings, cookie?: string]> => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/settings`, { - method: "get", + method: "GET", credentials: "include" }); @@ -32,7 +32,7 @@ export const getSettings = async ( export const updateSettings = async (fetchFunc: FetchFunc, settings: Settings) => { await fetchFunc(`${env.PUBLIC_API_BASE}/settings`, { - method: "patch", + method: "PATCH", credentials: "include", headers: { "Content-Type": "application/json" @@ -43,7 +43,7 @@ export const updateSettings = async (fetchFunc: FetchFunc, settings: Settings) = export const getUserSettings = async (fetchFunc: FetchFunc): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/settings/user`, { - method: "get", + method: "GET", credentials: "include" }); @@ -52,7 +52,7 @@ export const getUserSettings = async (fetchFunc: FetchFunc): Promise { await fetchFunc(`${env.PUBLIC_API_BASE}/settings/user`, { - method: "patch", + method: "PATCH", credentials: "include", headers: { "Content-Type": "application/json" diff --git a/client/src/lib/api/user.ts b/client/src/lib/api/user.ts index 499dfeac..6c59ad0b 100755 --- a/client/src/lib/api/user.ts +++ b/client/src/lib/api/user.ts @@ -13,7 +13,7 @@ export interface User { export const getUserByUsername = async (username: string): Promise => { const res = await fetch(`${env.PUBLIC_API_BASE}/users/${username}`, { - method: "get" + method: "GET" }); if (res.ok) return await res.json(); @@ -26,7 +26,7 @@ export const getUserById = async ( id: string ): Promise<[User | null, number]> => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/users?id=${id}`, { - method: "get" + method: "GET" }); if (res.ok) return [await res.json(), res.status]; @@ -36,7 +36,7 @@ export const getUserById = async ( export const getUserTags = async (fetchFunc: FetchFunc, username: string): Promise => { const res = await fetchFunc(`${env.PUBLIC_API_BASE}/users/${username}/tags`, { - method: "get", + method: "GET", credentials: "include" }); @@ -47,7 +47,7 @@ export const getUserTags = async (fetchFunc: FetchFunc, username: string): Promi export const deleteUser = async (username: string): Promise => { const res = await fetch(`${env.PUBLIC_API_BASE}/users/${username}`, { - method: "delete", + method: "DELETE", credentials: "include" }); diff --git a/client/src/routes/[paste]/+page.ts b/client/src/routes/[paste]/+page.ts index 0ef69d06..5241c474 100644 --- a/client/src/routes/[paste]/+page.ts +++ b/client/src/routes/[paste]/+page.ts @@ -37,7 +37,7 @@ export const load: PageLoad = async ({ params, fetch, parent }) => { for (const pasty of paste.pasties) { const res = await fetch("/internal/highlight", { - method: "post", + method: "POST", headers: { "Content-Type": "application/json" }, diff --git a/client/src/routes/[paste]/history/[history]/+page.ts b/client/src/routes/[paste]/history/[history]/+page.ts index 6e68ddf3..ffcb9c10 100644 --- a/client/src/routes/[paste]/history/[history]/+page.ts +++ b/client/src/routes/[paste]/history/[history]/+page.ts @@ -36,7 +36,7 @@ export const load: PageLoad = async ({ params, fetch, parent }) => { for (const pasty of paste.pasties) { const res = await fetch("/internal/highlight", { - method: "post", + method: "POST", headers: { "Content-Type": "application/json" }, diff --git a/client/src/routes/~[user]/+page.ts b/client/src/routes/~[user]/+page.ts index 837f5842..84a37ca8 100644 --- a/client/src/routes/~[user]/+page.ts +++ b/client/src/routes/~[user]/+page.ts @@ -11,18 +11,18 @@ export const load: PageLoad = async ({ params, url, fetch }) => { const tagQuery = tag == null ? "" : "&tag=" + tag; const userRes = await fetch(`${env.PUBLIC_API_BASE}/users/${params.user}`, { - method: "get" + method: "GET" }); const meRes = await fetch(`${env.PUBLIC_API_BASE}/auth/self`, { - method: "get", + method: "GET", credentials: "include" }); const userPastesRes = await fetch( `${env.PUBLIC_API_BASE}/users/${params.user}/pastes?pageSize=5${tagQuery}`, { - method: "get", + method: "GET", credentials: "include" } ); @@ -30,7 +30,7 @@ export const load: PageLoad = async ({ params, url, fetch }) => { const userPinnedPastesRes = await fetch( `${env.PUBLIC_API_BASE}/users/${params.user}/pastes/pinned?pageSize=5`, { - method: "get", + method: "GET", credentials: "include" } );