diff --git a/hooks/useLinks.tsx b/hooks/useLinks.tsx index 0896c83..5de86e3 100644 --- a/hooks/useLinks.tsx +++ b/hooks/useLinks.tsx @@ -33,7 +33,7 @@ export default function useLinks( const encodedData = encodeURIComponent(JSON.stringify(requestBody)); const response = await fetch( - `/api/routes/links?body=${encodeURIComponent(encodedData)}` + `/api/links?body=${encodeURIComponent(encodedData)}` ); const data = await response.json(); diff --git a/lib/client/getPublicCollectionData.ts b/lib/client/getPublicCollectionData.ts index 6179142..d997eb7 100644 --- a/lib/client/getPublicCollectionData.ts +++ b/lib/client/getPublicCollectionData.ts @@ -17,7 +17,7 @@ const getPublicCollectionData = async ( const encodedData = encodeURIComponent(JSON.stringify(requestBody)); const res = await fetch( - "/api/public/routes/collections?body=" + encodeURIComponent(encodedData) + "/api/public/collections?body=" + encodeURIComponent(encodedData) ); const data = await res.json(); diff --git a/lib/client/getPublicUserData.ts b/lib/client/getPublicUserData.ts index 620cf9e..4c65da3 100644 --- a/lib/client/getPublicUserData.ts +++ b/lib/client/getPublicUserData.ts @@ -8,7 +8,7 @@ export default async function getPublicUserData({ id?: number; }) { const response = await fetch( - `/api/routes/users?id=${id}&${ + `/api/users?id=${id}&${ username ? `username=${username?.toLowerCase()}` : undefined }` ); diff --git a/pages/api/routes/collections/index.ts b/pages/api/collections/index.ts similarity index 100% rename from pages/api/routes/collections/index.ts rename to pages/api/collections/index.ts diff --git a/pages/api/routes/links/index.ts b/pages/api/links/index.ts similarity index 100% rename from pages/api/routes/links/index.ts rename to pages/api/links/index.ts diff --git a/pages/api/public/routes/collections.ts b/pages/api/public/collections.ts similarity index 100% rename from pages/api/public/routes/collections.ts rename to pages/api/public/collections.ts diff --git a/pages/api/routes/tags/index.ts b/pages/api/tags/index.ts similarity index 100% rename from pages/api/routes/tags/index.ts rename to pages/api/tags/index.ts diff --git a/pages/api/routes/users/index.ts b/pages/api/users/index.ts similarity index 100% rename from pages/api/routes/users/index.ts rename to pages/api/users/index.ts diff --git a/store/account.ts b/store/account.ts index 638848c..4b7e9b6 100644 --- a/store/account.ts +++ b/store/account.ts @@ -15,7 +15,7 @@ type AccountStore = { const useAccountStore = create()((set) => ({ account: {} as AccountSettings, setAccount: async (id) => { - const response = await fetch(`/api/routes/users?id=${id}`); + const response = await fetch(`/api/users?id=${id}`); const data = await response.json(); @@ -24,7 +24,7 @@ const useAccountStore = create()((set) => ({ if (response.ok) set({ account: { ...data.response, profilePic } }); }, updateAccount: async (user) => { - const response = await fetch("/api/routes/users", { + const response = await fetch("/api/users", { method: "PUT", body: JSON.stringify(user), headers: { diff --git a/store/collections.ts b/store/collections.ts index 5e05291..0fade5f 100644 --- a/store/collections.ts +++ b/store/collections.ts @@ -22,14 +22,14 @@ type CollectionStore = { const useCollectionStore = create()((set) => ({ collections: [], setCollections: async () => { - const response = await fetch("/api/routes/collections"); + const response = await fetch("/api/collections"); const data = await response.json(); if (response.ok) set({ collections: data.response }); }, addCollection: async (body) => { - const response = await fetch("/api/routes/collections", { + const response = await fetch("/api/collections", { body: JSON.stringify(body), headers: { "Content-Type": "application/json", @@ -47,7 +47,7 @@ const useCollectionStore = create()((set) => ({ return { ok: response.ok, data: data.response }; }, updateCollection: async (collection) => { - const response = await fetch("/api/routes/collections", { + const response = await fetch("/api/collections", { body: JSON.stringify(collection), headers: { "Content-Type": "application/json", @@ -67,7 +67,7 @@ const useCollectionStore = create()((set) => ({ return { ok: response.ok, data: data.response }; }, removeCollection: async (id) => { - const response = await fetch("/api/routes/collections", { + const response = await fetch("/api/collections", { body: JSON.stringify({ id }), headers: { "Content-Type": "application/json", diff --git a/store/links.ts b/store/links.ts index 807e1ae..ff25603 100644 --- a/store/links.ts +++ b/store/links.ts @@ -38,7 +38,7 @@ const useLinkStore = create()((set) => ({ })); }, addLink: async (body) => { - const response = await fetch("/api/routes/links", { + const response = await fetch("/api/links", { body: JSON.stringify(body), headers: { "Content-Type": "application/json", @@ -59,7 +59,7 @@ const useLinkStore = create()((set) => ({ return { ok: response.ok, data: data.response }; }, updateLink: async (link) => { - const response = await fetch("/api/routes/links", { + const response = await fetch("/api/links", { body: JSON.stringify(link), headers: { "Content-Type": "application/json", @@ -82,7 +82,7 @@ const useLinkStore = create()((set) => ({ return { ok: response.ok, data: data.response }; }, removeLink: async (link) => { - const response = await fetch("/api/routes/links", { + const response = await fetch("/api/links", { body: JSON.stringify(link), headers: { "Content-Type": "application/json", diff --git a/store/tags.ts b/store/tags.ts index 17b5c52..f833aa0 100644 --- a/store/tags.ts +++ b/store/tags.ts @@ -9,7 +9,7 @@ type TagStore = { const useTagStore = create()((set) => ({ tags: [], setTags: async () => { - const response = await fetch("/api/routes/tags"); + const response = await fetch("/api/tags"); const data = await response.json();