Skip to content

Commit

Permalink
fix: uppercase http method names
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeMyst committed Oct 22, 2024
1 parent 4d8e229 commit b2c5a64
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion client/src/lib/Editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions client/src/lib/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const createAccount = async (username: string): Promise<string | null> =>
};

const res = await fetch(`${env.PUBLIC_API_BASE}/auth/register`, {
method: "post",
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json"
Expand All @@ -23,7 +23,7 @@ export const createAccount = async (username: string): Promise<string | null> =>

export const getSelf = async (fetchFunc: FetchFunc): Promise<User | null> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/auth/self`, {
method: "get",
method: "GET",
credentials: "include"
});

Expand Down
8 changes: 4 additions & 4 deletions client/src/lib/api/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface AppStats {

export const getVersion = async (fetchFunc: FetchFunc): Promise<string> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/meta/version`, {
method: "get"
method: "GET"
});

if (res.ok) return (await res.json()).version;
Expand All @@ -31,7 +31,7 @@ export const getVersion = async (fetchFunc: FetchFunc): Promise<string> => {

export const getReleases = async (fetchFunc: FetchFunc): Promise<Release[]> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/meta/releases`, {
method: "get"
method: "GET"
});

if (res.ok) return await res.json();
Expand All @@ -41,7 +41,7 @@ export const getReleases = async (fetchFunc: FetchFunc): Promise<Release[]> => {

export const getActivePastes = async (fetchFunc: FetchFunc): Promise<number> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/meta/active_pastes`, {
method: "get"
method: "GET"
});

if (res.ok) return (await res.json()).count;
Expand All @@ -51,7 +51,7 @@ export const getActivePastes = async (fetchFunc: FetchFunc): Promise<number> =>

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];
Expand Down
30 changes: 15 additions & 15 deletions client/src/lib/api/paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const expiresInToLongString = (exp: ExpiresIn): string => {

export const createPaste = async (createInfo: PasteCreateInfo): Promise<Paste | null> => {
const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/`, {
method: "post",
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json"
Expand All @@ -167,7 +167,7 @@ export const createPaste = async (createInfo: PasteCreateInfo): Promise<Paste |

export const editPasteTags = async (id: string, tags: string[]): Promise<Paste | null> => {
const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}/tags`, {
method: "patch",
method: "PATCH",
credentials: "include",
headers: {
"Content-Type": "application/json"
Expand All @@ -182,7 +182,7 @@ export const editPasteTags = async (id: string, tags: string[]): Promise<Paste |

export const editPaste = async (id: string, editInfo: PasteEditInfo): Promise<Paste | null> => {
const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}`, {
method: "patch",
method: "PATCH",
credentials: "include",
headers: {
"Content-Type": "application/json"
Expand All @@ -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"
});

Expand All @@ -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"
});

Expand All @@ -229,7 +229,7 @@ export const getPasteAtEdit = async (
historyId: string
): Promise<Paste | null> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/history/${historyId}`, {
method: "get",
method: "GET",
credentials: "include"
});

Expand All @@ -244,7 +244,7 @@ export const getPasteDiff = async (
historyId: string
): Promise<PasteDiff | null> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/history/${historyId}/diff`, {
method: "get",
method: "GET",
credentials: "include"
});

Expand All @@ -255,7 +255,7 @@ export const getPasteDiff = async (

export const deletePaste = async (id: string): Promise<boolean> => {
const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}`, {
method: "delete",
method: "DELETE",
credentials: "include"
});

Expand All @@ -264,7 +264,7 @@ export const deletePaste = async (id: string): Promise<boolean> => {

export const starPaste = async (id: string): Promise<boolean> => {
const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}/star`, {
method: "post",
method: "POST",
credentials: "include"
});

Expand All @@ -273,7 +273,7 @@ export const starPaste = async (id: string): Promise<boolean> => {

export const pinPaste = async (id: string): Promise<boolean> => {
const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}/pin`, {
method: "post",
method: "POST",
credentials: "include"
});

Expand All @@ -282,7 +282,7 @@ export const pinPaste = async (id: string): Promise<boolean> => {

export const isPasteStarred = async (fetchFunc: FetchFunc, id: string): Promise<boolean> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/star`, {
method: "get",
method: "GET",
credentials: "include"
});

Expand All @@ -293,7 +293,7 @@ export const isPasteStarred = async (fetchFunc: FetchFunc, id: string): Promise<

export const togglePrivatePaste = async (id: string): Promise<boolean> => {
const res = await fetch(`${env.PUBLIC_API_BASE}/pastes/${id}/private`, {
method: "post",
method: "POST",
credentials: "include"
});

Expand All @@ -305,7 +305,7 @@ export const getPasteStats = async (
id: string
): Promise<PasteStats | null> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/stats`, {
method: "get",
method: "GET",
credentials: "include"
});

Expand All @@ -316,7 +316,7 @@ export const getPasteStats = async (

export const getPasteLangs = async (fetchFunc: FetchFunc, id: string): Promise<LangStat[]> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/pastes/${id}/langs`, {
method: "get",
method: "GET",
credentials: "include"
});

Expand All @@ -337,7 +337,7 @@ export const getUserPastes = async (
`?page=${page}` +
`&pageSize=${pageSize}`,
{
method: "get",
method: "GET",
credentials: "include"
}
);
Expand Down
8 changes: 4 additions & 4 deletions client/src/lib/api/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});

Expand All @@ -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"
Expand All @@ -43,7 +43,7 @@ export const updateSettings = async (fetchFunc: FetchFunc, settings: Settings) =

export const getUserSettings = async (fetchFunc: FetchFunc): Promise<UserSettings> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/settings/user`, {
method: "get",
method: "GET",
credentials: "include"
});

Expand All @@ -52,7 +52,7 @@ export const getUserSettings = async (fetchFunc: FetchFunc): Promise<UserSetting

export const updateUserSettings = async (fetchFunc: FetchFunc, userSettings: UserSettings) => {
await fetchFunc(`${env.PUBLIC_API_BASE}/settings/user`, {
method: "patch",
method: "PATCH",
credentials: "include",
headers: {
"Content-Type": "application/json"
Expand Down
8 changes: 4 additions & 4 deletions client/src/lib/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface User {

export const getUserByUsername = async (username: string): Promise<User | null> => {
const res = await fetch(`${env.PUBLIC_API_BASE}/users/${username}`, {
method: "get"
method: "GET"
});

if (res.ok) return await res.json();
Expand All @@ -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];
Expand All @@ -36,7 +36,7 @@ export const getUserById = async (

export const getUserTags = async (fetchFunc: FetchFunc, username: string): Promise<string[]> => {
const res = await fetchFunc(`${env.PUBLIC_API_BASE}/users/${username}/tags`, {
method: "get",
method: "GET",
credentials: "include"
});

Expand All @@ -47,7 +47,7 @@ export const getUserTags = async (fetchFunc: FetchFunc, username: string): Promi

export const deleteUser = async (username: string): Promise<boolean> => {
const res = await fetch(`${env.PUBLIC_API_BASE}/users/${username}`, {
method: "delete",
method: "DELETE",
credentials: "include"
});

Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/[paste]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/[paste]/history/[history]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
8 changes: 4 additions & 4 deletions client/src/routes/~[user]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ 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"
}
);

const userPinnedPastesRes = await fetch(
`${env.PUBLIC_API_BASE}/users/${params.user}/pastes/pinned?pageSize=5`,
{
method: "get",
method: "GET",
credentials: "include"
}
);
Expand Down

0 comments on commit b2c5a64

Please sign in to comment.