diff --git a/package.json b/package.json index b4e991ca..426d774d 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,6 @@ "@svgr/webpack": "6.5.1", "@tanem/react-nprogress": "5.0.30", "ace-builds": "1.15.2", - "axios": "1.3.4", - "axios-rate-limit": "1.3.0", "bcrypt": "5.1.0", "bowser": "2.11.0", "connect-typeorm": "1.1.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4f3c296b..ea593fea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,12 +41,6 @@ importers: ace-builds: specifier: 1.15.2 version: 1.15.2 - axios: - specifier: 1.3.4 - version: 1.3.4 - axios-rate-limit: - specifier: 1.3.0 - version: 1.3.0(axios@1.3.4) bcrypt: specifier: 5.1.0 version: 5.1.0(encoding@0.1.13) @@ -3396,14 +3390,6 @@ packages: resolution: {integrity: sha512-QbUdXJVTpvUTHU7871ppZkdOLBeGUKBQWHkHrvN2V9IQWGMt61zf3B45BtzjxEJzYuj0JBjBZP/hmYS/R9pmAw==} engines: {node: '>=4'} - axios-rate-limit@1.3.0: - resolution: {integrity: sha512-cKR5wTbU/CeeyF1xVl5hl6FlYsmzDVqxlN4rGtfO5x7J83UxKDckudsW0yW21/ZJRcO0Qrfm3fUFbhEbWTLayw==} - peerDependencies: - axios: '*' - - axios@1.3.4: - resolution: {integrity: sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==} - axobject-query@3.1.1: resolution: {integrity: sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg==} @@ -5028,15 +5014,6 @@ packages: fn.name@1.1.0: resolution: {integrity: sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==} - follow-redirects@1.15.6: - resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} - engines: {node: '>=4.0'} - peerDependencies: - debug: '*' - peerDependenciesMeta: - debug: - optional: true - for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} @@ -5051,10 +5028,6 @@ packages: resolution: {integrity: sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==} engines: {node: '>= 0.12'} - form-data@4.0.0: - resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} - engines: {node: '>= 6'} - formik@2.4.6: resolution: {integrity: sha512-A+2EI7U7aG296q2TLGvNapDNTZp1khVt5Vk0Q/fyfSROss0V/V6+txt2aJnwEos44IxTCW/LYAi/zgWzlevj+g==} peerDependencies: @@ -7408,9 +7381,6 @@ packages: proxy-from-env@1.0.0: resolution: {integrity: sha512-F2JHgJQ1iqwnHDcQjVBsq3n/uoaFL+iPW/eAeL7kVxy/2RrWaN4WroKjjvbsoRtv0ftelNyC01bjRhn/bhcf4A==} - proxy-from-env@1.1.0: - resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - psl@1.9.0: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} @@ -10773,14 +10743,14 @@ snapshots: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 17.0.36 + '@types/node': 20.14.8 jest-mock: 29.7.0 '@jest/fake-timers@29.7.0': dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 17.0.36 + '@types/node': 20.14.8 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -10793,7 +10763,7 @@ snapshots: dependencies: '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 17.0.36 + '@types/node': 20.14.8 '@types/yargs': 15.0.19 chalk: 4.1.2 @@ -10802,7 +10772,7 @@ snapshots: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 17.0.36 + '@types/node': 20.14.8 '@types/yargs': 17.0.32 chalk: 4.1.2 @@ -12712,7 +12682,7 @@ snapshots: '@types/node-forge@1.3.11': dependencies: - '@types/node': 17.0.36 + '@types/node': 20.14.8 '@types/node-schedule@2.1.0': dependencies: @@ -13287,18 +13257,6 @@ snapshots: axe-core@4.9.1: {} - axios-rate-limit@1.3.0(axios@1.3.4): - dependencies: - axios: 1.3.4 - - axios@1.3.4: - dependencies: - follow-redirects: 1.15.6 - form-data: 4.0.0 - proxy-from-env: 1.1.0 - transitivePeerDependencies: - - debug - axobject-query@3.1.1: dependencies: deep-equal: 2.2.3 @@ -13658,7 +13616,7 @@ snapshots: chrome-launcher@0.15.2: dependencies: - '@types/node': 17.0.36 + '@types/node': 20.14.8 escape-string-regexp: 4.0.0 is-wsl: 2.2.0 lighthouse-logger: 1.4.2 @@ -15318,8 +15276,6 @@ snapshots: fn.name@1.1.0: {} - follow-redirects@1.15.6: {} - for-each@0.3.3: dependencies: is-callable: 1.2.7 @@ -15337,12 +15293,6 @@ snapshots: combined-stream: 1.0.8 mime-types: 2.1.35 - form-data@4.0.0: - dependencies: - asynckit: 0.4.0 - combined-stream: 1.0.8 - mime-types: 2.1.35 - formik@2.4.6(react@18.3.1): dependencies: '@types/hoist-non-react-statics': 3.3.5 @@ -16135,7 +16085,7 @@ snapshots: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 17.0.36 + '@types/node': 20.14.8 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -16156,13 +16106,13 @@ snapshots: jest-mock@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 17.0.36 + '@types/node': 20.14.8 jest-util: 29.7.0 jest-util@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 17.0.36 + '@types/node': 20.14.8 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -16179,7 +16129,7 @@ snapshots: jest-worker@29.7.0: dependencies: - '@types/node': 17.0.36 + '@types/node': 20.14.8 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -17892,8 +17842,6 @@ snapshots: proxy-from-env@1.0.0: {} - proxy-from-env@1.1.0: {} - psl@1.9.0: {} pstree.remy@1.1.8: {} diff --git a/src/components/Discover/CreateSlider/index.tsx b/src/components/Discover/CreateSlider/index.tsx index 32cca079..1d558faa 100644 --- a/src/components/Discover/CreateSlider/index.tsx +++ b/src/components/Discover/CreateSlider/index.tsx @@ -14,7 +14,6 @@ import { DiscoverSliderType } from '@server/constants/discover'; import type DiscoverSlider from '@server/entity/DiscoverSlider'; import type { GenreSliderItem } from '@server/interfaces/api/discoverInterfaces'; import type { Keyword, ProductionCompany } from '@server/models/common'; -import axios from 'axios'; import { Field, Form, Formik } from 'formik'; import { useCallback, useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; @@ -77,11 +76,9 @@ const CreateSlider = ({ onCreate, slider }: CreateSliderProps) => { const keywords = await Promise.all( slider.data.split(',').map(async (keywordId) => { - const keyword = await axios.get( - `/api/v1/keyword/${keywordId}` - ); - - return keyword.data; + const res = await fetch(`/api/v1/keyword/${keywordId}`); + const keyword: Keyword = await res.json(); + return keyword; }) ); @@ -98,15 +95,13 @@ const CreateSlider = ({ onCreate, slider }: CreateSliderProps) => { return; } - const response = await axios.get( + const res = await fetch( `/api/v1/genres/${ slider.type === DiscoverSliderType.TMDB_MOVIE_GENRE ? 'movie' : 'tv' }` ); - - const genre = response.data.find( - (genre) => genre.id === Number(slider.data) - ); + const genres: TmdbGenre[] = await res.json(); + const genre = genres.find((genre) => genre.id === Number(slider.data)); setDefaultDataValue([ { @@ -121,11 +116,8 @@ const CreateSlider = ({ onCreate, slider }: CreateSliderProps) => { return; } - const response = await axios.get( - `/api/v1/studio/${slider.data}` - ); - - const studio = response.data; + const res = await fetch(`/api/v1/studio/${slider.data}`); + const studio: ProductionCompany = await res.json(); setDefaultDataValue([ { @@ -168,16 +160,17 @@ const CreateSlider = ({ onCreate, slider }: CreateSliderProps) => { ); const loadKeywordOptions = async (inputValue: string) => { - const results = await axios.get( - '/api/v1/search/keyword', + const res = await fetch( + `/api/v1/search/keyword?query=${encodeURIExtraParams(inputValue)}`, { - params: { - query: encodeURIExtraParams(inputValue), + headers: { + 'Content-Type': 'application/json', }, } ); + const results: TmdbKeywordSearchResponse = await res.json(); - return results.data.results.map((result) => ({ + return results.results.map((result) => ({ label: result.name, value: result.id, })); @@ -188,38 +181,37 @@ const CreateSlider = ({ onCreate, slider }: CreateSliderProps) => { return []; } - const results = await axios.get( - '/api/v1/search/company', + const res = await fetch( + `/api/v1/search/company?query=${encodeURIExtraParams(inputValue)}`, { - params: { - query: encodeURIExtraParams(inputValue), + headers: { + 'Content-Type': 'application/json', }, } ); + const results: TmdbCompanySearchResponse = await res.json(); - return results.data.results.map((result) => ({ + return results.results.map((result) => ({ label: result.name, value: result.id, })); }; const loadMovieGenreOptions = async () => { - const results = await axios.get( - '/api/v1/discover/genreslider/movie' - ); + const res = await fetch('/api/v1/discover/genreslider/movie'); + const results: GenreSliderItem[] = await res.json(); - return results.data.map((result) => ({ + return results.map((result) => ({ label: result.name, value: result.id, })); }; const loadTvGenreOptions = async () => { - const results = await axios.get( - '/api/v1/discover/genreslider/tv' - ); + const res = await fetch('/api/v1/discover/genreslider/tv'); + const results: GenreSliderItem[] = await res.json(); - return results.data.map((result) => ({ + return results.map((result) => ({ label: result.name, value: result.id, })); @@ -314,17 +306,31 @@ const CreateSlider = ({ onCreate, slider }: CreateSliderProps) => { onSubmit={async (values, { resetForm }) => { try { if (slider) { - await axios.put(`/api/v1/settings/discover/${slider.id}`, { - type: Number(values.sliderType), - title: values.title, - data: values.data, + const res = await fetch(`/api/v1/settings/discover/${slider.id}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + type: Number(values.sliderType), + title: values.title, + data: values.data, + }), }); + if (!res.ok) throw new Error(); } else { - await axios.post('/api/v1/settings/discover/add', { - type: Number(values.sliderType), - title: values.title, - data: values.data, + const res = await fetch('/api/v1/settings/discover/add', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + type: Number(values.sliderType), + title: values.title, + data: values.data, + }), }); + if (!res.ok) throw new Error(); } addToast( diff --git a/src/components/Discover/DiscoverSliderEdit/index.tsx b/src/components/Discover/DiscoverSliderEdit/index.tsx index 8fd556fe..cb58b9c5 100644 --- a/src/components/Discover/DiscoverSliderEdit/index.tsx +++ b/src/components/Discover/DiscoverSliderEdit/index.tsx @@ -20,7 +20,6 @@ import { } from '@heroicons/react/24/solid'; import { DiscoverSliderType } from '@server/constants/discover'; import type DiscoverSlider from '@server/entity/DiscoverSlider'; -import axios from 'axios'; import { useRef, useState } from 'react'; import { useDrag, useDrop } from 'react-aria'; import { useIntl } from 'react-intl'; @@ -78,7 +77,10 @@ const DiscoverSliderEdit = ({ const deleteSlider = async () => { try { - await axios.delete(`/api/v1/settings/discover/${slider.id}`); + const res = await fetch(`/api/v1/settings/discover/${slider.id}`, { + method: 'DELETE', + }); + if (!res.ok) throw new Error(); addToast(intl.formatMessage(messages.deletesuccess), { appearance: 'success', autoDismiss: true, diff --git a/src/components/Discover/index.tsx b/src/components/Discover/index.tsx index d46e9955..370384f1 100644 --- a/src/components/Discover/index.tsx +++ b/src/components/Discover/index.tsx @@ -28,7 +28,6 @@ import { } from '@heroicons/react/24/solid'; import { DiscoverSliderType } from '@server/constants/discover'; import type DiscoverSlider from '@server/entity/DiscoverSlider'; -import axios from 'axios'; import { useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; import { useToasts } from 'react-toast-notifications'; @@ -76,7 +75,14 @@ const Discover = () => { const updateSliders = async () => { try { - await axios.post('/api/v1/settings/discover', sliders); + const res = await fetch('/api/v1/settings/discover', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(sliders), + }); + if (!res.ok) throw new Error(); addToast(intl.formatMessage(messages.updatesuccess), { appearance: 'success', @@ -94,7 +100,10 @@ const Discover = () => { const resetSliders = async () => { try { - await axios.get('/api/v1/settings/discover/reset'); + const res = await fetch('/api/v1/settings/discover/reset', { + method: 'GET', + }); + if (!res.ok) throw new Error(); addToast(intl.formatMessage(messages.resetsuccess), { appearance: 'success', diff --git a/src/components/IssueDetails/IssueComment/index.tsx b/src/components/IssueDetails/IssueComment/index.tsx index f0ec8a5a..aa5a65dc 100644 --- a/src/components/IssueDetails/IssueComment/index.tsx +++ b/src/components/IssueDetails/IssueComment/index.tsx @@ -5,7 +5,6 @@ import defineMessages from '@app/utils/defineMessages'; import { Menu, Transition } from '@headlessui/react'; import { EllipsisVerticalIcon } from '@heroicons/react/24/solid'; import type { default as IssueCommentType } from '@server/entity/IssueComment'; -import axios from 'axios'; import { Field, Form, Formik } from 'formik'; import Image from 'next/image'; import Link from 'next/link'; @@ -49,7 +48,10 @@ const IssueComment = ({ const deleteComment = async () => { try { - await axios.delete(`/api/v1/issueComment/${comment.id}`); + const res = await fetch(`/api/v1/issueComment/${comment.id}`, { + method: 'DELETE', + }); + if (!res.ok) throw new Error(); } catch (e) { // something went wrong deleting the comment } finally { @@ -175,9 +177,14 @@ const IssueComment = ({ { - await axios.put(`/api/v1/issueComment/${comment.id}`, { - message: values.newMessage, - }); + const res = await fetch( + `/api/v1/issueComment/${comment.id}`, + { + method: 'PUT', + body: JSON.stringify({ message: values.newMessage }), + } + ); + if (!res.ok) throw new Error(); if (onUpdate) { onUpdate(); diff --git a/src/components/IssueDetails/index.tsx b/src/components/IssueDetails/index.tsx index 0c6e831f..e4b952e2 100644 --- a/src/components/IssueDetails/index.tsx +++ b/src/components/IssueDetails/index.tsx @@ -11,7 +11,7 @@ import useDeepLinks from '@app/hooks/useDeepLinks'; import useSettings from '@app/hooks/useSettings'; import { Permission, useUser } from '@app/hooks/useUser'; import globalMessages from '@app/i18n/globalMessages'; -import Error from '@app/pages/_error'; +import ErrorPage from '@app/pages/_error'; import defineMessages from '@app/utils/defineMessages'; import { Transition } from '@headlessui/react'; import { @@ -27,7 +27,6 @@ import { MediaServerType } from '@server/constants/server'; import type Issue from '@server/entity/Issue'; import type { MovieDetails } from '@server/models/Movie'; import type { TvDetails } from '@server/models/Tv'; -import axios from 'axios'; import { Field, Form, Formik } from 'formik'; import getConfig from 'next/config'; import Image from 'next/image'; @@ -116,7 +115,7 @@ const IssueDetails = () => { } if (!data || !issueData) { - return ; + return ; } const belongsToUser = issueData.createdBy.id === currentUser?.id; @@ -125,9 +124,11 @@ const IssueDetails = () => { const editFirstComment = async (newMessage: string) => { try { - await axios.put(`/api/v1/issueComment/${firstComment.id}`, { - message: newMessage, + const res = await fetch(`/api/v1/issueComment/${firstComment.id}`, { + method: 'PUT', + body: JSON.stringify({ message: newMessage }), }); + if (!res.ok) throw new Error(); addToast(intl.formatMessage(messages.toasteditdescriptionsuccess), { appearance: 'success', @@ -144,7 +145,10 @@ const IssueDetails = () => { const updateIssueStatus = async (newStatus: 'open' | 'resolved') => { try { - await axios.post(`/api/v1/issue/${issueData.id}/${newStatus}`); + const res = await fetch(`/api/v1/issue/${issueData.id}/${newStatus}`, { + method: 'POST', + }); + if (!res.ok) throw new Error(); addToast(intl.formatMessage(messages.toaststatusupdated), { appearance: 'success', @@ -161,7 +165,10 @@ const IssueDetails = () => { const deleteIssue = async () => { try { - await axios.delete(`/api/v1/issue/${issueData.id}`); + const res = await fetch(`/api/v1/issue/${issueData.id}`, { + method: 'DELETE', + }); + if (!res.ok) throw new Error(); addToast(intl.formatMessage(messages.toastissuedeleted), { appearance: 'success', @@ -490,9 +497,14 @@ const IssueDetails = () => { }} validationSchema={CommentSchema} onSubmit={async (values, { resetForm }) => { - await axios.post(`/api/v1/issue/${issueData?.id}/comment`, { - message: values.message, - }); + const res = await fetch( + `/api/v1/issue/${issueData?.id}/comment`, + { + method: 'POST', + body: JSON.stringify({ message: values.message }), + } + ); + if (!res.ok) throw new Error(); revalidateIssue(); resetForm(); }} diff --git a/src/components/IssueModal/CreateIssueModal/index.tsx b/src/components/IssueModal/CreateIssueModal/index.tsx index 7af3e495..8db12010 100644 --- a/src/components/IssueModal/CreateIssueModal/index.tsx +++ b/src/components/IssueModal/CreateIssueModal/index.tsx @@ -11,7 +11,6 @@ import { MediaStatus } from '@server/constants/media'; import type Issue from '@server/entity/Issue'; import type { MovieDetails } from '@server/models/Movie'; import type { TvDetails } from '@server/models/Tv'; -import axios from 'axios'; import { Field, Formik } from 'formik'; import Link from 'next/link'; import { useIntl } from 'react-intl'; @@ -101,14 +100,19 @@ const CreateIssueModal = ({ validationSchema={CreateIssueModalSchema} onSubmit={async (values) => { try { - const newIssue = await axios.post('/api/v1/issue', { - issueType: values.selectedIssue.issueType, - message: values.message, - mediaId: data?.mediaInfo?.id, - problemSeason: values.problemSeason, - problemEpisode: - values.problemSeason > 0 ? values.problemEpisode : 0, + const res = await fetch('/api/v1/issue', { + method: 'POST', + body: JSON.stringify({ + issueType: values.selectedIssue.issueType, + message: values.message, + mediaId: data?.mediaInfo?.id, + problemSeason: values.problemSeason, + problemEpisode: + values.problemSeason > 0 ? values.problemEpisode : 0, + }), }); + if (!res.ok) throw new Error(); + const newIssue: Issue = await res.json(); if (data) { addToast( @@ -119,7 +123,7 @@ const CreateIssueModal = ({ strong: (msg: React.ReactNode) => {msg}, })} - +