From 8576aa81a34a67f20d4bbf71733bee23ab82a82e Mon Sep 17 00:00:00 2001 From: swordfest Date: Fri, 29 Mar 2024 16:29:55 -0400 Subject: [PATCH 01/10] setting next env base url --- components/layout.tsx | 2 +- components/meta.tsx | 2 +- components/serversListCols.tsx | 2 +- libs/store.tsx | 11 ----------- next.config.js | 10 +++------- 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/components/layout.tsx b/components/layout.tsx index 4342589..e8ca387 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -32,7 +32,7 @@ export default function Layout({ children }: any) { const fetcher = (...args: [any, any]) => fetch(...args).then((res) => res.json()); const { data: proxies, error } = useSWR( - "https://shadowmere.akiel.dev/api/proxies/?format=json&is_active=true&location_country_code=" + + `${process.env.BASE_URL}&is_active=true&location_country_code=` + countryFilter + "&port=" + portFilter + diff --git a/components/meta.tsx b/components/meta.tsx index a56f22b..0a2ae1d 100644 --- a/components/meta.tsx +++ b/components/meta.tsx @@ -23,7 +23,7 @@ export function Meta({ title, keywords, description }: Props) { {title} diff --git a/components/serversListCols.tsx b/components/serversListCols.tsx index 758e9e8..6708853 100644 --- a/components/serversListCols.tsx +++ b/components/serversListCols.tsx @@ -34,7 +34,7 @@ export default function ServersListCols(props: any) { const fetcher = (...args: [any, any]) => fetch(...args).then((res) => res.json()); const { data, error, mutate } = useSWR( - "https://shadowmere.akiel.dev/api/proxies/?format=json&is_active=true&location_country_code=" + + `${process.env.BASE_URL}&is_active=true&location_country_code=` + countryFilter + "&port=" + portFilter + diff --git a/libs/store.tsx b/libs/store.tsx index 3b2440f..e12386e 100644 --- a/libs/store.tsx +++ b/libs/store.tsx @@ -33,17 +33,6 @@ export const qrScreen = atom({ default: false, }) -// export const proxiesObj = selector({ -// key: 'proxiesObj', -// get: async ({ get }: any) => { -// const response: Proxies = await (await fetch('https://shadowmere.akiel.dev/api/proxies/?format=json&is_active=true')).json() -// if (!response) { -// return console.error(); -// } -// return response -// }, -// }) - export const proxyId = atom({ key: 'proxyId', default: null, diff --git a/next.config.js b/next.config.js index 8c5e956..a7b5b91 100644 --- a/next.config.js +++ b/next.config.js @@ -3,14 +3,10 @@ const nextConfig = { distDir: 'dist', reactStrictMode: true, swcMinify: true, - // compiler: { - // styledComponents: { - // displayName: true, - // ssr: true - // }, - // }, + env: { + BASE_URL:'https://shadowmere.akiel.dev/api/proxies/?format=json', + }, staticPageGenerationTimeout: 1000, - // output: 'standalone', images: { unoptimized: true, remotePatterns: [ From 7d89da8aede2c6551ac3359c7add029b67d846b9 Mon Sep 17 00:00:00 2001 From: swordfest Date: Sun, 31 Mar 2024 19:51:53 -0400 Subject: [PATCH 02/10] changes on the base url --- .gitignore | 2 + components/countries.tsx | 6 +- components/itemSubscriptionSSoscks.tsx | 6 +- components/itemSubscriptionV2Ray.tsx | 6 +- components/layout.tsx | 6 +- components/meta.tsx | 6 +- components/ports.tsx | 6 +- components/serversListCols.tsx | 4 +- components/v2raySubs.tsx | 109 +++++++++++++------------ libs/store.tsx | 5 ++ next.config.js | 6 +- 11 files changed, 98 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index 0153669..7db32da 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,8 @@ yarn-error.log* # local env files .env*.local +.env*.prod +.env.* # vercel .vercel diff --git a/components/countries.tsx b/components/countries.tsx index e2d4165..e5fd9a1 100644 --- a/components/countries.tsx +++ b/components/countries.tsx @@ -1,18 +1,20 @@ import useSWR from "swr"; import React, { useEffect, useState } from "react"; import { getFlagEmoji, getPercentage } from "../libs/functions"; -import { countryFilterState, pageCounterState } from "../libs/store"; +import { apiBaseUrl, countryFilterState, pageCounterState } from "../libs/store"; import { useRecoilState } from "recoil"; export default function Countries(props: any) { const [country, setCountry] = useRecoilState(countryFilterState); const [pageFilter, setPageFilter] = useRecoilState(pageCounterState); + const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); + const fetcher = (...args: [any, any]) => fetch(...args).then((res) => res.json()); const { data: countries, error } = useSWR( - "https://shadowmere.akiel.dev/api/country-codes", + `${apiBaseUrlGlobal}/country-codes`, fetcher ); diff --git a/components/itemSubscriptionSSoscks.tsx b/components/itemSubscriptionSSoscks.tsx index 9a35773..1aea16e 100644 --- a/components/itemSubscriptionSSoscks.tsx +++ b/components/itemSubscriptionSSoscks.tsx @@ -5,10 +5,14 @@ import { IconKey, } from "@tabler/icons-react"; import { useState } from "react"; +import { useRecoilState } from "recoil"; +import { apiBaseUrl } from "../libs/store"; export default function ItemSubscriptionSSocks(props: any) { const [isOver, setIsOver] = useState(false); const [timeCopy, setTimeCopy] = useState(false); + const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); + const handleOver = () => { setIsOver(true); @@ -21,7 +25,7 @@ export default function ItemSubscriptionSSocks(props: any) { setTimeCopy(true); navigator.clipboard - .writeText("https://shadowmere.akiel.dev/api/sub") + .writeText(`${apiBaseUrlGlobal}/sub/`) .then(() => { setTimeout(() => { setTimeCopy(false); diff --git a/components/itemSubscriptionV2Ray.tsx b/components/itemSubscriptionV2Ray.tsx index dd5191d..55561c9 100644 --- a/components/itemSubscriptionV2Ray.tsx +++ b/components/itemSubscriptionV2Ray.tsx @@ -1,9 +1,13 @@ import { IconCheck, IconClipboardCopy } from "@tabler/icons-react"; import { useState } from "react"; +import { useRecoilState } from "recoil"; +import { apiBaseUrl } from "../libs/store"; export default function ItemSubscriptionV2Ray(props: any) { const [isOver, setIsOver] = useState(false); const [timeCopy, setTimeCopy] = useState(false); + const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); + const handleOver = () => { setIsOver(true); @@ -16,7 +20,7 @@ export default function ItemSubscriptionV2Ray(props: any) { setTimeCopy(true); navigator.clipboard - .writeText("https://shadowmere.akiel.dev/api/b64sub/") + .writeText(`${apiBaseUrlGlobal}/b64sub/`) .then(() => { setTimeout(() => { setTimeCopy(false); diff --git a/components/layout.tsx b/components/layout.tsx index e8ca387..2c717c1 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -3,7 +3,7 @@ import Navbar from "./navbar"; import Sidebar from "./sidebar"; import ModalQR from "./modalQR"; import { useRecoilState } from "recoil"; -import { proxiesObj, qrScreen } from "../libs/store"; +import { apiBaseUrl, proxiesObj, qrScreen } from "../libs/store"; import { useEffect, useState } from "react"; import useSWR from "swr"; import { @@ -28,11 +28,13 @@ export default function Layout({ children }: any) { const [loader, setLoader] = useRecoilState(loaderPage); const [prox, setProx] = useRecoilState(proxiesObj); const [time, setTime] = useState(""); + const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); + const fetcher = (...args: [any, any]) => fetch(...args).then((res) => res.json()); const { data: proxies, error } = useSWR( - `${process.env.BASE_URL}&is_active=true&location_country_code=` + + `${apiBaseUrlGlobal}/proxies/?format=json&is_active=true&location_country_code=` + countryFilter + "&port=" + portFilter + diff --git a/components/meta.tsx b/components/meta.tsx index 0a2ae1d..6365f6e 100644 --- a/components/meta.tsx +++ b/components/meta.tsx @@ -2,7 +2,7 @@ import Head, { defaultHead } from "next/head"; import Script from "next/script"; import { useEffect } from "react"; import { useRecoilState } from "recoil"; -import { countryFilterState, pageCounterState, portFilterState } from "../libs/store"; +import { apiBaseUrl, countryFilterState, pageCounterState, portFilterState } from "../libs/store"; type Props = { title: string; @@ -14,6 +14,8 @@ export function Meta({ title, keywords, description }: Props) { const [pageCounter, setPageCounter] = useRecoilState(pageCounterState); const [portFilter, setPortFilter] = useRecoilState(portFilterState); const [countryFilter, setCountryFilter] = useRecoilState(countryFilterState); + const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); + return ( @@ -23,7 +25,7 @@ export function Meta({ title, keywords, description }: Props) { {title} diff --git a/components/ports.tsx b/components/ports.tsx index db1a942..9b3cf68 100644 --- a/components/ports.tsx +++ b/components/ports.tsx @@ -1,17 +1,19 @@ import useSWR from "swr"; import React, { useEffect } from "react"; -import { portFilterState, pageCounterState } from "../libs/store"; +import { portFilterState, pageCounterState, apiBaseUrl } from "../libs/store"; import { useRecoilState } from "recoil"; export default function Ports(props: any) { const [portFilter, setPortFilter] = useRecoilState(portFilterState); const [pageFilter, setPageFilter] = useRecoilState(pageCounterState); + const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); + const fetcher = (...args: [any, any]) => fetch(...args).then((res) => res.json()); const { data: ports, error } = useSWR( - "https://shadowmere.akiel.dev/api/ports/", + `${apiBaseUrlGlobal}/ports/`, fetcher ); diff --git a/components/serversListCols.tsx b/components/serversListCols.tsx index 6708853..8c3780b 100644 --- a/components/serversListCols.tsx +++ b/components/serversListCols.tsx @@ -16,6 +16,7 @@ import { proxiesCount, proxiesObj, loaderPage, + apiBaseUrl, } from "../libs/store"; import ServerSkeleton from "./serverSkeleton"; import ServerCol from "./serverCol"; @@ -30,11 +31,12 @@ export default function ServersListCols(props: any) { const [proxyCounter, setProxyCounter] = useRecoilState(proxiesCount); // const [data, setData] = useRecoilState(proxiesObj) const [noResults, setNoResults] = useState("No results has been found"); + const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); const fetcher = (...args: [any, any]) => fetch(...args).then((res) => res.json()); const { data, error, mutate } = useSWR( - `${process.env.BASE_URL}&is_active=true&location_country_code=` + + `${apiBaseUrlGlobal}/proxies/?format=json&is_active=true&location_country_code=` + countryFilter + "&port=" + portFilter + diff --git a/components/v2raySubs.tsx b/components/v2raySubs.tsx index f004b03..ee6178a 100644 --- a/components/v2raySubs.tsx +++ b/components/v2raySubs.tsx @@ -1,55 +1,64 @@ import { useState } from "react"; +import { useRecoilState } from "recoil"; +import { apiBaseUrl } from "../libs/store"; export default function V2raySubs() { - const [copyLink, setCopyLink] = useState(false); + const [copyLink, setCopyLink] = useState(false); + const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); - return ( - <> -

- {'Some applications like '} - - V2Ray for Android - - {` allow`} users to subscribe to a list of servers. You can subscribe to - Shadowmere's using this link:  - { - navigator.clipboard.writeText( - "https://shadowmere.akiel.dev/api/b64sub/" - ); - setCopyLink(true); - setTimeout(() => { - setCopyLink(false); - }, 1000); - }} - className=" group text-[#579eff] cursor-pointer font-bold hover:text-[#467ecc] transition-colors after:pl-1 dark:after:text-[#7a7a7a] after:text-[#c1c1c1] after:font-awesome after:text-sm "> - https://shadowmere.akiel.dev/api/b64sub/  - - Copied to Clipboard! - - -  - - -

-

Tutorial video

- - - ); + + return ( + <> +

+ {"Some applications like "} + + V2Ray for Android + + {` allow`} users to subscribe to a list of servers. You can subscribe to + Shadowmere's using this link:  + { + navigator.clipboard.writeText( + `${apiBaseUrlGlobal}/b64sub/` + ); + setCopyLink(true); + setTimeout(() => { + setCopyLink(false); + }, 1000); + }} + className=" group text-[#579eff] cursor-pointer font-bold hover:text-[#467ecc] transition-colors after:pl-1 dark:after:text-[#7a7a7a] after:text-[#c1c1c1] after:font-awesome after:text-sm " + > + https://shadowmere.akiel.dev/api/b64sub/  + + Copied to Clipboard! + + +  + + +

+

Tutorial video

+ + + ); } diff --git a/libs/store.tsx b/libs/store.tsx index e12386e..cc642c6 100644 --- a/libs/store.tsx +++ b/libs/store.tsx @@ -56,4 +56,9 @@ export const loaderPage = atom({ export const viewDataLayout = atom({ key: 'viewDataLayout', default: 'details' +}) + +export const apiBaseUrl = atom({ + key: 'apiBaseUrl', + default: process.env.BASE_URL }) \ No newline at end of file diff --git a/next.config.js b/next.config.js index a7b5b91..71230fb 100644 --- a/next.config.js +++ b/next.config.js @@ -3,9 +3,9 @@ const nextConfig = { distDir: 'dist', reactStrictMode: true, swcMinify: true, - env: { - BASE_URL:'https://shadowmere.akiel.dev/api/proxies/?format=json', - }, + // env: { + // BASE_URL:'https://shadowmere.akiel.dev/api', + // }, staticPageGenerationTimeout: 1000, images: { unoptimized: true, From d79365eda6efc1068aa0acfdb56068f00c13af37 Mon Sep 17 00:00:00 2001 From: swordfest Date: Mon, 1 Apr 2024 11:34:26 -0400 Subject: [PATCH 03/10] setting apiBaseUrl as global api variable from env file --- .gitignore | 1 + components/countries.tsx | 6 +- components/itemSubscriptionSSoscks.tsx | 6 +- components/itemSubscriptionV2Ray.tsx | 6 +- components/layout.tsx | 171 ++++++++++++------------- components/meta.tsx | 6 +- components/ports.tsx | 6 +- components/serversListCols.tsx | 5 +- components/v2raySubs.tsx | 5 +- libs/store.tsx | 5 - next.config.js | 4 +- vars/variables.ts | 1 + 12 files changed, 107 insertions(+), 115 deletions(-) create mode 100644 vars/variables.ts diff --git a/.gitignore b/.gitignore index 7db32da..05bfb6e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ yarn-error.log* .env*.local .env*.prod .env.* +.env # vercel .vercel diff --git a/components/countries.tsx b/components/countries.tsx index e5fd9a1..5263974 100644 --- a/components/countries.tsx +++ b/components/countries.tsx @@ -1,20 +1,20 @@ import useSWR from "swr"; import React, { useEffect, useState } from "react"; import { getFlagEmoji, getPercentage } from "../libs/functions"; -import { apiBaseUrl, countryFilterState, pageCounterState } from "../libs/store"; +import { countryFilterState, pageCounterState } from "../libs/store"; import { useRecoilState } from "recoil"; +import { apiBaseUrl } from "../vars/variables"; export default function Countries(props: any) { const [country, setCountry] = useRecoilState(countryFilterState); const [pageFilter, setPageFilter] = useRecoilState(pageCounterState); - const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); const fetcher = (...args: [any, any]) => fetch(...args).then((res) => res.json()); const { data: countries, error } = useSWR( - `${apiBaseUrlGlobal}/country-codes`, + `${apiBaseUrl}/country-codes`, fetcher ); diff --git a/components/itemSubscriptionSSoscks.tsx b/components/itemSubscriptionSSoscks.tsx index 1aea16e..68698d8 100644 --- a/components/itemSubscriptionSSoscks.tsx +++ b/components/itemSubscriptionSSoscks.tsx @@ -6,12 +6,12 @@ import { } from "@tabler/icons-react"; import { useState } from "react"; import { useRecoilState } from "recoil"; -import { apiBaseUrl } from "../libs/store"; +import { apiBaseUrl } from "../vars/variables"; + export default function ItemSubscriptionSSocks(props: any) { const [isOver, setIsOver] = useState(false); const [timeCopy, setTimeCopy] = useState(false); - const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); const handleOver = () => { @@ -25,7 +25,7 @@ export default function ItemSubscriptionSSocks(props: any) { setTimeCopy(true); navigator.clipboard - .writeText(`${apiBaseUrlGlobal}/sub/`) + .writeText(`${apiBaseUrl}/sub/`) .then(() => { setTimeout(() => { setTimeCopy(false); diff --git a/components/itemSubscriptionV2Ray.tsx b/components/itemSubscriptionV2Ray.tsx index 55561c9..814444b 100644 --- a/components/itemSubscriptionV2Ray.tsx +++ b/components/itemSubscriptionV2Ray.tsx @@ -1,12 +1,12 @@ import { IconCheck, IconClipboardCopy } from "@tabler/icons-react"; import { useState } from "react"; import { useRecoilState } from "recoil"; -import { apiBaseUrl } from "../libs/store"; +import { apiBaseUrl } from "../vars/variables"; + export default function ItemSubscriptionV2Ray(props: any) { const [isOver, setIsOver] = useState(false); const [timeCopy, setTimeCopy] = useState(false); - const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); const handleOver = () => { @@ -20,7 +20,7 @@ export default function ItemSubscriptionV2Ray(props: any) { setTimeCopy(true); navigator.clipboard - .writeText(`${apiBaseUrlGlobal}/b64sub/`) + .writeText(`${apiBaseUrl}/b64sub/`) .then(() => { setTimeout(() => { setTimeCopy(false); diff --git a/components/layout.tsx b/components/layout.tsx index 2c717c1..9379e9b 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -3,14 +3,14 @@ import Navbar from "./navbar"; import Sidebar from "./sidebar"; import ModalQR from "./modalQR"; import { useRecoilState } from "recoil"; -import { apiBaseUrl, proxiesObj, qrScreen } from "../libs/store"; +import { proxiesObj, qrScreen } from "../libs/store"; import { useEffect, useState } from "react"; import useSWR from "swr"; import { - pageCounterState, - portFilterState, - countryFilterState, - loaderPage, + pageCounterState, + portFilterState, + countryFilterState, + loaderPage, } from "../libs/store"; import { Player } from "@lottiefiles/react-lottie-player"; import Loader from "./loader"; @@ -19,91 +19,90 @@ import ServerStatsCard from "./serversStatsCard"; import ItemSubscription from "./itemSubscriptionSSoscks"; import ItemSubscriptionSSocks from "./itemSubscriptionSSoscks"; import ItemSubscriptionV2Ray from "./itemSubscriptionV2Ray"; +import { apiBaseUrl } from "../vars/variables"; export default function Layout({ children }: any) { - const [qrScreenCode, setQRScreenCode] = useRecoilState(qrScreen); - const [pageCounter, setPageCounter] = useRecoilState(pageCounterState); - const [portFilter, setPortFilter] = useRecoilState(portFilterState); - const [countryFilter, setCountryFilter] = useRecoilState(countryFilterState); - const [loader, setLoader] = useRecoilState(loaderPage); - const [prox, setProx] = useRecoilState(proxiesObj); - const [time, setTime] = useState(""); - const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); + const [qrScreenCode, setQRScreenCode] = useRecoilState(qrScreen); + const [pageCounter, setPageCounter] = useRecoilState(pageCounterState); + const [portFilter, setPortFilter] = useRecoilState(portFilterState); + const [countryFilter, setCountryFilter] = useRecoilState(countryFilterState); + const [loader, setLoader] = useRecoilState(loaderPage); + const [prox, setProx] = useRecoilState(proxiesObj); + const [time, setTime] = useState(""); + const fetcher = (...args: [any, any]) => + fetch(...args).then((res) => res.json()); + const { data: proxies, error } = useSWR( + `${apiBaseUrl}/proxies/?format=json&is_active=true&location_country_code=` + + countryFilter + + "&port=" + + portFilter + + "&page=" + + pageCounter?.toString(), + fetcher + ); - const fetcher = (...args: [any, any]) => - fetch(...args).then((res) => res.json()); - const { data: proxies, error } = useSWR( - `${apiBaseUrlGlobal}/proxies/?format=json&is_active=true&location_country_code=` + - countryFilter + - "&port=" + - portFilter + - "&page=" + - pageCounter?.toString(), - fetcher - ); + if (error) { + <>Error; + } + if (!proxies) { + <>Loading; + } - if (error) { - <>Error; - } - if (!proxies) { - <>Loading; - } + useEffect(() => { + document + .querySelector("body") + ?.classList.add( + "overflow-y-scroll", + "bg-[#F8F8F8]", + "dark:bg-[#141414]", + "text-[#212121]" + ); + if (proxies) { + setProx(proxies); + if (countryFilter === "" && pageCounter == 1 && portFilter === "") { + setTime(proxies?.results[0]?.last_checked); + } + } + window.addEventListener("load", function () { + (window as any).wpcc?.init({ + border: "thin", + corners: "small", + colors: { + popup: { + background: "#f6f6f6", + text: "#000000", + border: "#cfcfcf", + }, + button: { + background: "#303030", + text: "#ffffff", + }, + }, + position: "bottom", + }); + }); + }, [proxies]); - useEffect(() => { - document - .querySelector("body") - ?.classList.add( - "overflow-y-scroll", - "bg-[#F8F8F8]", - "dark:bg-[#141414]", - "text-[#212121]" - ); - if (proxies) { - setProx(proxies); - if (countryFilter === "" && pageCounter == 1 && portFilter === "") { - setTime(proxies?.results[0]?.last_checked); - } - } - window.addEventListener("load", function() { - (window as any).wpcc?.init({ - border: "thin", - corners: "small", - colors: { - popup: { - background: "#f6f6f6", - text: "#000000", - border: "#cfcfcf", - }, - button: { - background: "#303030", - text: "#ffffff", - }, - }, - position: "bottom", - }); - }); - }, [proxies]); - - return ( - <> - {/* */} - - - {qrScreenCode && } -
-
-
- -
- - -
-
- -
- {children} -
- - ); + return ( + <> + {/* */} + + + {qrScreenCode && } +
+
+
+ +
+ + +
+
+ +
+ {children} +
+ + ); } diff --git a/components/meta.tsx b/components/meta.tsx index 6365f6e..1aa632c 100644 --- a/components/meta.tsx +++ b/components/meta.tsx @@ -2,7 +2,8 @@ import Head, { defaultHead } from "next/head"; import Script from "next/script"; import { useEffect } from "react"; import { useRecoilState } from "recoil"; -import { apiBaseUrl, countryFilterState, pageCounterState, portFilterState } from "../libs/store"; +import { countryFilterState, pageCounterState, portFilterState } from "../libs/store"; +import { apiBaseUrl } from "../vars/variables"; type Props = { title: string; @@ -14,7 +15,6 @@ export function Meta({ title, keywords, description }: Props) { const [pageCounter, setPageCounter] = useRecoilState(pageCounterState); const [portFilter, setPortFilter] = useRecoilState(portFilterState); const [countryFilter, setCountryFilter] = useRecoilState(countryFilterState); - const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); return ( @@ -25,7 +25,7 @@ export function Meta({ title, keywords, description }: Props) { {title} diff --git a/components/ports.tsx b/components/ports.tsx index 9b3cf68..8a3ccc2 100644 --- a/components/ports.tsx +++ b/components/ports.tsx @@ -1,19 +1,19 @@ import useSWR from "swr"; import React, { useEffect } from "react"; -import { portFilterState, pageCounterState, apiBaseUrl } from "../libs/store"; +import { portFilterState, pageCounterState } from "../libs/store"; import { useRecoilState } from "recoil"; +import { apiBaseUrl } from "../vars/variables"; export default function Ports(props: any) { const [portFilter, setPortFilter] = useRecoilState(portFilterState); const [pageFilter, setPageFilter] = useRecoilState(pageCounterState); - const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); const fetcher = (...args: [any, any]) => fetch(...args).then((res) => res.json()); const { data: ports, error } = useSWR( - `${apiBaseUrlGlobal}/ports/`, + `${apiBaseUrl}/ports/`, fetcher ); diff --git a/components/serversListCols.tsx b/components/serversListCols.tsx index 8c3780b..ae5c4e7 100644 --- a/components/serversListCols.tsx +++ b/components/serversListCols.tsx @@ -16,10 +16,10 @@ import { proxiesCount, proxiesObj, loaderPage, - apiBaseUrl, } from "../libs/store"; import ServerSkeleton from "./serverSkeleton"; import ServerCol from "./serverCol"; +import { apiBaseUrl } from "../vars/variables"; export default function ServersListCols(props: any) { const [pageCounter, setPageCounter] = useRecoilState(pageCounterState); @@ -31,12 +31,11 @@ export default function ServersListCols(props: any) { const [proxyCounter, setProxyCounter] = useRecoilState(proxiesCount); // const [data, setData] = useRecoilState(proxiesObj) const [noResults, setNoResults] = useState("No results has been found"); - const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); const fetcher = (...args: [any, any]) => fetch(...args).then((res) => res.json()); const { data, error, mutate } = useSWR( - `${apiBaseUrlGlobal}/proxies/?format=json&is_active=true&location_country_code=` + + `${apiBaseUrl}/proxies/?format=json&is_active=true&location_country_code=` + countryFilter + "&port=" + portFilter + diff --git a/components/v2raySubs.tsx b/components/v2raySubs.tsx index ee6178a..8158598 100644 --- a/components/v2raySubs.tsx +++ b/components/v2raySubs.tsx @@ -1,10 +1,9 @@ import { useState } from "react"; import { useRecoilState } from "recoil"; -import { apiBaseUrl } from "../libs/store"; +import { apiBaseUrl } from "../vars/variables"; export default function V2raySubs() { const [copyLink, setCopyLink] = useState(false); - const [apiBaseUrlGlobal, setApiBaseUrlGlobal] = useRecoilState(apiBaseUrl); return ( @@ -22,7 +21,7 @@ export default function V2raySubs() { { navigator.clipboard.writeText( - `${apiBaseUrlGlobal}/b64sub/` + `${apiBaseUrl}/b64sub/` ); setCopyLink(true); setTimeout(() => { diff --git a/libs/store.tsx b/libs/store.tsx index cc642c6..e12386e 100644 --- a/libs/store.tsx +++ b/libs/store.tsx @@ -56,9 +56,4 @@ export const loaderPage = atom({ export const viewDataLayout = atom({ key: 'viewDataLayout', default: 'details' -}) - -export const apiBaseUrl = atom({ - key: 'apiBaseUrl', - default: process.env.BASE_URL }) \ No newline at end of file diff --git a/next.config.js b/next.config.js index 71230fb..2c47348 100644 --- a/next.config.js +++ b/next.config.js @@ -3,9 +3,7 @@ const nextConfig = { distDir: 'dist', reactStrictMode: true, swcMinify: true, - // env: { - // BASE_URL:'https://shadowmere.akiel.dev/api', - // }, + staticPageGenerationTimeout: 1000, images: { unoptimized: true, diff --git a/vars/variables.ts b/vars/variables.ts new file mode 100644 index 0000000..6469702 --- /dev/null +++ b/vars/variables.ts @@ -0,0 +1 @@ +export const apiBaseUrl = process.env.NEXT_PUBLIC_BASE_URL \ No newline at end of file From a6e97f4ea5e9f75fabb99605cc43c6064e1bbb29 Mon Sep 17 00:00:00 2001 From: swordfest Date: Mon, 15 Jul 2024 14:19:51 -0400 Subject: [PATCH 04/10] some other fixes --- components/detailsLayoutButton.tsx | 2 +- components/layout.tsx | 2 +- components/modalQR.tsx | 9 ++++++--- components/serverCol.tsx | 3 ++- pages/about.tsx | 2 +- pages/subscription.tsx | 2 +- pages/why-shadowmere.tsx | 6 ++++-- vars/variables.ts | 3 ++- 8 files changed, 18 insertions(+), 11 deletions(-) diff --git a/components/detailsLayoutButton.tsx b/components/detailsLayoutButton.tsx index b2d032f..55b8140 100644 --- a/components/detailsLayoutButton.tsx +++ b/components/detailsLayoutButton.tsx @@ -15,7 +15,7 @@ export default function DetailsLayoutButton() { useEffect(() => { const view = JSON.parse(localStorage.getItem('viewMode')!) setViewMode(view) - }, []) + }, [setViewMode]) return (
diff --git a/components/modalQR.tsx b/components/modalQR.tsx index 8c646c3..d351567 100644 --- a/components/modalQR.tsx +++ b/components/modalQR.tsx @@ -1,10 +1,13 @@ import Image from 'next/image' import { proxyId, qrScreen } from '../libs/store' import { useRecoilState } from 'recoil' +import { apiBaseUrl, rootUrl } from '../vars/variables' + export default function ModalQR (props: any) { const [proxID, setProxID] = useRecoilState(proxyId) const [qrActive, setQrActive] = useRecoilState(qrScreen) + const handleClick = () => { setQrActive(false) @@ -13,9 +16,9 @@ export default function ModalQR (props: any) { return (
{/*
*/} -
-
- QR Code for server address +
+
+ QR Code for server address

diff --git a/components/serverCol.tsx b/components/serverCol.tsx index 5b65585..9ab1820 100644 --- a/components/serverCol.tsx +++ b/components/serverCol.tsx @@ -14,6 +14,7 @@ import { import NewFeature from "./newFeature"; import NewServer from "./newServer"; import Link from "next/link"; +import { rootUrl } from "../vars/variables"; export default function ServerCol(dataServer: { proxy: any }) { const [timeCopy, setTimeCopy] = useState(false); @@ -177,7 +178,7 @@ export default function ServerCol(dataServer: { proxy: any }) { diff --git a/pages/about.tsx b/pages/about.tsx index 6fe63e4..87a806a 100644 --- a/pages/about.tsx +++ b/pages/about.tsx @@ -11,7 +11,7 @@ export default function About() { if (router.pathname === '/about'){ setTabActive('about') } - },[]) + },[router.pathname, setTabActive]) return (
diff --git a/pages/subscription.tsx b/pages/subscription.tsx index 43aa89a..aece8a7 100644 --- a/pages/subscription.tsx +++ b/pages/subscription.tsx @@ -29,7 +29,7 @@ export default function Sub() { useEffect(()=>{ setTabActive('sub') - },[]) + },[setTabActive]) const handleClick = (t: string) => { setTab(t); diff --git a/pages/why-shadowmere.tsx b/pages/why-shadowmere.tsx index a94c117..bd1db80 100644 --- a/pages/why-shadowmere.tsx +++ b/pages/why-shadowmere.tsx @@ -12,7 +12,7 @@ export default function Why() { useEffect(()=>{ setTabActive('why') - },[]) + },[setTabActive]) return ( @@ -24,7 +24,9 @@ export default function Why() { since her first appearance in The Elder Scrolls IV: Oblivion's Dark Brotherhood questline.

- Date: Mon, 15 Jul 2024 14:22:26 -0400 Subject: [PATCH 05/10] Update layout.tsx --- components/layout.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/components/layout.tsx b/components/layout.tsx index fc981f1..f762b1a 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -106,7 +106,6 @@ export default function Layout({ children }: any) { ); -======= useEffect(() => { document .querySelector("body") From 158ff098198da949d43dd8e2aeb4bcedbfe4ddef Mon Sep 17 00:00:00 2001 From: swordfest Date: Mon, 15 Jul 2024 14:35:42 -0400 Subject: [PATCH 06/10] some minor changes --- components/countries.tsx | 9 --------- next.config.js | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/components/countries.tsx b/components/countries.tsx index 0115808..6f9cba3 100644 --- a/components/countries.tsx +++ b/components/countries.tsx @@ -35,15 +35,6 @@ export default function Countries(props: any) { setPageFilter(1); } }; - - - const fetcher = (...args: [any, any]) => - fetch(...args).then((res) => res.json()); - - const { data: countries, error } = useSWR( - "https://shadowmere.akiel.dev/api/country-codes", - fetcher - ); if (error) return <>Error; diff --git a/next.config.js b/next.config.js index 2c47348..53fb01e 100644 --- a/next.config.js +++ b/next.config.js @@ -11,13 +11,13 @@ const nextConfig = { { protocol: 'https', hostname: 'vangogh.teespring.com', - port: '', + port: '80', pathname: '/v3/image/**', }, { protocol: 'https', hostname: 'mockup-api.teespring.com', - port: '', + port: '80', pathname: '/v3/image/**', }, ], From abfb8d2d64f963f63abea123824f79a356b795ba Mon Sep 17 00:00:00 2001 From: swordfest Date: Mon, 15 Jul 2024 16:07:17 -0400 Subject: [PATCH 07/10] some other details --- .eslintrc.json | 3 +- components/layout.tsx | 118 +++++++++++++++++++++--------------------- package.json | 1 + yarn.lock | 5 ++ 4 files changed, 67 insertions(+), 60 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index bffb357..bc61de3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,4 @@ { - "extends": "next/core-web-vitals" + // "extends": "next/core-web-vitals", + "extends": ["next/core-web-vitals", "next", "prettier"] } diff --git a/components/layout.tsx b/components/layout.tsx index 1ee853e..74d6208 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -50,6 +50,62 @@ export default function Layout({ children }: any) { <>Loading; } + useEffect(() => { + document + .querySelector("body") + ?.classList.add( + "overflow-y-scroll", + "bg-[#F8F8F8]", + "dark:bg-[#141414]", + "text-[#212121]" + ); + setProx(proxies); + setTime(proxies?.results[0]?.last_checked); + window.addEventListener("load", function () { + (window as any).wpcc?.init({ + border: "thin", + corners: "small", + colors: { + popup: { + background: "#f6f6f6", + text: "#000000", + border: "#cfcfcf", + }, + button: { + background: "#303030", + text: "#ffffff", + }, + }, + position: "bottom", + }); + }); + }, [ + proxies, + countryFilter === "" && pageCounter == 1 && portFilter === "", + setProx, + ]); + + return ( + <> + {/* */} + + + {qrScreenCode && } +
+
+
+ +
+ + +
+
+ +
+ {children} +
+ + ); useEffect(() => { document .querySelector("body") @@ -91,7 +147,7 @@ export default function Layout({ children }: any) { {qrScreenCode && } -
+
@@ -101,67 +157,11 @@ export default function Layout({ children }: any) {
+
{children} + ); - useEffect(() => { - document - .querySelector("body") - ?.classList.add( - "overflow-y-scroll", - "bg-[#F8F8F8]", - "dark:bg-[#141414]", - "text-[#212121]" - ); - if (proxies) { - setProx(proxies); - if (countryFilter === "" && pageCounter == 1 && portFilter === "") { - setTime(proxies?.results[0]?.last_checked); - } - } - window.addEventListener("load", function() { - (window as any).wpcc?.init({ - border: "thin", - corners: "small", - colors: { - popup: { - background: "#f6f6f6", - text: "#000000", - border: "#cfcfcf", - }, - button: { - background: "#303030", - text: "#ffffff", - }, - }, - position: "bottom", - }); - }); - }, [proxies, countryFilter, pageCounter, portFilter, setProx]); - - return ( - <> - {/* */} - - - {qrScreenCode && } -
-
-
- -
- - -
-
- - -
- {children} - -
- - ); } diff --git a/package.json b/package.json index 06d727c..f6c9b35 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", "autoprefixer": "^10.4.13", + "eslint-config-prettier": "^9.1.0", "postcss": "^8.4.19", "tailwindcss": "^3.2.4" } diff --git a/yarn.lock b/yarn.lock index 755c513..fb0fd8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -876,6 +876,11 @@ eslint-config-next@13.0.5: eslint-plugin-react "^7.31.7" eslint-plugin-react-hooks "^4.5.0" +eslint-config-prettier@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f" + integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw== + eslint-import-resolver-node@^0.3.6, eslint-import-resolver-node@^0.3.7: version "0.3.7" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.7.tgz#83b375187d412324a1963d84fa664377a23eb4d7" From 59d023b6dfcd6e781d1d260032d03a4a4a19c165 Mon Sep 17 00:00:00 2001 From: swordfest Date: Mon, 15 Jul 2024 16:09:33 -0400 Subject: [PATCH 08/10] Extract it to a separate variable (cond on useEffect) --- components/layout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/layout.tsx b/components/layout.tsx index 74d6208..29670f6 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -81,7 +81,7 @@ export default function Layout({ children }: any) { }); }, [ proxies, - countryFilter === "" && pageCounter == 1 && portFilter === "", + countryFilter === "", pageCounter == 1, portFilter === "", setProx, ]); From ed5eeb4483832b58b830acda86256bfd2576f516 Mon Sep 17 00:00:00 2001 From: swordfest Date: Mon, 15 Jul 2024 16:11:53 -0400 Subject: [PATCH 09/10] fixing dependencies 2nd try --- components/layout.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/layout.tsx b/components/layout.tsx index 29670f6..10caede 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -79,11 +79,7 @@ export default function Layout({ children }: any) { position: "bottom", }); }); - }, [ - proxies, - countryFilter === "", pageCounter == 1, portFilter === "", - setProx, - ]); + }, [proxies, countryFilter, pageCounter, portFilter, setProx]); return ( <> From 0fe20d2b9a155ba4b0fb3650dc41e4a5112c09f5 Mon Sep 17 00:00:00 2001 From: swordfest Date: Mon, 15 Jul 2024 16:14:29 -0400 Subject: [PATCH 10/10] fix --- components/layout.tsx | 97 +++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 59 deletions(-) diff --git a/components/layout.tsx b/components/layout.tsx index 10caede..c41c342 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -50,67 +50,46 @@ export default function Layout({ children }: any) { <>Loading; } - useEffect(() => { - document - .querySelector("body") - ?.classList.add( - "overflow-y-scroll", - "bg-[#F8F8F8]", - "dark:bg-[#141414]", - "text-[#212121]" - ); - setProx(proxies); - setTime(proxies?.results[0]?.last_checked); - window.addEventListener("load", function () { - (window as any).wpcc?.init({ - border: "thin", - corners: "small", - colors: { - popup: { - background: "#f6f6f6", - text: "#000000", - border: "#cfcfcf", - }, - button: { - background: "#303030", - text: "#ffffff", - }, - }, - position: "bottom", - }); - }); - }, [proxies, countryFilter, pageCounter, portFilter, setProx]); + // useEffect(() => { + // document + // .querySelector("body") + // ?.classList.add( + // "overflow-y-scroll", + // "bg-[#F8F8F8]", + // "dark:bg-[#141414]", + // "text-[#212121]" + // ); + // setProx(proxies); + // setTime(proxies?.results[0]?.last_checked); + // window.addEventListener("load", function () { + // (window as any).wpcc?.init({ + // border: "thin", + // corners: "small", + // colors: { + // popup: { + // background: "#f6f6f6", + // text: "#000000", + // border: "#cfcfcf", + // }, + // button: { + // background: "#303030", + // text: "#ffffff", + // }, + // }, + // position: "bottom", + // }); + // }); + // }, [proxies, countryFilter, pageCounter, portFilter, setProx]); - return ( - <> - {/* */} - - - {qrScreenCode && } -
-
-
- -
- - -
-
- -
- {children} -
- - ); useEffect(() => { document - .querySelector("body") - ?.classList.add( - "overflow-y-scroll", - "bg-[#F8F8F8]", - "dark:bg-[#141414]", - "text-[#212121]" - ); + .querySelector("body") + ?.classList.add( + "overflow-y-scroll", + "bg-[#F8F8F8]", + "dark:bg-[#141414]", + "text-[#212121]" + ); if (proxies) { setProx(proxies); if (countryFilter === "" && pageCounter == 1 && portFilter === "") { @@ -136,7 +115,7 @@ export default function Layout({ children }: any) { }); }); }, [proxies, countryFilter, pageCounter, portFilter, setProx]); - + return ( <> {/* */}