refactored api routes

This commit is contained in:
Daniel 2023-08-20 12:00:42 -04:00
parent b0e92c6253
commit 8dfd1598f3
12 changed files with 13 additions and 13 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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
}`
);

View File

@ -15,7 +15,7 @@ type AccountStore = {
const useAccountStore = create<AccountStore>()((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<AccountStore>()((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: {

View File

@ -22,14 +22,14 @@ type CollectionStore = {
const useCollectionStore = create<CollectionStore>()((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<CollectionStore>()((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<CollectionStore>()((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",

View File

@ -38,7 +38,7 @@ const useLinkStore = create<LinkStore>()((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<LinkStore>()((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<LinkStore>()((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",

View File

@ -9,7 +9,7 @@ type TagStore = {
const useTagStore = create<TagStore>()((set) => ({
tags: [],
setTags: async () => {
const response = await fetch("/api/routes/tags");
const response = await fetch("/api/tags");
const data = await response.json();