From 92b21dd9f20d45acff2733395d7d78b5574f027a Mon Sep 17 00:00:00 2001 From: Juraj Uhlar Date: Fri, 11 Oct 2024 09:53:22 +0200 Subject: [PATCH] Chore: Stop using pages router INTER-911 (#167) * chore: move remaining page and handler to `app` * chore: clean up files * chore: consolidate layour * chore: more file clean up * chore: fix cors * chore: clean up cors * chore: clean up cors * chore: fix seo * chore: move files around --- cron-jobs/delete_expired_ip_rules.ts | 2 +- e2e/sms-pumping/bot-unprotected.spec.ts | 2 +- next-env.d.ts | 1 - next.config.js | 2 +- src/Layout.tsx | 18 ---- .../LayoutUI.module.scss} | 0 src/app/LayoutUI.tsx | 22 ++++ src/{ => app}/Providers.tsx | 4 +- src/app/api/event/[requestId]/route.ts | 101 ++++++++++++++++++ src/app/appLayout.tsx | 9 -- src/app/bot-firewall/BotFirewall.tsx | 12 +-- .../api/block-ip/buildFirewallRules.ts | 2 +- src/app/bot-firewall/api/block-ip/route.ts | 2 +- .../api/get-bot-visits/botVisitDatabase.ts | 2 +- .../components/botFirewallComponents.tsx | 4 +- src/app/bot-firewall/embed/page.tsx | 4 +- src/app/bot-firewall/page.tsx | 4 +- src/app/coupon-fraud/CouponFraud.tsx | 12 +-- src/app/coupon-fraud/embed/page.tsx | 4 +- src/app/coupon-fraud/page.tsx | 4 +- .../CredentialStuffing.tsx | 10 +- src/app/credential-stuffing/embed/page.tsx | 4 +- src/app/credential-stuffing/page.tsx | 4 +- src/app/layout.tsx | 6 +- src/app/loan-risk/LoanRisk.tsx | 16 +-- .../calculate-month-installment.ts | 0 .../api/request-loan/evaluateLoanRequest.ts | 2 +- src/app/loan-risk/embed/page.tsx | 4 +- src/app/loan-risk/page.tsx | 4 +- .../page.module.scss} | 0 src/{pages/index.tsx => app/page.tsx} | 20 ++-- src/app/payment-fraud/PaymentFraud.tsx | 10 +- src/app/payment-fraud/embed/page.tsx | 4 +- src/app/payment-fraud/page.tsx | 4 +- src/app/paywall/Paywall.tsx | 4 +- src/app/paywall/api/article/[id]/route.ts | 2 +- src/app/paywall/article/[id]/Article.tsx | 8 +- src/app/paywall/article/[id]/embed/page.tsx | 4 +- src/app/paywall/article/[id]/page.tsx | 4 +- src/app/paywall/embed/page.tsx | 4 +- src/app/paywall/page.tsx | 4 +- src/app/personalization/Personalization.tsx | 10 +- .../components/productCard.tsx | 2 +- src/app/personalization/embed/page.tsx | 4 +- .../use-personalization-notification.tsx | 4 +- src/app/personalization/page.tsx | 4 +- src/app/playground/Playground.tsx | 18 ++-- .../components/HowToUseThisPlayground.tsx | 4 +- .../playground/components/RefreshButton.tsx | 2 +- src/app/playground/embed/page.tsx | 4 +- src/app/playground/page.tsx | 4 +- src/app/sitemap.xml/route.ts | 30 ++++++ src/app/sms-pumping/SmsPumping.tsx | 12 +-- .../api/send-verification-sms/route.ts | 4 +- src/app/sms-pumping/api/smsPumpingConst.ts | 4 +- .../components/PhoneNumberForm.tsx | 2 +- .../components/SendSMSMessageButton.tsx | 4 +- .../sms-pumping/components/SubmitCodeForm.tsx | 6 +- src/app/sms-pumping/embed/page.tsx | 4 +- src/app/sms-pumping/page.tsx | 4 +- src/app/vpn-detection/VpnDetectionUseCase.tsx | 14 +-- .../vpn-detection/api/activate-ppp/route.ts | 2 +- src/app/vpn-detection/embed/page.tsx | 4 +- src/app/vpn-detection/page.tsx | 4 +- src/app/web-scraping/WebScraping.tsx | 12 +-- src/app/web-scraping/api/flights/route.ts | 2 +- .../web-scraping/components/FlightCard.tsx | 4 +- src/app/web-scraping/embed/page.tsx | 4 +- src/app/web-scraping/page.tsx | 4 +- .../Accordion/Accordion.module.scss | 0 .../{common => }/Accordion/Accordion.tsx | 4 +- .../components/{common => }/Alert/Alert.tsx | 8 +- .../{common => }/Alert/alert.module.scss | 0 .../components/{common => }/Alert/error.svg | 0 .../components/{common => }/Alert/sucess.svg | 0 .../components/{common => }/Alert/warning.svg | 0 .../BackArrow/BackArrow.module.scss | 0 .../{common => }/BackArrow/BackArrow.tsx | 2 +- .../{common => }/Button/Button.module.scss | 0 .../components/{common => }/Button/Button.tsx | 0 .../components/{common => }/Cart/Cart.tsx | 6 +- .../{common => }/Cart/cart.module.scss | 0 .../CodeSnippet/CodeSnippet.module.scss | 0 .../{common => }/CodeSnippet/CodeSnippet.tsx | 4 +- .../Collapsible/Collapsible.module.scss | 0 .../{common => }/Collapsible/Collapsible.tsx | 0 .../Container/Container.module.scss | 0 .../{common => }/Container/index.tsx | 0 .../CopyButton/CopyButton.module.scss | 0 .../{common => }/CopyButton/CopyButton.tsx | 4 +- .../{common => }/Dropdown/ArrowSVG.svg | 0 .../Dropdown/Dropdown.module.scss | 0 .../{common => }/Dropdown/Dropdown.tsx | 2 +- .../DropdownMenu/DropdownMenu.module.scss | 0 .../DropdownMenu/DropdownMenu.tsx | 4 +- .../FancyNumberedList.module.scss | 0 .../FancyNumberedList/FancyNumberedList.tsx | 0 .../{common => }/Footer/Footer.module.scss | 0 .../components/{common => }/Footer/Footer.tsx | 2 +- .../components/{common => }/Footer/github.svg | 0 .../{common => }/Footer/linkedin.svg | 0 .../{common => }/Footer/twitter.svg | 0 .../{common => }/Header/Header.module.scss | 0 .../components/{common => }/Header/Header.tsx | 8 +- .../{common => }/Header/StarSVG.svg | 0 .../components/{common => }/Header/fpjs.svg | 0 .../{common => }/Header/fpjsDark.svg | 0 .../HeaderBar/HeaderBar.module.scss | 0 .../{common => }/HeaderBar/HeaderBar.tsx | 2 +- .../InputNumberWithUnits.tsx | 0 .../InputTextWithUnits.module.scss | 0 .../MobileNavbar/MobileNavbar.module.scss | 0 .../MobileNavbar/MobileNavbar.tsx | 8 +- .../ResourceLinks/ResourceLinks.module.scss | 0 .../ResourceLinks/ResourceLinks.tsx | 2 +- .../ScrollArea/ScrollArea.module.scss | 0 .../{common => }/ScrollArea/ScrollArea.tsx | 0 .../{common => }/Select/Select.module.scss | 0 .../components/{common => }/Select/Select.tsx | 2 +- .../{common => }/Slider/Slider.module.scss | 0 .../components/{common => }/Slider/Slider.tsx | 0 .../{common => }/Spinner/Spinner.module.scss | 0 .../{common => }/Spinner/Spinner.tsx | 2 +- .../UseCaseWrapper/RestartHint.tsx | 0 .../UseCaseWrapper/UseCaseWrapper.module.scss | 0 .../UseCaseWrapper/UseCaseWrapper.tsx | 12 +-- .../{common => }/UseCaseWrapper/lightbulb.svg | 0 src/client/components/common/seo.tsx | 74 ------------- .../{common => }/componentUtils.tsx | 0 .../{components/common => }/content.tsx | 26 ++--- src/{ => client}/fonts/Inter-SemiBold.ttf | Bin .../fonts/JetBrainsMono-Bold.woff | Bin .../fonts/JetBrainsMono-Bold.woff2 | Bin .../fonts/JetBrainsMono-ExtraBold.woff | Bin .../fonts/JetBrainsMono-ExtraBold.woff2 | Bin .../fonts/JetBrainsMono-Medium.woff | Bin .../fonts/JetBrainsMono-Medium.woff2 | Bin .../fonts/JetBrainsMono-Regular.woff | Bin .../fonts/JetBrainsMono-Regular.woff2 | Bin .../fonts/inter-v12-latin-200.woff | Bin .../fonts/inter-v12-latin-200.woff2 | Bin .../fonts/inter-v12-latin-500.woff | Bin .../fonts/inter-v12-latin-500.woff2 | Bin .../fonts/inter-v12-latin-600.woff | Bin .../fonts/inter-v12-latin-600.woff2 | Bin .../fonts/inter-v12-latin-700.woff | Bin .../fonts/inter-v12-latin-700.woff2 | Bin .../fonts/inter-v12-latin-regular.woff | Bin .../fonts/inter-v12-latin-regular.woff2 | Bin src/client/hooks/useReset/useReset.tsx | 2 +- .../img/{InfoIcon.svg => InfoIconSvg.svg} | 0 src/client/seo.tsx | 44 ++++++++ src/{ => client}/styles/_animations.scss | 0 src/{ => client}/styles/_functions.scss | 0 src/{ => client}/styles/_mixins.scss | 0 src/{ => client}/styles/_typography.scss | 0 src/{ => client}/styles/_variables.scss | 0 src/{ => client}/styles/common.scss | 0 .../styles/custom-properties.scss | 0 src/{ => client}/styles/forms.module.scss | 0 src/{ => client}/styles/global-styles.scss | 0 .../styles/vendors/code-theme.scss | 0 .../styles/vendors/normalize.scss | 0 src/{ => client}/styles/vendors/swiper.scss | 0 src/{ => client}/styles/vendors/tippy.scss | 0 src/pages/.DS_Store | Bin 6148 -> 0 bytes src/pages/_app.tsx | 26 ----- src/pages/_document.tsx | 15 --- src/pages/api/event/[requestId].ts | 86 --------------- src/pages/sitemap.xml.ts | 38 ------- src/server/checks.ts | 2 +- src/shared/utils/date.ts | 7 -- src/{shared => }/utils/link.ts | 0 src/{shared => }/utils/locationUtils.test.ts | 0 src/{shared => }/utils/locationUtils.ts | 2 +- src/{shared => utils}/timeUtils.spec.ts | 0 src/{shared => utils}/timeUtils.ts | 8 ++ src/{shared => utils}/types.ts | 0 src/{shared => utils}/utils.test.ts | 0 src/{shared => utils}/utils.ts | 0 180 files changed, 419 insertions(+), 488 deletions(-) delete mode 100644 src/Layout.tsx rename src/{styles/layout.module.scss => app/LayoutUI.module.scss} (100%) create mode 100644 src/app/LayoutUI.tsx rename src/{ => app}/Providers.tsx (92%) create mode 100644 src/app/api/event/[requestId]/route.ts delete mode 100644 src/app/appLayout.tsx rename src/{shared/loan-risk => app/loan-risk/api/request-loan}/calculate-month-installment.ts (100%) rename src/{pages/index.module.scss => app/page.module.scss} (100%) rename src/{pages/index.tsx => app/page.tsx} (77%) create mode 100644 src/app/sitemap.xml/route.ts rename src/client/components/{common => }/Accordion/Accordion.module.scss (100%) rename src/client/components/{common => }/Accordion/Accordion.tsx (93%) rename src/client/components/{common => }/Alert/Alert.tsx (93%) rename src/client/components/{common => }/Alert/alert.module.scss (100%) rename src/client/components/{common => }/Alert/error.svg (100%) rename src/client/components/{common => }/Alert/sucess.svg (100%) rename src/client/components/{common => }/Alert/warning.svg (100%) rename src/client/components/{common => }/BackArrow/BackArrow.module.scss (100%) rename src/client/components/{common => }/BackArrow/BackArrow.tsx (91%) rename src/client/components/{common => }/Button/Button.module.scss (100%) rename src/client/components/{common => }/Button/Button.tsx (100%) rename src/client/components/{common => }/Cart/Cart.tsx (95%) rename src/client/components/{common => }/Cart/cart.module.scss (100%) rename src/client/components/{common => }/CodeSnippet/CodeSnippet.module.scss (100%) rename src/client/components/{common => }/CodeSnippet/CodeSnippet.tsx (96%) rename src/client/components/{common => }/Collapsible/Collapsible.module.scss (100%) rename src/client/components/{common => }/Collapsible/Collapsible.tsx (100%) rename src/client/components/{common => }/Container/Container.module.scss (100%) rename src/client/components/{common => }/Container/index.tsx (100%) rename src/client/components/{common => }/CopyButton/CopyButton.module.scss (100%) rename src/client/components/{common => }/CopyButton/CopyButton.tsx (90%) rename src/client/components/{common => }/Dropdown/ArrowSVG.svg (100%) rename src/client/components/{common => }/Dropdown/Dropdown.module.scss (100%) rename src/client/components/{common => }/Dropdown/Dropdown.tsx (99%) rename src/client/components/{common => }/DropdownMenu/DropdownMenu.module.scss (100%) rename src/client/components/{common => }/DropdownMenu/DropdownMenu.tsx (94%) rename src/client/components/{common => }/FancyNumberedList/FancyNumberedList.module.scss (100%) rename src/client/components/{common => }/FancyNumberedList/FancyNumberedList.tsx (100%) rename src/client/components/{common => }/Footer/Footer.module.scss (100%) rename src/client/components/{common => }/Footer/Footer.tsx (98%) rename src/client/components/{common => }/Footer/github.svg (100%) rename src/client/components/{common => }/Footer/linkedin.svg (100%) rename src/client/components/{common => }/Footer/twitter.svg (100%) rename src/client/components/{common => }/Header/Header.module.scss (100%) rename src/client/components/{common => }/Header/Header.tsx (96%) rename src/client/components/{common => }/Header/StarSVG.svg (100%) rename src/client/components/{common => }/Header/fpjs.svg (100%) rename src/client/components/{common => }/Header/fpjsDark.svg (100%) rename src/client/components/{common => }/HeaderBar/HeaderBar.module.scss (100%) rename src/client/components/{common => }/HeaderBar/HeaderBar.tsx (95%) rename src/client/components/{common => }/InputNumberWithUnits/InputNumberWithUnits.tsx (100%) rename src/client/components/{common => }/InputNumberWithUnits/InputTextWithUnits.module.scss (100%) rename src/client/components/{common => }/MobileNavbar/MobileNavbar.module.scss (100%) rename src/client/components/{common => }/MobileNavbar/MobileNavbar.tsx (95%) rename src/client/components/{common => }/ResourceLinks/ResourceLinks.module.scss (100%) rename src/client/components/{common => }/ResourceLinks/ResourceLinks.tsx (94%) rename src/client/components/{common => }/ScrollArea/ScrollArea.module.scss (100%) rename src/client/components/{common => }/ScrollArea/ScrollArea.tsx (100%) rename src/client/components/{common => }/Select/Select.module.scss (100%) rename src/client/components/{common => }/Select/Select.tsx (97%) rename src/client/components/{common => }/Slider/Slider.module.scss (100%) rename src/client/components/{common => }/Slider/Slider.tsx (100%) rename src/client/components/{common => }/Spinner/Spinner.module.scss (100%) rename src/client/components/{common => }/Spinner/Spinner.tsx (86%) rename src/client/components/{common => }/UseCaseWrapper/RestartHint.tsx (100%) rename src/client/components/{common => }/UseCaseWrapper/UseCaseWrapper.module.scss (100%) rename src/client/components/{common => }/UseCaseWrapper/UseCaseWrapper.tsx (92%) rename src/client/components/{common => }/UseCaseWrapper/lightbulb.svg (100%) delete mode 100644 src/client/components/common/seo.tsx rename src/client/components/{common => }/componentUtils.tsx (100%) rename src/client/{components/common => }/content.tsx (97%) rename src/{ => client}/fonts/Inter-SemiBold.ttf (100%) rename src/{ => client}/fonts/JetBrainsMono-Bold.woff (100%) rename src/{ => client}/fonts/JetBrainsMono-Bold.woff2 (100%) rename src/{ => client}/fonts/JetBrainsMono-ExtraBold.woff (100%) rename src/{ => client}/fonts/JetBrainsMono-ExtraBold.woff2 (100%) rename src/{ => client}/fonts/JetBrainsMono-Medium.woff (100%) rename src/{ => client}/fonts/JetBrainsMono-Medium.woff2 (100%) rename src/{ => client}/fonts/JetBrainsMono-Regular.woff (100%) rename src/{ => client}/fonts/JetBrainsMono-Regular.woff2 (100%) rename src/{ => client}/fonts/inter-v12-latin-200.woff (100%) rename src/{ => client}/fonts/inter-v12-latin-200.woff2 (100%) rename src/{ => client}/fonts/inter-v12-latin-500.woff (100%) rename src/{ => client}/fonts/inter-v12-latin-500.woff2 (100%) rename src/{ => client}/fonts/inter-v12-latin-600.woff (100%) rename src/{ => client}/fonts/inter-v12-latin-600.woff2 (100%) rename src/{ => client}/fonts/inter-v12-latin-700.woff (100%) rename src/{ => client}/fonts/inter-v12-latin-700.woff2 (100%) rename src/{ => client}/fonts/inter-v12-latin-regular.woff (100%) rename src/{ => client}/fonts/inter-v12-latin-regular.woff2 (100%) rename src/client/img/{InfoIcon.svg => InfoIconSvg.svg} (100%) create mode 100644 src/client/seo.tsx rename src/{ => client}/styles/_animations.scss (100%) rename src/{ => client}/styles/_functions.scss (100%) rename src/{ => client}/styles/_mixins.scss (100%) rename src/{ => client}/styles/_typography.scss (100%) rename src/{ => client}/styles/_variables.scss (100%) rename src/{ => client}/styles/common.scss (100%) rename src/{ => client}/styles/custom-properties.scss (100%) rename src/{ => client}/styles/forms.module.scss (100%) rename src/{ => client}/styles/global-styles.scss (100%) rename src/{ => client}/styles/vendors/code-theme.scss (100%) rename src/{ => client}/styles/vendors/normalize.scss (100%) rename src/{ => client}/styles/vendors/swiper.scss (100%) rename src/{ => client}/styles/vendors/tippy.scss (100%) delete mode 100644 src/pages/.DS_Store delete mode 100644 src/pages/_app.tsx delete mode 100644 src/pages/_document.tsx delete mode 100644 src/pages/api/event/[requestId].ts delete mode 100644 src/pages/sitemap.xml.ts delete mode 100644 src/shared/utils/date.ts rename src/{shared => }/utils/link.ts (100%) rename src/{shared => }/utils/locationUtils.test.ts (100%) rename src/{shared => }/utils/locationUtils.ts (96%) rename src/{shared => utils}/timeUtils.spec.ts (100%) rename src/{shared => utils}/timeUtils.ts (86%) rename src/{shared => utils}/types.ts (100%) rename src/{shared => utils}/utils.test.ts (100%) rename src/{shared => utils}/utils.ts (100%) diff --git a/cron-jobs/delete_expired_ip_rules.ts b/cron-jobs/delete_expired_ip_rules.ts index dd85817e..fa2bc0ab 100644 --- a/cron-jobs/delete_expired_ip_rules.ts +++ b/cron-jobs/delete_expired_ip_rules.ts @@ -2,7 +2,7 @@ import { Op } from 'sequelize'; import { syncFirewallRuleset } from '../src/app/bot-firewall/api/block-ip/cloudflareApiHelper'; import { schedule } from 'node-cron'; import 'dotenv/config'; -import { ONE_HOUR_MS } from '../src/shared/timeUtils'; +import { ONE_HOUR_MS } from '../src/utils/timeUtils'; import { BlockedIpDbModel } from '../src/app/bot-firewall/api/get-blocked-ips/blockedIpsDatabase'; /** diff --git a/e2e/sms-pumping/bot-unprotected.spec.ts b/e2e/sms-pumping/bot-unprotected.spec.ts index d04352c1..dd262b70 100644 --- a/e2e/sms-pumping/bot-unprotected.spec.ts +++ b/e2e/sms-pumping/bot-unprotected.spec.ts @@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test'; import { TEST_IDS } from '../../src/client/testIDs'; import { assertAlert, assertSnackbar, blockGoogleTagManager, resetScenarios } from '../e2eTestUtils'; -import { ONE_MINUTE_MS } from '../../src/shared/timeUtils'; +import { ONE_MINUTE_MS } from '../../src/utils/timeUtils'; import { TEST_BUILD } from '../../src/envShared'; import { SMS_FRAUD_COPY, diff --git a/next-env.d.ts b/next-env.d.ts index fd36f949..4f11a03d 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,6 +1,5 @@ /// /// -/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/next.config.js b/next.config.js index 6eb56c0f..706fbd75 100644 --- a/next.config.js +++ b/next.config.js @@ -9,7 +9,7 @@ module.exports = { formats: ['image/webp'], }, sassOptions: { - includePaths: [path.join(__dirname, 'src/styles')], + includePaths: [path.join(__dirname, 'src/client/styles')], prependData: `@import "common.scss";`, }, experimental: { diff --git a/src/Layout.tsx b/src/Layout.tsx deleted file mode 100644 index 51708f6d..00000000 --- a/src/Layout.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import './styles/global-styles.scss'; -import { FunctionComponent, PropsWithChildren } from 'react'; -import Footer from './client/components/common/Footer/Footer'; -import Header from './client/components/common/Header/Header'; -import styles from './styles/layout.module.scss'; -import { IS_PRODUCTION } from './envShared'; -import { Analytics } from './client/analytics/Analytics'; - -export const Layout: FunctionComponent> = ({ children, embed }) => { - return ( -
- {embed ? null :
} - {IS_PRODUCTION ? : null} -
{children}
- {embed ? null :
} -
- ); -}; diff --git a/src/styles/layout.module.scss b/src/app/LayoutUI.module.scss similarity index 100% rename from src/styles/layout.module.scss rename to src/app/LayoutUI.module.scss diff --git a/src/app/LayoutUI.tsx b/src/app/LayoutUI.tsx new file mode 100644 index 00000000..a7153970 --- /dev/null +++ b/src/app/LayoutUI.tsx @@ -0,0 +1,22 @@ +'use client'; + +import '../client/styles/global-styles.scss'; +import { useSelectedLayoutSegments } from 'next/navigation'; +import { IS_PRODUCTION } from '../envShared'; +import Header from '../client/components/Header/Header'; +import { Analytics } from '../client/analytics/Analytics'; +import Footer from '../client/components/Footer/Footer'; +import styles from './LayoutUI.module.scss'; + +export function LayoutUI({ children }: { children: React.ReactNode }) { + const segments = useSelectedLayoutSegments(); + const embed = Boolean(segments?.includes('embed')); + return ( +
+ {embed ? null :
} + {IS_PRODUCTION ? : null} +
{children}
+ {embed ? null :
} +
+ ); +} diff --git a/src/Providers.tsx b/src/app/Providers.tsx similarity index 92% rename from src/Providers.tsx rename to src/app/Providers.tsx index e4e71282..65b1cd80 100644 --- a/src/Providers.tsx +++ b/src/app/Providers.tsx @@ -3,9 +3,9 @@ import { QueryClient, QueryClientProvider } from 'react-query'; import { SnackbarProvider } from 'notistack'; import { PropsWithChildren } from 'react'; -import { CloseSnackbarButton, CustomSnackbar } from './client/components/common/Alert/Alert'; import { FingerprintJSPro, FpjsProvider } from '@fingerprintjs/fingerprintjs-pro-react'; -import { env } from './env'; +import { env } from '../env'; +import { CloseSnackbarButton, CustomSnackbar } from '../client/components/Alert/Alert'; const queryClient = new QueryClient({ defaultOptions: { diff --git a/src/app/api/event/[requestId]/route.ts b/src/app/api/event/[requestId]/route.ts new file mode 100644 index 00000000..1410981c --- /dev/null +++ b/src/app/api/event/[requestId]/route.ts @@ -0,0 +1,101 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { EventResponse, isEventError } from '@fingerprintjs/fingerprintjs-pro-server-api'; +import { OUR_ORIGINS } from '../../../../server/checks'; +import { IS_PRODUCTION } from '../../../../envShared'; +import { fingerprintServerApiClient } from '../../../../server/fingerprint-server-api'; + +// Also allow our documentation to use the endpoint +const allowedOrigins = [...OUR_ORIGINS, 'https://dev.fingerprint.com']; + +// Handle CORS +const getCorsHeaders = (origin: string | null) => ({ + 'Access-Control-Allow-Origin': String(origin), + 'Access-Control-Allow-Methods': 'POST, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type', +}); + +type CorsHeaders = ReturnType; + +export async function OPTIONS(request: NextRequest) { + const origin = request.headers.get('origin'); + + // CORS preflight + if (origin && allowedOrigins.includes(origin)) { + return new NextResponse(null, { + status: 200, + headers: getCorsHeaders(origin), + }); + } + + return new NextResponse(null, { status: 204 }); +} + +// Main handler +export async function POST(request: NextRequest, { params }: { params: { requestId: string } }) { + const origin = request.headers.get('origin'); + const requestId = params.requestId; + + // In production, validate the origin + if (IS_PRODUCTION && (!origin || !allowedOrigins.includes(origin))) { + return new NextResponse(null, { + status: 403, + statusText: `Origin "${origin}" is not allowed to call this endpoint`, + headers: getCorsHeaders(origin), + }); + } + + if (!requestId) { + return new NextResponse(null, { + status: 400, + statusText: 'Missing requestId parameter', + headers: getCorsHeaders(origin), + }); + } + + const result = await tryGetFingerprintEvent(requestId); + + if (!result.okay) { + return sendErrorResponse(result.error, getCorsHeaders(origin)); + } + + return NextResponse.json(result.data, { headers: getCorsHeaders(origin) }); +} + +async function tryGetFingerprintEvent( + requestId: string, + retryCount = 5, + retryDelay: number = 3000, +): Promise<{ okay: true; data: EventResponse } | { okay: false; error: unknown }> { + try { + const eventResponse = await fingerprintServerApiClient.getEvent(requestId); + return { okay: true, data: eventResponse }; + } catch (error) { + // Retry only Not Found (404) requests. + if (isEventError(error) && error.statusCode === 404 && retryCount > 1) { + await new Promise((resolve) => setTimeout(resolve, retryDelay)); + return tryGetFingerprintEvent(requestId, retryCount - 1, retryDelay); + } else { + console.error(error); + return { okay: false, error }; + } + } +} + +function sendErrorResponse(error: unknown, corsHeaders: CorsHeaders): NextResponse { + if (isEventError(error)) { + return NextResponse.json( + { message: error.message, code: error.errorCode }, + { + status: error.statusCode, + statusText: `${error.errorCode} - ${error.message}`, + headers: corsHeaders, + }, + ); + } else { + return new NextResponse(null, { + status: 500, + statusText: `Something went wrong ${error}`, + headers: corsHeaders, + }); + } +} diff --git a/src/app/appLayout.tsx b/src/app/appLayout.tsx deleted file mode 100644 index 357bfc73..00000000 --- a/src/app/appLayout.tsx +++ /dev/null @@ -1,9 +0,0 @@ -'use client'; - -import { useSelectedLayoutSegments } from 'next/navigation'; -import { Layout } from '../Layout'; - -export default function LayoutUiInsideApp({ children }: { children: React.ReactNode }) { - const segments = useSelectedLayoutSegments(); - return {children}; -} diff --git a/src/app/bot-firewall/BotFirewall.tsx b/src/app/bot-firewall/BotFirewall.tsx index 2814df3b..2eb4d520 100644 --- a/src/app/bot-firewall/BotFirewall.tsx +++ b/src/app/bot-firewall/BotFirewall.tsx @@ -1,9 +1,9 @@ 'use client'; -import { INSTRUCTION_ANCHOR_ID, UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; -import { USE_CASES } from '../../client/components/common/content'; +import { INSTRUCTION_ANCHOR_ID, UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; +import { USE_CASES } from '../../client/content'; import { useMutation, useQuery } from 'react-query'; -import Button from '../../client/components/common/Button/Button'; +import Button from '../../client/components/Button/Button'; import { BlockIpPayload, BlockIpResponse } from './api/block-ip/route'; import styles from './components/botFirewallComponents.module.scss'; import { VisitorQueryContext, useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'; @@ -12,9 +12,9 @@ import ChevronIcon from '../../client/img/chevronBlack.svg'; import Image from 'next/image'; import Link from 'next/link'; import { FunctionComponent, useState } from 'react'; -import { wait } from '../../shared/timeUtils'; -import { Spinner } from '../../client/components/common/Spinner/Spinner'; -import { Alert } from '../../client/components/common/Alert/Alert'; +import { wait } from '../../utils/timeUtils'; +import { Spinner } from '../../client/components/Spinner/Spinner'; +import { Alert } from '../../client/components/Alert/Alert'; import { BotVisit } from './api/get-bot-visits/botVisitDatabase'; import { BotTypeInfo, BotVisitAction, InstructionPrompt } from './components/botFirewallComponents'; diff --git a/src/app/bot-firewall/api/block-ip/buildFirewallRules.ts b/src/app/bot-firewall/api/block-ip/buildFirewallRules.ts index 1ae11022..b67c69d7 100644 --- a/src/app/bot-firewall/api/block-ip/buildFirewallRules.ts +++ b/src/app/bot-firewall/api/block-ip/buildFirewallRules.ts @@ -1,4 +1,4 @@ -import { chunk } from '../../../../shared/utils'; +import { chunk } from '../../../../utils/utils'; /** * Cloudflare rule expressions are limited to [4096 characters](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/#maximum-rule-expression-length). diff --git a/src/app/bot-firewall/api/block-ip/route.ts b/src/app/bot-firewall/api/block-ip/route.ts index 2127bae3..dd35aa29 100644 --- a/src/app/bot-firewall/api/block-ip/route.ts +++ b/src/app/bot-firewall/api/block-ip/route.ts @@ -1,7 +1,7 @@ import { syncFirewallRuleset } from './cloudflareApiHelper'; import { Severity, getAndValidateFingerprintResult } from '../../../../server/checks'; import { isIP } from 'is-ip'; -import { ValidationResult } from '../../../../shared/types'; +import { ValidationResult } from '../../../../utils/types'; import { NextRequest, NextResponse } from 'next/server'; import { deleteBlockedIp, saveBlockedIp } from '../get-blocked-ips/blockedIpsDatabase'; diff --git a/src/app/bot-firewall/api/get-bot-visits/botVisitDatabase.ts b/src/app/bot-firewall/api/get-bot-visits/botVisitDatabase.ts index 2dda40c5..01babcd8 100644 --- a/src/app/bot-firewall/api/get-bot-visits/botVisitDatabase.ts +++ b/src/app/bot-firewall/api/get-bot-visits/botVisitDatabase.ts @@ -1,6 +1,6 @@ import { Attributes, DataTypes, FindOptions, InferAttributes, InferCreationAttributes, Model } from 'sequelize'; import { sequelize } from '../../../../server/sequelize'; -import { EventResponseBotData } from '../../../../shared/types'; +import { EventResponseBotData } from '../../../../utils/types'; interface BotVisitAttributes extends Model, InferCreationAttributes> { diff --git a/src/app/bot-firewall/components/botFirewallComponents.tsx b/src/app/bot-firewall/components/botFirewallComponents.tsx index b7fc765c..9c0e4195 100644 --- a/src/app/bot-firewall/components/botFirewallComponents.tsx +++ b/src/app/bot-firewall/components/botFirewallComponents.tsx @@ -4,10 +4,10 @@ import { BOT_FIREWALL_COPY } from './botFirewallCopy'; import { Tooltip } from '@mui/material'; import Image from 'next/image'; import WaveIcon from '../../../client/img/wave.svg'; -import InfoIcon from '../../../client/img/InfoIcon.svg'; +import InfoIcon from '../../../client/img/InfoIconSvg.svg'; import styles from './botFirewallComponents.module.scss'; import { BlockIpPayload } from '../api/block-ip/route'; -import Button from '../../../client/components/common/Button/Button'; +import Button from '../../../client/components/Button/Button'; type BotVisitActionProps = { ip: string; diff --git a/src/app/bot-firewall/embed/page.tsx b/src/app/bot-firewall/embed/page.tsx index 687080fe..a2445b2d 100644 --- a/src/app/bot-firewall/embed/page.tsx +++ b/src/app/bot-firewall/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import BotFirewall from '../BotFirewall'; export const metadata = generateUseCaseMetadata(USE_CASES.botFirewall); diff --git a/src/app/bot-firewall/page.tsx b/src/app/bot-firewall/page.tsx index 226e117e..79d93d2d 100644 --- a/src/app/bot-firewall/page.tsx +++ b/src/app/bot-firewall/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import BotFirewall from './BotFirewall'; export const metadata = generateUseCaseMetadata(USE_CASES.botFirewall); diff --git a/src/app/coupon-fraud/CouponFraud.tsx b/src/app/coupon-fraud/CouponFraud.tsx index 43dfd495..9377f2a8 100644 --- a/src/app/coupon-fraud/CouponFraud.tsx +++ b/src/app/coupon-fraud/CouponFraud.tsx @@ -1,17 +1,17 @@ 'use client'; -import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; +import { UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; import { useState } from 'react'; import React from 'react'; -import { USE_CASES } from '../../client/components/common/content'; +import { USE_CASES } from '../../client/content'; import styles from './couponFraud.module.scss'; -import formStyles from '../../styles/forms.module.scss'; +import formStyles from '../../client/styles/forms.module.scss'; import classNames from 'classnames'; import AirMax from './shoeAirMax.svg'; import AllStar from './shoeAllStar.svg'; -import { Alert } from '../../client/components/common/Alert/Alert'; -import Button from '../../client/components/common/Button/Button'; -import { Cart } from '../../client/components/common/Cart/Cart'; +import { Alert } from '../../client/components/Alert/Alert'; +import Button from '../../client/components/Button/Button'; +import { Cart } from '../../client/components/Cart/Cart'; import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'; import { TEST_IDS } from '../../client/testIDs'; import { useMutation } from 'react-query'; diff --git a/src/app/coupon-fraud/embed/page.tsx b/src/app/coupon-fraud/embed/page.tsx index c723d5bb..d262cc37 100644 --- a/src/app/coupon-fraud/embed/page.tsx +++ b/src/app/coupon-fraud/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import { CouponFraudUseCase } from '../CouponFraud'; export const metadata = generateUseCaseMetadata(USE_CASES.couponFraud); diff --git a/src/app/coupon-fraud/page.tsx b/src/app/coupon-fraud/page.tsx index 6f4f8ebe..e78bf0c0 100644 --- a/src/app/coupon-fraud/page.tsx +++ b/src/app/coupon-fraud/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import { CouponFraudUseCase } from './CouponFraud'; export const metadata = generateUseCaseMetadata(USE_CASES.couponFraud); diff --git a/src/app/credential-stuffing/CredentialStuffing.tsx b/src/app/credential-stuffing/CredentialStuffing.tsx index dd15fc0c..a1b43df5 100644 --- a/src/app/credential-stuffing/CredentialStuffing.tsx +++ b/src/app/credential-stuffing/CredentialStuffing.tsx @@ -1,13 +1,13 @@ 'use client'; import { useState } from 'react'; -import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; +import { UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; import React from 'react'; -import { USE_CASES } from '../../client/components/common/content'; -import { Alert } from '../../client/components/common/Alert/Alert'; -import Button from '../../client/components/common/Button/Button'; +import { USE_CASES } from '../../client/content'; +import { Alert } from '../../client/components/Alert/Alert'; +import Button from '../../client/components/Button/Button'; import styles from './credentialStuffing.module.scss'; -import formStyles from '../../styles/forms.module.scss'; +import formStyles from '../../client/styles/forms.module.scss'; import classNames from 'classnames'; import hiddenIcon from './iconHidden.svg'; import shownIcon from './iconShown.svg'; diff --git a/src/app/credential-stuffing/embed/page.tsx b/src/app/credential-stuffing/embed/page.tsx index 4d870bcc..435698be 100644 --- a/src/app/credential-stuffing/embed/page.tsx +++ b/src/app/credential-stuffing/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import { CredentialStuffing } from '.././CredentialStuffing'; export const metadata = generateUseCaseMetadata(USE_CASES.credentialStuffing); diff --git a/src/app/credential-stuffing/page.tsx b/src/app/credential-stuffing/page.tsx index 8fec591e..b33add4b 100644 --- a/src/app/credential-stuffing/page.tsx +++ b/src/app/credential-stuffing/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import { CredentialStuffing } from './CredentialStuffing'; export const metadata = generateUseCaseMetadata(USE_CASES.credentialStuffing); diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 498d2a20..153c1236 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,5 +1,5 @@ -import Providers from '../Providers'; -import LayoutUiInsideApp from './appLayout'; +import { LayoutUI } from './LayoutUI'; +import Providers from './Providers'; export const metadata = { title: 'Fingerprint Pro Use Cases', @@ -12,7 +12,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) - {children} + {children} diff --git a/src/app/loan-risk/LoanRisk.tsx b/src/app/loan-risk/LoanRisk.tsx index b6aee4ce..b395e25c 100644 --- a/src/app/loan-risk/LoanRisk.tsx +++ b/src/app/loan-risk/LoanRisk.tsx @@ -1,15 +1,15 @@ 'use client'; -import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; +import { UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; import { FunctionComponent, useMemo, useState } from 'react'; -import { calculateMonthInstallment } from '../../shared/loan-risk/calculate-month-installment'; +import { calculateMonthInstallment } from './api/request-loan/calculate-month-installment'; import React from 'react'; -import { USE_CASES } from '../../client/components/common/content'; -import Button from '../../client/components/common/Button/Button'; -import { Alert } from '../../client/components/common/Alert/Alert'; -import formStyles from '../../styles/forms.module.scss'; -import { Slider } from '../../client/components/common/Slider/Slider'; -import { NumberInputWithUnits } from '../../client/components/common/InputNumberWithUnits/InputNumberWithUnits'; +import { USE_CASES } from '../../client/content'; +import Button from '../../client/components/Button/Button'; +import { Alert } from '../../client/components/Alert/Alert'; +import formStyles from '../../client/styles/forms.module.scss'; +import { Slider } from '../../client/components/Slider/Slider'; +import { NumberInputWithUnits } from '../../client/components/InputNumberWithUnits/InputNumberWithUnits'; import styles from './loanRisk.module.scss'; import classNames from 'classnames'; import { TEST_IDS } from '../../client/testIDs'; diff --git a/src/shared/loan-risk/calculate-month-installment.ts b/src/app/loan-risk/api/request-loan/calculate-month-installment.ts similarity index 100% rename from src/shared/loan-risk/calculate-month-installment.ts rename to src/app/loan-risk/api/request-loan/calculate-month-installment.ts diff --git a/src/app/loan-risk/api/request-loan/evaluateLoanRequest.ts b/src/app/loan-risk/api/request-loan/evaluateLoanRequest.ts index 2d5dfea1..02a74bc1 100644 --- a/src/app/loan-risk/api/request-loan/evaluateLoanRequest.ts +++ b/src/app/loan-risk/api/request-loan/evaluateLoanRequest.ts @@ -1,4 +1,4 @@ -import { calculateMonthInstallment } from '../../../../shared/loan-risk/calculate-month-installment'; +import { calculateMonthInstallment } from './calculate-month-installment'; /** * Required minimal income. diff --git a/src/app/loan-risk/embed/page.tsx b/src/app/loan-risk/embed/page.tsx index 96bf6963..287e12ff 100644 --- a/src/app/loan-risk/embed/page.tsx +++ b/src/app/loan-risk/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import { LoanRisk } from '../LoanRisk'; export const metadata = generateUseCaseMetadata(USE_CASES.loanRisk); diff --git a/src/app/loan-risk/page.tsx b/src/app/loan-risk/page.tsx index 3ac6d276..c53088f1 100644 --- a/src/app/loan-risk/page.tsx +++ b/src/app/loan-risk/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import { LoanRisk } from './LoanRisk'; export const metadata = generateUseCaseMetadata(USE_CASES.loanRisk); diff --git a/src/pages/index.module.scss b/src/app/page.module.scss similarity index 100% rename from src/pages/index.module.scss rename to src/app/page.module.scss diff --git a/src/pages/index.tsx b/src/app/page.tsx similarity index 77% rename from src/pages/index.tsx rename to src/app/page.tsx index 90b23470..bbfdc17f 100644 --- a/src/pages/index.tsx +++ b/src/app/page.tsx @@ -1,21 +1,23 @@ import Link from 'next/link'; -import styles from './index.module.scss'; -import Container from '../client/components/common/Container'; -import { HOMEPAGE_CARDS } from '../client/components/common/content'; +import styles from './page.module.scss'; +import Container from '../client/components/Container'; +import { HOMEPAGE_CARDS } from '../client/content'; import LinkArrow from '../client/img/externalLinkArrow.svg'; import Image from 'next/image'; import { TEST_IDS } from '../client/testIDs'; import { Fragment } from 'react'; -import { SEO } from '../client/components/common/seo'; +import { Metadata } from 'next'; +import { generateMetadata } from '../client/seo'; + +export const metadata: Metadata = generateMetadata({ + title: 'Fingerprint Use Cases | Discover Device Intelligence Use Cases', + description: + 'Explore an extensive range of use cases supported by Fingerprint, and learn how to successfully implement it for your business with practical guidance and a comprehensive demo.', +}); export default function Index() { return ( <> -

Fingerprint use cases

diff --git a/src/app/payment-fraud/PaymentFraud.tsx b/src/app/payment-fraud/PaymentFraud.tsx index 889d50d2..416d9bc9 100644 --- a/src/app/payment-fraud/PaymentFraud.tsx +++ b/src/app/payment-fraud/PaymentFraud.tsx @@ -1,14 +1,14 @@ 'use client'; import { useState } from 'react'; -import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; +import { UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; import React from 'react'; -import { USE_CASES } from '../../client/components/common/content'; -import Button from '../../client/components/common/Button/Button'; +import { USE_CASES } from '../../client/content'; +import Button from '../../client/components/Button/Button'; import styles from './paymentFraud.module.scss'; -import formStyles from '../../styles/forms.module.scss'; -import { Alert } from '../../client/components/common/Alert/Alert'; +import formStyles from '../../client/styles/forms.module.scss'; +import { Alert } from '../../client/components/Alert/Alert'; import classNames from 'classnames'; import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'; import { TEST_IDS } from '../../client/testIDs'; diff --git a/src/app/payment-fraud/embed/page.tsx b/src/app/payment-fraud/embed/page.tsx index fc0fbcf2..db46c82b 100644 --- a/src/app/payment-fraud/embed/page.tsx +++ b/src/app/payment-fraud/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import { PaymentFraud } from '../PaymentFraud'; export const metadata = generateUseCaseMetadata(USE_CASES.paymentFraud); diff --git a/src/app/payment-fraud/page.tsx b/src/app/payment-fraud/page.tsx index 794e6287..1035b4eb 100644 --- a/src/app/payment-fraud/page.tsx +++ b/src/app/payment-fraud/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import { PaymentFraud } from './PaymentFraud'; export const metadata = generateUseCaseMetadata(USE_CASES.paymentFraud); diff --git a/src/app/paywall/Paywall.tsx b/src/app/paywall/Paywall.tsx index d17b8980..a1933455 100644 --- a/src/app/paywall/Paywall.tsx +++ b/src/app/paywall/Paywall.tsx @@ -1,7 +1,7 @@ 'use client'; -import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; -import { USE_CASES } from '../../client/components/common/content'; +import { UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; +import { USE_CASES } from '../../client/content'; import { ArticleCard, ArticleGrid } from './components/ArticleGrid'; import { ARTICLES } from './api/articles'; diff --git a/src/app/paywall/api/article/[id]/route.ts b/src/app/paywall/api/article/[id]/route.ts index 4cd355ce..af2899a5 100644 --- a/src/app/paywall/api/article/[id]/route.ts +++ b/src/app/paywall/api/article/[id]/route.ts @@ -2,9 +2,9 @@ import { getAndValidateFingerprintResult, Severity } from '../../../../../server import { NextResponse } from 'next/server'; import { ArticleData, ARTICLES } from '../../articles'; import { ArticleViewDbModel } from '../../database'; -import { getTodayDateRange } from '../../../../../shared/utils/date'; import { Op } from 'sequelize'; import { PAYWALL_COPY } from '../../copy'; +import { getTodayDateRange } from '../../../../../utils/timeUtils'; export type ArticleResponse = { message: string; diff --git a/src/app/paywall/article/[id]/Article.tsx b/src/app/paywall/article/[id]/Article.tsx index dec50b18..accb2a67 100644 --- a/src/app/paywall/article/[id]/Article.tsx +++ b/src/app/paywall/article/[id]/Article.tsx @@ -1,17 +1,17 @@ 'use client'; import { Skeleton, SkeletonTypeMap } from '@mui/material'; -import { UseCaseWrapper } from '../../../../client/components/common/UseCaseWrapper/UseCaseWrapper'; -import { USE_CASES } from '../../../../client/components/common/content'; +import { UseCaseWrapper } from '../../../../client/components/UseCaseWrapper/UseCaseWrapper'; +import { USE_CASES } from '../../../../client/content'; import Image from 'next/image'; import styles from '../../paywall.module.scss'; -import { Alert } from '../../../../client/components/common/Alert/Alert'; +import { Alert } from '../../../../client/components/Alert/Alert'; import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'; import { useQuery } from 'react-query'; import { TEST_IDS } from '../../../../client/testIDs'; import { ArticleGrid, Byline } from '../../components/ArticleGrid'; -import { BackArrow } from '../../../../client/components/common/BackArrow/BackArrow'; +import { BackArrow } from '../../../../client/components/BackArrow/BackArrow'; import { ArticleRequestPayload, ArticleResponse } from '../../api/article/[id]/route'; import { ARTICLES } from '../../api/articles'; diff --git a/src/app/paywall/article/[id]/embed/page.tsx b/src/app/paywall/article/[id]/embed/page.tsx index c0905c4b..dc5d1f2e 100644 --- a/src/app/paywall/article/[id]/embed/page.tsx +++ b/src/app/paywall/article/[id]/embed/page.tsx @@ -1,6 +1,6 @@ import { ARTICLES } from '../../../api/articles'; -import { USE_CASES } from '../../../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../../../client/components/common/seo'; +import { USE_CASES } from '../../../../../client/content'; +import { generateUseCaseMetadata } from '../../../../../client/seo'; import { Article } from '../Article'; export async function generateStaticParams() { diff --git a/src/app/paywall/article/[id]/page.tsx b/src/app/paywall/article/[id]/page.tsx index abed53fa..a8c41cb1 100644 --- a/src/app/paywall/article/[id]/page.tsx +++ b/src/app/paywall/article/[id]/page.tsx @@ -1,6 +1,6 @@ import { ARTICLES } from '../../api/articles'; -import { USE_CASES } from '../../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../../client/components/common/seo'; +import { USE_CASES } from '../../../../client/content'; +import { generateUseCaseMetadata } from '../../../../client/seo'; import { Article } from './Article'; export async function generateStaticParams() { diff --git a/src/app/paywall/embed/page.tsx b/src/app/paywall/embed/page.tsx index 212e0036..b33dd657 100644 --- a/src/app/paywall/embed/page.tsx +++ b/src/app/paywall/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import Paywall from '../Paywall'; export const metadata = generateUseCaseMetadata(USE_CASES.paywall); diff --git a/src/app/paywall/page.tsx b/src/app/paywall/page.tsx index af23c5b6..b28b5fbc 100644 --- a/src/app/paywall/page.tsx +++ b/src/app/paywall/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import Paywall from './Paywall'; export const metadata = generateUseCaseMetadata(USE_CASES.paywall); diff --git a/src/app/personalization/Personalization.tsx b/src/app/personalization/Personalization.tsx index c2b2a5c9..47fb2941 100644 --- a/src/app/personalization/Personalization.tsx +++ b/src/app/personalization/Personalization.tsx @@ -2,21 +2,21 @@ import { useEffect, useState } from 'react'; import { useDebounce, useSessionStorage } from 'react-use'; -import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; +import { UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; import { Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material'; import { useSnackbar } from 'notistack'; import { useCart } from './hooks/use-cart'; import React from 'react'; -import { USE_CASES } from '../../client/components/common/content'; +import { USE_CASES } from '../../client/content'; import styles from './personalization.module.scss'; import Image from 'next/image'; -import Button from '../../client/components/common/Button/Button'; +import Button from '../../client/components/Button/Button'; import CartIcon from '../../client/img/cart.svg'; -import { Cart, CartProduct } from '../../client/components/common/Cart/Cart'; +import { Cart, CartProduct } from '../../client/components/Cart/Cart'; import { Search, SearchHistory } from './components/searchComponents'; import { ProductCard } from './components/productCard'; import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'; -import { Spinner } from '../../client/components/common/Spinner/Spinner'; +import { Spinner } from '../../client/components/Spinner/Spinner'; import { useSearchHistory } from './hooks/use-search-history'; import { useProducts } from './hooks/use-products'; import { usePersonalizationNotification } from './hooks/use-personalization-notification'; diff --git a/src/app/personalization/components/productCard.tsx b/src/app/personalization/components/productCard.tsx index 0b5210af..74a0c3cf 100644 --- a/src/app/personalization/components/productCard.tsx +++ b/src/app/personalization/components/productCard.tsx @@ -5,7 +5,7 @@ import { ButtonMinusSvg } from '../../../client/img/buttonMinusSvg'; import { ButtonPlusSvg } from '../../../client/img/buttonPlusSvg'; import Image from 'next/image'; import styles from './productCard.module.scss'; -import Button from '../../../client/components/common/Button/Button'; +import Button from '../../../client/components/Button/Button'; import HeartIcon from '../img/heart.svg'; import { TEST_IDS } from '../../../client/testIDs'; import { UserCartItem } from '../api/database'; diff --git a/src/app/personalization/embed/page.tsx b/src/app/personalization/embed/page.tsx index eff35348..82ec7754 100644 --- a/src/app/personalization/embed/page.tsx +++ b/src/app/personalization/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import { Personalization } from '../Personalization'; export const metadata = generateUseCaseMetadata(USE_CASES.personalization); diff --git a/src/app/personalization/hooks/use-personalization-notification.tsx b/src/app/personalization/hooks/use-personalization-notification.tsx index dae033c1..f77c441c 100644 --- a/src/app/personalization/hooks/use-personalization-notification.tsx +++ b/src/app/personalization/hooks/use-personalization-notification.tsx @@ -1,8 +1,8 @@ import { useCallback } from 'react'; import { SnackbarKey, useSnackbar } from 'notistack'; import { useCopyToClipboard } from 'react-use'; -import Button from '../../../client/components/common/Button/Button'; -import { CloseSnackbarButton } from '../../../client/components/common/Alert/Alert'; +import Button from '../../../client/components/Button/Button'; +import { CloseSnackbarButton } from '../../../client/components/Alert/Alert'; export function usePersonalizationNotification() { const { enqueueSnackbar, closeSnackbar } = useSnackbar(); diff --git a/src/app/personalization/page.tsx b/src/app/personalization/page.tsx index 2b39e6f2..9bd95931 100644 --- a/src/app/personalization/page.tsx +++ b/src/app/personalization/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import { Personalization } from './Personalization'; export const metadata = generateUseCaseMetadata(USE_CASES.personalization); diff --git a/src/app/playground/Playground.tsx b/src/app/playground/Playground.tsx index d3b4b6c2..1257f597 100644 --- a/src/app/playground/Playground.tsx +++ b/src/app/playground/Playground.tsx @@ -1,7 +1,7 @@ 'use client'; import { useEffect, ReactNode } from 'react'; -import { CollapsibleJsonViewer } from '../../client/components/common/CodeSnippet/CodeSnippet'; +import { CollapsibleJsonViewer } from '../../client/components/CodeSnippet/CodeSnippet'; import dynamic from 'next/dynamic'; import SignalTable, { TableCellData } from './components/SignalTable'; import botDetectionResult from './components/BotDetectionResult'; @@ -9,25 +9,25 @@ import { RefreshButton } from './components/RefreshButton'; import { ipBlocklistResult } from './components/IpBlocklistResult'; import { vpnDetectionResult } from './components/VpnDetectionResult'; import { usePlaygroundSignals } from './hooks/usePlaygroundSignals'; -import { getLocationName, getZoomLevel } from '../../shared/utils/locationUtils'; +import { getLocationName, getZoomLevel } from '../../utils/locationUtils'; import Link from 'next/link'; import styles from './playground.module.scss'; -import { Spinner } from '../../client/components/common/Spinner/Spinner'; -import { Alert } from '../../client/components/common/Alert/Alert'; -import { timeAgoLabel } from '../../shared/timeUtils'; -import Container from '../../client/components/common/Container'; +import { Spinner } from '../../client/components/Spinner/Spinner'; +import { Alert } from '../../client/components/Alert/Alert'; +import { timeAgoLabel } from '../../utils/timeUtils'; +import Container from '../../client/components/Container'; import { TEST_IDS } from '../../client/testIDs'; import tableStyles from './components/SignalTable.module.scss'; import { HowToUseThisPlayground } from './components/HowToUseThisPlayground'; import classnames from 'classnames'; -import { ResourceLinks } from '../../client/components/common/ResourceLinks/ResourceLinks'; +import { ResourceLinks } from '../../client/components/ResourceLinks/ResourceLinks'; import { MyCollapsible, MyCollapsibleTrigger, MyCollapsibleContent, -} from '../../client/components/common/Collapsible/Collapsible'; +} from '../../client/components/Collapsible/Collapsible'; import { ChevronSvg } from '../../client/img/chevronSvg'; -import { pluralize } from '../../shared/utils'; +import { pluralize } from '../../utils/utils'; import { motion } from 'framer-motion'; import { JsonLink, DocsLink } from './components/ArrowLinks'; diff --git a/src/app/playground/components/HowToUseThisPlayground.tsx b/src/app/playground/components/HowToUseThisPlayground.tsx index 38011b3c..c600aec2 100644 --- a/src/app/playground/components/HowToUseThisPlayground.tsx +++ b/src/app/playground/components/HowToUseThisPlayground.tsx @@ -4,8 +4,8 @@ import { AccordionContent, AccordionItem, AccordionTrigger, -} from '../../../client/components/common/Accordion/Accordion'; -import { FancyNumberedList } from '../../../client/components/common/FancyNumberedList/FancyNumberedList'; +} from '../../../client/components/Accordion/Accordion'; +import { FancyNumberedList } from '../../../client/components/FancyNumberedList/FancyNumberedList'; import Link from 'next/link'; type HowTo = { diff --git a/src/app/playground/components/RefreshButton.tsx b/src/app/playground/components/RefreshButton.tsx index 2ad44f4f..4aef53f4 100644 --- a/src/app/playground/components/RefreshButton.tsx +++ b/src/app/playground/components/RefreshButton.tsx @@ -1,5 +1,5 @@ import { FunctionComponent } from 'react'; -import Button from '../../../client/components/common/Button/Button'; +import Button from '../../../client/components/Button/Button'; import styles from './RefreshButton.module.scss'; import classnames from 'classnames'; import { TEST_IDS } from '../../../client/testIDs'; diff --git a/src/app/playground/embed/page.tsx b/src/app/playground/embed/page.tsx index 870247a2..afe97469 100644 --- a/src/app/playground/embed/page.tsx +++ b/src/app/playground/embed/page.tsx @@ -1,5 +1,5 @@ -import { PLAYGROUND_METADATA } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { PLAYGROUND_METADATA } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import { Playground } from '../Playground'; export const metadata = generateUseCaseMetadata(PLAYGROUND_METADATA); diff --git a/src/app/playground/page.tsx b/src/app/playground/page.tsx index d92d138f..eb3f5088 100644 --- a/src/app/playground/page.tsx +++ b/src/app/playground/page.tsx @@ -1,5 +1,5 @@ -import { PLAYGROUND_METADATA } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { PLAYGROUND_METADATA } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import { Playground } from './Playground'; export const metadata = generateUseCaseMetadata(PLAYGROUND_METADATA); diff --git a/src/app/sitemap.xml/route.ts b/src/app/sitemap.xml/route.ts new file mode 100644 index 00000000..6744d78b --- /dev/null +++ b/src/app/sitemap.xml/route.ts @@ -0,0 +1,30 @@ +import { HOMEPAGE_CARDS, PRODUCTION_URL } from '../../client/content'; +import { NextResponse } from 'next/server'; + +function generateSiteMap() { + return ` + + + ${PRODUCTION_URL} + + ${HOMEPAGE_CARDS.map(({ url }) => { + return ` + + ${`${PRODUCTION_URL}${url}`} + + `; + }).join('')} + + `; +} + +export async function GET() { + const sitemap = generateSiteMap(); + + return new NextResponse(sitemap, { + status: 200, + headers: { + 'Content-Type': 'text/xml', + }, + }); +} diff --git a/src/app/sms-pumping/SmsPumping.tsx b/src/app/sms-pumping/SmsPumping.tsx index c520cff4..01c9e3bf 100644 --- a/src/app/sms-pumping/SmsPumping.tsx +++ b/src/app/sms-pumping/SmsPumping.tsx @@ -1,16 +1,16 @@ 'use client'; import { FunctionComponent, Suspense, useState } from 'react'; -import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; +import { UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; import React from 'react'; -import { USE_CASES } from '../../client/components/common/content'; -import Button from '../../client/components/common/Button/Button'; -import formStyles from '../../styles/forms.module.scss'; +import { USE_CASES } from '../../client/content'; +import Button from '../../client/components/Button/Button'; +import formStyles from '../../client/styles/forms.module.scss'; import { TEST_IDS } from '../../client/testIDs'; -import { CloseSnackbarButton } from '../../client/components/common/Alert/Alert'; +import { CloseSnackbarButton } from '../../client/components/Alert/Alert'; import { enqueueSnackbar } from 'notistack'; import { useCopyToClipboard } from 'react-use'; -import { BackArrow } from '../../client/components/common/BackArrow/BackArrow'; +import { BackArrow } from '../../client/components/BackArrow/BackArrow'; import { GetServerSideProps } from 'next'; import { SubmitCodeForm } from './components/SubmitCodeForm'; import { PhoneNumberForm } from './components/PhoneNumberForm'; diff --git a/src/app/sms-pumping/api/send-verification-sms/route.ts b/src/app/sms-pumping/api/send-verification-sms/route.ts index a6325e38..396198ee 100644 --- a/src/app/sms-pumping/api/send-verification-sms/route.ts +++ b/src/app/sms-pumping/api/send-verification-sms/route.ts @@ -1,7 +1,7 @@ import { Severity, getAndValidateFingerprintResult } from '../../../../server/checks'; -import { ONE_SECOND_MS, readableMilliseconds } from '../../../../shared/timeUtils'; +import { ONE_SECOND_MS, readableMilliseconds } from '../../../../utils/timeUtils'; import { Op } from 'sequelize'; -import { pluralize } from '../../../../shared/utils'; +import { pluralize } from '../../../../utils/utils'; import Twilio from 'twilio'; import { hashString } from '../../../../server/server-utils'; import { env } from '../../../../env'; diff --git a/src/app/sms-pumping/api/smsPumpingConst.ts b/src/app/sms-pumping/api/smsPumpingConst.ts index 7f01e307..bcae3532 100644 --- a/src/app/sms-pumping/api/smsPumpingConst.ts +++ b/src/app/sms-pumping/api/smsPumpingConst.ts @@ -1,6 +1,6 @@ import { TEST_BUILD } from '../../../envShared'; -import { ONE_SECOND_MS } from '../../../shared/timeUtils'; -import { pluralize } from '../../../shared/utils'; +import { ONE_SECOND_MS } from '../../../utils/timeUtils'; +import { pluralize } from '../../../utils/utils'; export const TEST_PHONE_NUMBER = '+1234567890'; diff --git a/src/app/sms-pumping/components/PhoneNumberForm.tsx b/src/app/sms-pumping/components/PhoneNumberForm.tsx index 89f7713f..86f7f46d 100644 --- a/src/app/sms-pumping/components/PhoneNumberForm.tsx +++ b/src/app/sms-pumping/components/PhoneNumberForm.tsx @@ -3,7 +3,7 @@ import { TEST_IDS } from '../../../client/testIDs'; import { SendMessageButton } from './SendSMSMessageButton'; import classNames from 'classnames'; import styles from './smsPumping.module.scss'; -import formStyles from '../../../styles/forms.module.scss'; +import formStyles from '../../../client/styles/forms.module.scss'; import { SendMessageMutation } from '../SmsPumping'; type PhoneNumberFormProps = { diff --git a/src/app/sms-pumping/components/SendSMSMessageButton.tsx b/src/app/sms-pumping/components/SendSMSMessageButton.tsx index 42249b1a..a40c4912 100644 --- a/src/app/sms-pumping/components/SendSMSMessageButton.tsx +++ b/src/app/sms-pumping/components/SendSMSMessageButton.tsx @@ -1,8 +1,8 @@ import { ButtonHTMLAttributes, FunctionComponent } from 'react'; import { TEST_IDS } from '../../../client/testIDs'; import styles from './smsPumping.module.scss'; -import { Alert } from '../../../client/components/common/Alert/Alert'; -import Button from '../../../client/components/common/Button/Button'; +import { Alert } from '../../../client/components/Alert/Alert'; +import Button from '../../../client/components/Button/Button'; import { SendMessageMutation } from '../SmsPumping'; type SendMessageButtonProps = { diff --git a/src/app/sms-pumping/components/SubmitCodeForm.tsx b/src/app/sms-pumping/components/SubmitCodeForm.tsx index db84e594..ee36e2dc 100644 --- a/src/app/sms-pumping/components/SubmitCodeForm.tsx +++ b/src/app/sms-pumping/components/SubmitCodeForm.tsx @@ -5,10 +5,10 @@ import { SubmitCodeResponse, SubmitCodePayload } from '../api/submit-code/route' import { TEST_IDS } from '../../../client/testIDs'; import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'; import { SendMessageButton } from './SendSMSMessageButton'; -import { Alert } from '../../../client/components/common/Alert/Alert'; -import Button from '../../../client/components/common/Button/Button'; +import { Alert } from '../../../client/components/Alert/Alert'; +import Button from '../../../client/components/Button/Button'; import styles from './smsPumping.module.scss'; -import formStyles from '../../../styles/forms.module.scss'; +import formStyles from '../../../client/styles/forms.module.scss'; import { SendMessageMutation } from '../SmsPumping'; export const useSubmitCode = (params?: { onSuccess?: () => void }) => { diff --git a/src/app/sms-pumping/embed/page.tsx b/src/app/sms-pumping/embed/page.tsx index 10d8f3cc..b0b79814 100644 --- a/src/app/sms-pumping/embed/page.tsx +++ b/src/app/sms-pumping/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import { SmsPumpingUseCase } from '../SmsPumping'; export const metadata = generateUseCaseMetadata(USE_CASES.smsPumping); diff --git a/src/app/sms-pumping/page.tsx b/src/app/sms-pumping/page.tsx index 05550fd0..60fb4720 100644 --- a/src/app/sms-pumping/page.tsx +++ b/src/app/sms-pumping/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import { SmsPumpingUseCase } from './SmsPumping'; export const metadata = generateUseCaseMetadata(USE_CASES.smsPumping); diff --git a/src/app/vpn-detection/VpnDetectionUseCase.tsx b/src/app/vpn-detection/VpnDetectionUseCase.tsx index 1ec2c600..78450657 100644 --- a/src/app/vpn-detection/VpnDetectionUseCase.tsx +++ b/src/app/vpn-detection/VpnDetectionUseCase.tsx @@ -1,19 +1,19 @@ 'use client'; -import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; +import { UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; import { FunctionComponent, useState } from 'react'; -import { USE_CASES } from '../../client/components/common/content'; +import { USE_CASES } from '../../client/content'; import styles from './vpnDetection.module.scss'; -import formStyles from '../../styles/forms.module.scss'; +import formStyles from '../../client/styles/forms.module.scss'; import classNames from 'classnames'; -import { Alert } from '../../client/components/common/Alert/Alert'; -import Button from '../../client/components/common/Button/Button'; -import { Cart } from '../../client/components/common/Cart/Cart'; +import { Alert } from '../../client/components/Alert/Alert'; +import Button from '../../client/components/Button/Button'; +import { Cart } from '../../client/components/Cart/Cart'; import { FingerprintJSPro, FpjsProvider, useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'; import { useMutation } from 'react-query'; import { ActivateRegionalPricingPayload, ActivateRegionalPricingResponse } from './api/activate-ppp/route'; import { useUnsealedResult } from '../../client/hooks/useUnsealedResult'; -import { getFlagEmoji, getIpLocation } from '../../shared/utils/locationUtils'; +import { getFlagEmoji, getIpLocation } from '../../utils/locationUtils'; import { getRegionalDiscount } from './data/getDiscountByCountry'; import courseLogo from './fingerprintLogoLowOpacitySquareBordered.svg'; import { env } from '../../env'; diff --git a/src/app/vpn-detection/api/activate-ppp/route.ts b/src/app/vpn-detection/api/activate-ppp/route.ts index 596ada3c..abd8b10a 100644 --- a/src/app/vpn-detection/api/activate-ppp/route.ts +++ b/src/app/vpn-detection/api/activate-ppp/route.ts @@ -3,7 +3,7 @@ import { getAndValidateFingerprintResult } from '../../../../server/checks'; import { getRegionalDiscount } from '../../data/getDiscountByCountry'; import { env } from '../../../../env'; import { VPN_DETECTION_COPY } from '../../copy'; -import { getIpLocation, getLocationName } from '../../../../shared/utils/locationUtils'; +import { getIpLocation, getLocationName } from '../../../../utils/locationUtils'; export type ActivateRegionalPricingPayload = { requestId: string; diff --git a/src/app/vpn-detection/embed/page.tsx b/src/app/vpn-detection/embed/page.tsx index e8094943..f02e0649 100644 --- a/src/app/vpn-detection/embed/page.tsx +++ b/src/app/vpn-detection/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import { VpnDetectionUseCaseWrapped } from '../VpnDetectionUseCase'; export const metadata = generateUseCaseMetadata(USE_CASES.vpnDetection); diff --git a/src/app/vpn-detection/page.tsx b/src/app/vpn-detection/page.tsx index 31d4340d..ce63b131 100644 --- a/src/app/vpn-detection/page.tsx +++ b/src/app/vpn-detection/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import { VpnDetectionUseCaseWrapped } from './VpnDetectionUseCase'; export const metadata = generateUseCaseMetadata(USE_CASES.vpnDetection); diff --git a/src/app/web-scraping/WebScraping.tsx b/src/app/web-scraping/WebScraping.tsx index 7ff4ac16..4eeb2172 100644 --- a/src/app/web-scraping/WebScraping.tsx +++ b/src/app/web-scraping/WebScraping.tsx @@ -1,17 +1,17 @@ 'use client'; -import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; +import { UseCaseWrapper } from '../../client/components/UseCaseWrapper/UseCaseWrapper'; import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'; import { useQueryState } from 'next-usequerystate'; import { useQuery, UseQueryResult } from 'react-query'; -import { USE_CASES } from '../../client/components/common/content'; -import { Select, SelectItem } from '../../client/components/common/Select/Select'; +import { USE_CASES } from '../../client/content'; +import { Select, SelectItem } from '../../client/components/Select/Select'; import ArrowIcon from '../../client/img/arrowRight.svg'; import Image from 'next/image'; import styles from './webScraping.module.scss'; -import Button from '../../client/components/common/Button/Button'; -import { Alert } from '../../client/components/common/Alert/Alert'; -import { Spinner } from '../../client/components/common/Spinner/Spinner'; +import Button from '../../client/components/Button/Button'; +import { Alert } from '../../client/components/Alert/Alert'; +import { Spinner } from '../../client/components/Spinner/Spinner'; import { FlightQuery } from './api/flights/route'; import { FunctionComponent, Suspense } from 'react'; import { useSearchParams } from 'next/navigation'; diff --git a/src/app/web-scraping/api/flights/route.ts b/src/app/web-scraping/api/flights/route.ts index b070630c..f4eed2e8 100644 --- a/src/app/web-scraping/api/flights/route.ts +++ b/src/app/web-scraping/api/flights/route.ts @@ -1,5 +1,5 @@ import { Severity, getAndValidateFingerprintResult } from '../../../../server/checks'; -import { ONE_DAY_MS, FIVE_MINUTES_MS, ONE_HOUR_MS } from '../../../../shared/timeUtils'; +import { ONE_DAY_MS, FIVE_MINUTES_MS, ONE_HOUR_MS } from '../../../../utils/timeUtils'; import { NextRequest, NextResponse } from 'next/server'; import { AIRPORTS } from '../../data/airports'; import { Flight } from '../../components/FlightCard'; diff --git a/src/app/web-scraping/components/FlightCard.tsx b/src/app/web-scraping/components/FlightCard.tsx index d19cefe8..0d56e89e 100644 --- a/src/app/web-scraping/components/FlightCard.tsx +++ b/src/app/web-scraping/components/FlightCard.tsx @@ -5,9 +5,9 @@ import ArrivalIcon from '../images/arrival.svg'; import AirCanada from '../images/airCanada.svg'; import StarIcon from '../images/star.svg'; import Image from 'next/image'; -import { ONE_HOUR_MS, ONE_MINUTE_MS } from '../../../shared/timeUtils'; +import { ONE_HOUR_MS, ONE_MINUTE_MS } from '../../../utils/timeUtils'; import { TEST_IDS } from '../../../client/testIDs'; -import Button from '../../../client/components/common/Button/Button'; +import Button from '../../../client/components/Button/Button'; const TEST_ID = TEST_IDS.webScraping; diff --git a/src/app/web-scraping/embed/page.tsx b/src/app/web-scraping/embed/page.tsx index be0ceda1..6b45c586 100644 --- a/src/app/web-scraping/embed/page.tsx +++ b/src/app/web-scraping/embed/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../../client/components/common/seo'; +import { USE_CASES } from '../../../client/content'; +import { generateUseCaseMetadata } from '../../../client/seo'; import { WebScrapingUseCase } from '../WebScraping'; export const metadata = generateUseCaseMetadata(USE_CASES.webScraping); diff --git a/src/app/web-scraping/page.tsx b/src/app/web-scraping/page.tsx index 25fa1125..fb26a76b 100644 --- a/src/app/web-scraping/page.tsx +++ b/src/app/web-scraping/page.tsx @@ -1,5 +1,5 @@ -import { USE_CASES } from '../../client/components/common/content'; -import { generateUseCaseMetadata } from '../../client/components/common/seo'; +import { USE_CASES } from '../../client/content'; +import { generateUseCaseMetadata } from '../../client/seo'; import { WebScrapingUseCase } from './WebScraping'; export const metadata = generateUseCaseMetadata(USE_CASES.webScraping); diff --git a/src/client/components/common/Accordion/Accordion.module.scss b/src/client/components/Accordion/Accordion.module.scss similarity index 100% rename from src/client/components/common/Accordion/Accordion.module.scss rename to src/client/components/Accordion/Accordion.module.scss diff --git a/src/client/components/common/Accordion/Accordion.tsx b/src/client/components/Accordion/Accordion.tsx similarity index 93% rename from src/client/components/common/Accordion/Accordion.tsx rename to src/client/components/Accordion/Accordion.tsx index f7d108a9..0c7f6d9c 100644 --- a/src/client/components/common/Accordion/Accordion.tsx +++ b/src/client/components/Accordion/Accordion.tsx @@ -4,8 +4,8 @@ import * as React from 'react'; import * as AccordionPrimitive from '@radix-ui/react-accordion'; import classnames from 'classnames'; import styles from './Accordion.module.scss'; -import { ButtonPlusSvgThin } from '../../../img/buttonPlusSvg'; -import { ButtonMinusSvgThin } from '../../../img/buttonMinusSvg'; +import { ButtonPlusSvgThin } from '../../img/buttonPlusSvg'; +import { ButtonMinusSvgThin } from '../../img/buttonMinusSvg'; import { extendUnstyledPrimitiveWithClass } from '../componentUtils'; /** diff --git a/src/client/components/common/Alert/Alert.tsx b/src/client/components/Alert/Alert.tsx similarity index 93% rename from src/client/components/common/Alert/Alert.tsx rename to src/client/components/Alert/Alert.tsx index 9410f916..9dd0303c 100644 --- a/src/client/components/common/Alert/Alert.tsx +++ b/src/client/components/Alert/Alert.tsx @@ -2,16 +2,16 @@ import { FunctionComponent, PropsWithChildren } from 'react'; import SuccessIcon from './sucess.svg'; import ErrorIcon from './error.svg'; import WarningIcon from './warning.svg'; -import InfoIcon from '../../../../client/img/InfoIcon.svg'; +import InfoIcon from '../../img/InfoIconSvg.svg'; import styles from './alert.module.scss'; import Image from 'next/image'; import classNames from 'classnames'; -import { TEST_ATTRIBUTES, TEST_IDS } from '../../../testIDs'; +import { TEST_ATTRIBUTES, TEST_IDS } from '../../testIDs'; import { CustomContentProps, VariantType, useSnackbar, SnackbarKey } from 'notistack'; import React from 'react'; import Button from '../Button/Button'; -import { CrossIconSvg } from '../../../img/crossIconSvg'; -import { Severity } from '../../../../server/checks'; +import { CrossIconSvg } from '../../img/crossIconSvg'; +import { Severity } from '../../../server/checks'; type AlertProps = { severity: Severity; diff --git a/src/client/components/common/Alert/alert.module.scss b/src/client/components/Alert/alert.module.scss similarity index 100% rename from src/client/components/common/Alert/alert.module.scss rename to src/client/components/Alert/alert.module.scss diff --git a/src/client/components/common/Alert/error.svg b/src/client/components/Alert/error.svg similarity index 100% rename from src/client/components/common/Alert/error.svg rename to src/client/components/Alert/error.svg diff --git a/src/client/components/common/Alert/sucess.svg b/src/client/components/Alert/sucess.svg similarity index 100% rename from src/client/components/common/Alert/sucess.svg rename to src/client/components/Alert/sucess.svg diff --git a/src/client/components/common/Alert/warning.svg b/src/client/components/Alert/warning.svg similarity index 100% rename from src/client/components/common/Alert/warning.svg rename to src/client/components/Alert/warning.svg diff --git a/src/client/components/common/BackArrow/BackArrow.module.scss b/src/client/components/BackArrow/BackArrow.module.scss similarity index 100% rename from src/client/components/common/BackArrow/BackArrow.module.scss rename to src/client/components/BackArrow/BackArrow.module.scss diff --git a/src/client/components/common/BackArrow/BackArrow.tsx b/src/client/components/BackArrow/BackArrow.tsx similarity index 91% rename from src/client/components/common/BackArrow/BackArrow.tsx rename to src/client/components/BackArrow/BackArrow.tsx index ba2db930..cbc44b38 100644 --- a/src/client/components/common/BackArrow/BackArrow.tsx +++ b/src/client/components/BackArrow/BackArrow.tsx @@ -1,7 +1,7 @@ import Link from 'next/link'; import { FunctionComponent } from 'react'; import Image from 'next/image'; -import BackArrowSvg from '../../../../client/img/arrowLeft.svg'; +import BackArrowSvg from '../../img/arrowLeft.svg'; import styles from './BackArrow.module.scss'; type Props = { diff --git a/src/client/components/common/Button/Button.module.scss b/src/client/components/Button/Button.module.scss similarity index 100% rename from src/client/components/common/Button/Button.module.scss rename to src/client/components/Button/Button.module.scss diff --git a/src/client/components/common/Button/Button.tsx b/src/client/components/Button/Button.tsx similarity index 100% rename from src/client/components/common/Button/Button.tsx rename to src/client/components/Button/Button.tsx diff --git a/src/client/components/common/Cart/Cart.tsx b/src/client/components/Cart/Cart.tsx similarity index 95% rename from src/client/components/common/Cart/Cart.tsx rename to src/client/components/Cart/Cart.tsx index d772ebdd..d4f465ca 100644 --- a/src/client/components/common/Cart/Cart.tsx +++ b/src/client/components/Cart/Cart.tsx @@ -1,10 +1,10 @@ import classNames from 'classnames'; import { FunctionComponent } from 'react'; import styles from './cart.module.scss'; -import { ButtonMinusSvg } from '../../../img/buttonMinusSvg'; -import { ButtonPlusSvg } from '../../../img/buttonPlusSvg'; +import { ButtonMinusSvg } from '../../img/buttonMinusSvg'; +import { ButtonPlusSvg } from '../../img/buttonPlusSvg'; import Image from 'next/image'; -import { TEST_IDS } from '../../../testIDs'; +import { TEST_IDS } from '../../testIDs'; const format$ = (price: number) => { return new Intl.NumberFormat('en-US', { diff --git a/src/client/components/common/Cart/cart.module.scss b/src/client/components/Cart/cart.module.scss similarity index 100% rename from src/client/components/common/Cart/cart.module.scss rename to src/client/components/Cart/cart.module.scss diff --git a/src/client/components/common/CodeSnippet/CodeSnippet.module.scss b/src/client/components/CodeSnippet/CodeSnippet.module.scss similarity index 100% rename from src/client/components/common/CodeSnippet/CodeSnippet.module.scss rename to src/client/components/CodeSnippet/CodeSnippet.module.scss diff --git a/src/client/components/common/CodeSnippet/CodeSnippet.tsx b/src/client/components/CodeSnippet/CodeSnippet.tsx similarity index 96% rename from src/client/components/common/CodeSnippet/CodeSnippet.tsx rename to src/client/components/CodeSnippet/CodeSnippet.tsx index 733d20fb..9b5d7938 100644 --- a/src/client/components/common/CodeSnippet/CodeSnippet.tsx +++ b/src/client/components/CodeSnippet/CodeSnippet.tsx @@ -7,8 +7,8 @@ import { MyScrollArea } from '../ScrollArea/ScrollArea'; import { MyCopyButton } from '../CopyButton/CopyButton'; import JsonView from 'react18-json-view'; import 'react18-json-view/src/style.css'; -import { CopyButtonSvg } from '../../../img/CopyButtonSvg'; -import { CheckMarkSvg } from '../../../img/CheckmarkSvg'; +import { CopyButtonSvg } from '../../img/CopyButtonSvg'; +import { CheckMarkSvg } from '../../img/CheckmarkSvg'; export interface CodeSnippetProps { language: string; diff --git a/src/client/components/common/Collapsible/Collapsible.module.scss b/src/client/components/Collapsible/Collapsible.module.scss similarity index 100% rename from src/client/components/common/Collapsible/Collapsible.module.scss rename to src/client/components/Collapsible/Collapsible.module.scss diff --git a/src/client/components/common/Collapsible/Collapsible.tsx b/src/client/components/Collapsible/Collapsible.tsx similarity index 100% rename from src/client/components/common/Collapsible/Collapsible.tsx rename to src/client/components/Collapsible/Collapsible.tsx diff --git a/src/client/components/common/Container/Container.module.scss b/src/client/components/Container/Container.module.scss similarity index 100% rename from src/client/components/common/Container/Container.module.scss rename to src/client/components/Container/Container.module.scss diff --git a/src/client/components/common/Container/index.tsx b/src/client/components/Container/index.tsx similarity index 100% rename from src/client/components/common/Container/index.tsx rename to src/client/components/Container/index.tsx diff --git a/src/client/components/common/CopyButton/CopyButton.module.scss b/src/client/components/CopyButton/CopyButton.module.scss similarity index 100% rename from src/client/components/common/CopyButton/CopyButton.module.scss rename to src/client/components/CopyButton/CopyButton.module.scss diff --git a/src/client/components/common/CopyButton/CopyButton.tsx b/src/client/components/CopyButton/CopyButton.tsx similarity index 90% rename from src/client/components/common/CopyButton/CopyButton.tsx rename to src/client/components/CopyButton/CopyButton.tsx index 64caf63b..a738643d 100644 --- a/src/client/components/common/CopyButton/CopyButton.tsx +++ b/src/client/components/CopyButton/CopyButton.tsx @@ -1,6 +1,6 @@ import { FunctionComponent, useEffect, useState } from 'react'; -import { CopyButtonSvg } from '../../../img/CopyButtonSvg'; -import { CheckMarkSvg } from '../../../img/CheckmarkSvg'; +import { CopyButtonSvg } from '../../img/CopyButtonSvg'; +import { CheckMarkSvg } from '../../img/CheckmarkSvg'; import styles from './CopyButton.module.scss'; import classnames from 'classnames'; diff --git a/src/client/components/common/Dropdown/ArrowSVG.svg b/src/client/components/Dropdown/ArrowSVG.svg similarity index 100% rename from src/client/components/common/Dropdown/ArrowSVG.svg rename to src/client/components/Dropdown/ArrowSVG.svg diff --git a/src/client/components/common/Dropdown/Dropdown.module.scss b/src/client/components/Dropdown/Dropdown.module.scss similarity index 100% rename from src/client/components/common/Dropdown/Dropdown.module.scss rename to src/client/components/Dropdown/Dropdown.module.scss diff --git a/src/client/components/common/Dropdown/Dropdown.tsx b/src/client/components/Dropdown/Dropdown.tsx similarity index 99% rename from src/client/components/common/Dropdown/Dropdown.tsx rename to src/client/components/Dropdown/Dropdown.tsx index d9838371..387e5a22 100644 --- a/src/client/components/common/Dropdown/Dropdown.tsx +++ b/src/client/components/Dropdown/Dropdown.tsx @@ -4,7 +4,7 @@ import ArrowSVG from './ArrowSVG.svg'; import classNames from 'classnames'; import styles from './Dropdown.module.scss'; import Link from 'next/link'; -import { isLocalLink } from '../../../../shared/utils/link'; +import { isLocalLink } from '../../../utils/link'; import Image from 'next/image'; export interface DropdownProps { diff --git a/src/client/components/common/DropdownMenu/DropdownMenu.module.scss b/src/client/components/DropdownMenu/DropdownMenu.module.scss similarity index 100% rename from src/client/components/common/DropdownMenu/DropdownMenu.module.scss rename to src/client/components/DropdownMenu/DropdownMenu.module.scss diff --git a/src/client/components/common/DropdownMenu/DropdownMenu.tsx b/src/client/components/DropdownMenu/DropdownMenu.tsx similarity index 94% rename from src/client/components/common/DropdownMenu/DropdownMenu.tsx rename to src/client/components/DropdownMenu/DropdownMenu.tsx index 90a50e85..622fcd27 100644 --- a/src/client/components/common/DropdownMenu/DropdownMenu.tsx +++ b/src/client/components/DropdownMenu/DropdownMenu.tsx @@ -1,9 +1,9 @@ import React, { useState, useRef, PropsWithChildren } from 'react'; import classNames from 'classnames'; -import ExpandMoreSvg from '../../../img/expand-more.svg'; +import ExpandMoreSvg from '../../img/expand-more.svg'; import styles from './DropdownMenu.module.scss'; import { AnimatePresence, motion } from 'framer-motion'; -import useOnClickOutside from '../../../hooks/useOnClickOutside'; +import useOnClickOutside from '../../hooks/useOnClickOutside'; import Image from 'next/image'; import Dropdown, { DropdownProps } from '../Dropdown/Dropdown'; import Link from 'next/link'; diff --git a/src/client/components/common/FancyNumberedList/FancyNumberedList.module.scss b/src/client/components/FancyNumberedList/FancyNumberedList.module.scss similarity index 100% rename from src/client/components/common/FancyNumberedList/FancyNumberedList.module.scss rename to src/client/components/FancyNumberedList/FancyNumberedList.module.scss diff --git a/src/client/components/common/FancyNumberedList/FancyNumberedList.tsx b/src/client/components/FancyNumberedList/FancyNumberedList.tsx similarity index 100% rename from src/client/components/common/FancyNumberedList/FancyNumberedList.tsx rename to src/client/components/FancyNumberedList/FancyNumberedList.tsx diff --git a/src/client/components/common/Footer/Footer.module.scss b/src/client/components/Footer/Footer.module.scss similarity index 100% rename from src/client/components/common/Footer/Footer.module.scss rename to src/client/components/Footer/Footer.module.scss diff --git a/src/client/components/common/Footer/Footer.tsx b/src/client/components/Footer/Footer.tsx similarity index 98% rename from src/client/components/common/Footer/Footer.tsx rename to src/client/components/Footer/Footer.tsx index c385a40a..84e3009c 100644 --- a/src/client/components/common/Footer/Footer.tsx +++ b/src/client/components/Footer/Footer.tsx @@ -5,7 +5,7 @@ import TwitterSvg from './twitter.svg'; import Container from '../Container'; import styles from './Footer.module.scss'; -import { URL } from '../content'; +import { URL } from '../../content'; import classNames from 'classnames'; import Image from 'next/image'; import LogoSvg from '../Header/fpjs.svg'; diff --git a/src/client/components/common/Footer/github.svg b/src/client/components/Footer/github.svg similarity index 100% rename from src/client/components/common/Footer/github.svg rename to src/client/components/Footer/github.svg diff --git a/src/client/components/common/Footer/linkedin.svg b/src/client/components/Footer/linkedin.svg similarity index 100% rename from src/client/components/common/Footer/linkedin.svg rename to src/client/components/Footer/linkedin.svg diff --git a/src/client/components/common/Footer/twitter.svg b/src/client/components/Footer/twitter.svg similarity index 100% rename from src/client/components/common/Footer/twitter.svg rename to src/client/components/Footer/twitter.svg diff --git a/src/client/components/common/Header/Header.module.scss b/src/client/components/Header/Header.module.scss similarity index 100% rename from src/client/components/common/Header/Header.module.scss rename to src/client/components/Header/Header.module.scss diff --git a/src/client/components/common/Header/Header.tsx b/src/client/components/Header/Header.tsx similarity index 96% rename from src/client/components/common/Header/Header.tsx rename to src/client/components/Header/Header.tsx index 987d828a..c711f9f0 100644 --- a/src/client/components/common/Header/Header.tsx +++ b/src/client/components/Header/Header.tsx @@ -6,18 +6,18 @@ import MobileNavbar from '../MobileNavbar/MobileNavbar'; import Container from '../Container'; import HeaderBar from '../HeaderBar/HeaderBar'; import classNames from 'classnames'; -import { PLAYGROUND_METADATA, URL, USE_CASES_NAVIGATION } from '../content'; +import { PLAYGROUND_METADATA, URL, USE_CASES_NAVIGATION } from '../../content'; import { DropdownLikeLink, DropdownMenu } from '../DropdownMenu/DropdownMenu'; import Image from 'next/image'; import LogoSvg from './fpjs.svg'; -import Restart from '../../../img/restart.svg'; +import Restart from '../../img/restart.svg'; import styles from './Header.module.scss'; import Link from 'next/link'; import Button from '../Button/Button'; -import { useReset } from '../../../hooks/useReset/useReset'; +import { useReset } from '../../hooks/useReset/useReset'; import { Tooltip } from '@mui/material'; -import { TEST_IDS } from '../../../testIDs'; +import { TEST_IDS } from '../../testIDs'; interface HeaderProps { notificationBar?: { diff --git a/src/client/components/common/Header/StarSVG.svg b/src/client/components/Header/StarSVG.svg similarity index 100% rename from src/client/components/common/Header/StarSVG.svg rename to src/client/components/Header/StarSVG.svg diff --git a/src/client/components/common/Header/fpjs.svg b/src/client/components/Header/fpjs.svg similarity index 100% rename from src/client/components/common/Header/fpjs.svg rename to src/client/components/Header/fpjs.svg diff --git a/src/client/components/common/Header/fpjsDark.svg b/src/client/components/Header/fpjsDark.svg similarity index 100% rename from src/client/components/common/Header/fpjsDark.svg rename to src/client/components/Header/fpjsDark.svg diff --git a/src/client/components/common/HeaderBar/HeaderBar.module.scss b/src/client/components/HeaderBar/HeaderBar.module.scss similarity index 100% rename from src/client/components/common/HeaderBar/HeaderBar.module.scss rename to src/client/components/HeaderBar/HeaderBar.module.scss diff --git a/src/client/components/common/HeaderBar/HeaderBar.tsx b/src/client/components/HeaderBar/HeaderBar.tsx similarity index 95% rename from src/client/components/common/HeaderBar/HeaderBar.tsx rename to src/client/components/HeaderBar/HeaderBar.tsx index 1d16a988..1d941b58 100644 --- a/src/client/components/common/HeaderBar/HeaderBar.tsx +++ b/src/client/components/HeaderBar/HeaderBar.tsx @@ -2,7 +2,7 @@ import React from 'react'; import Container from '../Container'; import styles from './HeaderBar.module.scss'; -import { isLocalLink } from '../../../../shared/utils/link'; +import { isLocalLink } from '../../../utils/link'; import Link from 'next/link'; export interface headerBarProps { diff --git a/src/client/components/common/InputNumberWithUnits/InputNumberWithUnits.tsx b/src/client/components/InputNumberWithUnits/InputNumberWithUnits.tsx similarity index 100% rename from src/client/components/common/InputNumberWithUnits/InputNumberWithUnits.tsx rename to src/client/components/InputNumberWithUnits/InputNumberWithUnits.tsx diff --git a/src/client/components/common/InputNumberWithUnits/InputTextWithUnits.module.scss b/src/client/components/InputNumberWithUnits/InputTextWithUnits.module.scss similarity index 100% rename from src/client/components/common/InputNumberWithUnits/InputTextWithUnits.module.scss rename to src/client/components/InputNumberWithUnits/InputTextWithUnits.module.scss diff --git a/src/client/components/common/MobileNavbar/MobileNavbar.module.scss b/src/client/components/MobileNavbar/MobileNavbar.module.scss similarity index 100% rename from src/client/components/common/MobileNavbar/MobileNavbar.module.scss rename to src/client/components/MobileNavbar/MobileNavbar.module.scss diff --git a/src/client/components/common/MobileNavbar/MobileNavbar.tsx b/src/client/components/MobileNavbar/MobileNavbar.tsx similarity index 95% rename from src/client/components/common/MobileNavbar/MobileNavbar.tsx rename to src/client/components/MobileNavbar/MobileNavbar.tsx index 9508c074..47c1f686 100644 --- a/src/client/components/common/MobileNavbar/MobileNavbar.tsx +++ b/src/client/components/MobileNavbar/MobileNavbar.tsx @@ -2,12 +2,12 @@ import React from 'react'; import Button from '../Button/Button'; import classNames from 'classnames'; import styles from './MobileNavbar.module.scss'; -import { PLAYGROUND_METADATA, URL, USE_CASES_NAVIGATION } from '../content'; +import { PLAYGROUND_METADATA, URL, USE_CASES_NAVIGATION } from '../../content'; import { DropdownLikeLink, DropdownMenu } from '../DropdownMenu/DropdownMenu'; import Image from 'next/image'; -import Restart from '../../../img/restart.svg'; -import { useReset } from '../../../hooks/useReset/useReset'; -import { TEST_IDS } from '../../../testIDs'; +import Restart from '../../img/restart.svg'; +import { useReset } from '../../hooks/useReset/useReset'; +import { TEST_IDS } from '../../testIDs'; interface MobileNavbarProps { darkMode?: boolean; diff --git a/src/client/components/common/ResourceLinks/ResourceLinks.module.scss b/src/client/components/ResourceLinks/ResourceLinks.module.scss similarity index 100% rename from src/client/components/common/ResourceLinks/ResourceLinks.module.scss rename to src/client/components/ResourceLinks/ResourceLinks.module.scss diff --git a/src/client/components/common/ResourceLinks/ResourceLinks.tsx b/src/client/components/ResourceLinks/ResourceLinks.tsx similarity index 94% rename from src/client/components/common/ResourceLinks/ResourceLinks.tsx rename to src/client/components/ResourceLinks/ResourceLinks.tsx index 24c08ea3..ca881eba 100644 --- a/src/client/components/common/ResourceLinks/ResourceLinks.tsx +++ b/src/client/components/ResourceLinks/ResourceLinks.tsx @@ -1,5 +1,5 @@ import { FunctionComponent } from 'react'; -import { ResourceLink } from '../content'; +import { ResourceLink } from '../../content'; import styles from './ResourceLinks.module.scss'; import Container from '../Container'; diff --git a/src/client/components/common/ScrollArea/ScrollArea.module.scss b/src/client/components/ScrollArea/ScrollArea.module.scss similarity index 100% rename from src/client/components/common/ScrollArea/ScrollArea.module.scss rename to src/client/components/ScrollArea/ScrollArea.module.scss diff --git a/src/client/components/common/ScrollArea/ScrollArea.tsx b/src/client/components/ScrollArea/ScrollArea.tsx similarity index 100% rename from src/client/components/common/ScrollArea/ScrollArea.tsx rename to src/client/components/ScrollArea/ScrollArea.tsx diff --git a/src/client/components/common/Select/Select.module.scss b/src/client/components/Select/Select.module.scss similarity index 100% rename from src/client/components/common/Select/Select.module.scss rename to src/client/components/Select/Select.module.scss diff --git a/src/client/components/common/Select/Select.tsx b/src/client/components/Select/Select.tsx similarity index 97% rename from src/client/components/common/Select/Select.tsx rename to src/client/components/Select/Select.tsx index 761c3ed0..475a5a17 100644 --- a/src/client/components/common/Select/Select.tsx +++ b/src/client/components/Select/Select.tsx @@ -3,7 +3,7 @@ import * as RadixSelect from '@radix-ui/react-select'; import * as ScrollArea from '@radix-ui/react-scroll-area'; import classnames from 'classnames'; import styles from './Select.module.scss'; -import ChevronIcon from '../../../img/chevron.svg'; +import ChevronIcon from '../../img/chevron.svg'; import Image from 'next/image'; export const Select = React.forwardRef< diff --git a/src/client/components/common/Slider/Slider.module.scss b/src/client/components/Slider/Slider.module.scss similarity index 100% rename from src/client/components/common/Slider/Slider.module.scss rename to src/client/components/Slider/Slider.module.scss diff --git a/src/client/components/common/Slider/Slider.tsx b/src/client/components/Slider/Slider.tsx similarity index 100% rename from src/client/components/common/Slider/Slider.tsx rename to src/client/components/Slider/Slider.tsx diff --git a/src/client/components/common/Spinner/Spinner.module.scss b/src/client/components/Spinner/Spinner.module.scss similarity index 100% rename from src/client/components/common/Spinner/Spinner.module.scss rename to src/client/components/Spinner/Spinner.module.scss diff --git a/src/client/components/common/Spinner/Spinner.tsx b/src/client/components/Spinner/Spinner.tsx similarity index 86% rename from src/client/components/common/Spinner/Spinner.tsx rename to src/client/components/Spinner/Spinner.tsx index 7756324e..da068249 100644 --- a/src/client/components/common/Spinner/Spinner.tsx +++ b/src/client/components/Spinner/Spinner.tsx @@ -1,6 +1,6 @@ import { FunctionComponent } from 'react'; import styles from './Spinner.module.scss'; -import { SpinnerSvg } from '../../../img/SpinnerSvg'; +import { SpinnerSvg } from '../../img/SpinnerSvg'; import classNames from 'classnames'; export const Spinner: FunctionComponent<{ diff --git a/src/client/components/common/UseCaseWrapper/RestartHint.tsx b/src/client/components/UseCaseWrapper/RestartHint.tsx similarity index 100% rename from src/client/components/common/UseCaseWrapper/RestartHint.tsx rename to src/client/components/UseCaseWrapper/RestartHint.tsx diff --git a/src/client/components/common/UseCaseWrapper/UseCaseWrapper.module.scss b/src/client/components/UseCaseWrapper/UseCaseWrapper.module.scss similarity index 100% rename from src/client/components/common/UseCaseWrapper/UseCaseWrapper.module.scss rename to src/client/components/UseCaseWrapper/UseCaseWrapper.module.scss diff --git a/src/client/components/common/UseCaseWrapper/UseCaseWrapper.tsx b/src/client/components/UseCaseWrapper/UseCaseWrapper.tsx similarity index 92% rename from src/client/components/common/UseCaseWrapper/UseCaseWrapper.tsx rename to src/client/components/UseCaseWrapper/UseCaseWrapper.tsx index c1e51b38..13ce7dc1 100644 --- a/src/client/components/common/UseCaseWrapper/UseCaseWrapper.tsx +++ b/src/client/components/UseCaseWrapper/UseCaseWrapper.tsx @@ -7,14 +7,13 @@ import Button from '../Button/Button'; import Lightbulb from './lightbulb.svg'; import Image from 'next/image'; import { Tooltip } from '@mui/material'; -import { UseCase } from '../content'; -import ExternalLinkIcon from '../../../img/externalLinkArrow.svg'; -import RestartIcon from '../../../img/restart.svg'; -import { useReset } from '../../../hooks/useReset/useReset'; +import { UseCase } from '../../content'; +import ExternalLinkIcon from '../../img/externalLinkArrow.svg'; +import RestartIcon from '../../img/restart.svg'; +import { useReset } from '../../hooks/useReset/useReset'; import classNames from 'classnames'; import { RestartHint } from './RestartHint'; -import { SEO } from '../seo'; -import { TEST_IDS } from '../../../testIDs'; +import { TEST_IDS } from '../../testIDs'; import { FancyNumberedList } from '../FancyNumberedList/FancyNumberedList'; import { ResourceLinks } from '../ResourceLinks/ResourceLinks'; @@ -57,7 +56,6 @@ export const UseCaseWrapper: FunctionComponent = ({ return ( <> - {embed && shouldDisplayResetButton && (
{ - const metaImage = image ?? `${PRODUCTION_URL}/fingerprintDefaultMetaImage.png`; - const metaUrl = `${PRODUCTION_URL}${path ?? ''}`; - return { - title, - description, - openGraph: { - type: 'website', - title, - description, - siteName: 'Fingerprint Use Cases', - images: [metaImage], - url: metaUrl, - }, - twitter: { - title, - description, - card: 'summary_large_image', - images: [metaImage], - site: metaUrl, - }, - }; -}; - -export const generateUseCaseMetadata = (useCase: Pick): Metadata => - generateMetadata({ - title: useCase.titleMeta, - description: useCase.descriptionMeta, - path: useCase.url, - }); - -/** - * Generates next/Head tags for Next `pages` directory - */ -export const SEO: FunctionComponent = ({ title, description, image, path }) => { - const metaImage = image ?? `${PRODUCTION_URL}/fingerprintDefaultMetaImage.png`; - const metaUrl = `${PRODUCTION_URL}${path ?? ''}`; - return ( - - {title} - - - - - - - - - - - - - - - - - ); -}; diff --git a/src/client/components/common/componentUtils.tsx b/src/client/components/componentUtils.tsx similarity index 100% rename from src/client/components/common/componentUtils.tsx rename to src/client/components/componentUtils.tsx diff --git a/src/client/components/common/content.tsx b/src/client/content.tsx similarity index 97% rename from src/client/components/common/content.tsx rename to src/client/content.tsx index 93e9f7f5..63e150e2 100644 --- a/src/client/components/common/content.tsx +++ b/src/client/content.tsx @@ -1,18 +1,18 @@ import Link from 'next/link'; -import SmartSignalsIcon from '../../img/smartSignalsIcon.svg'; -import CouponFraudIcon from '../../img/couponFraudIcon.svg'; -import CredentialStuffingIcon from '../../img/credentialStuffingIcon.svg'; -import LoanRiskIcon from '../../img/loanRiskIcon.svg'; -import PaymentFraudIcon from '../../img/paymentFraudIcon.svg'; -import PaywallIcon from '../../img/paywallIcon.svg'; -import PersonalizationIcon from '../../img/personalizationIcon.svg'; -import ScrapingIcon from '../../img/scrapingIcon.svg'; -import FirewallIcon from '../../img/firewallIcon.svg'; -import VpnDetectionIcon from '../../img/vpnDetection.svg'; -import SmsIcon from '../../img/smsIcon.svg'; +import SmartSignalsIcon from './img/smartSignalsIcon.svg'; +import CouponFraudIcon from './img/couponFraudIcon.svg'; +import CredentialStuffingIcon from './img/credentialStuffingIcon.svg'; +import LoanRiskIcon from './img/loanRiskIcon.svg'; +import PaymentFraudIcon from './img/paymentFraudIcon.svg'; +import PaywallIcon from './img/paywallIcon.svg'; +import PersonalizationIcon from './img/personalizationIcon.svg'; +import ScrapingIcon from './img/scrapingIcon.svg'; +import FirewallIcon from './img/firewallIcon.svg'; +import VpnDetectionIcon from './img/vpnDetection.svg'; +import SmsIcon from './img/smsIcon.svg'; import { ReactNode } from 'react'; -import { RestartHint, RestartHintProps } from './UseCaseWrapper/RestartHint'; -import { TEST_PHONE_NUMBER } from '../../../app/sms-pumping/api/smsPumpingConst'; +import { RestartHint, RestartHintProps } from './components/UseCaseWrapper/RestartHint'; +import { TEST_PHONE_NUMBER } from '../app/sms-pumping/api/smsPumpingConst'; export const PRODUCTION_URL = 'https://demo.fingerprint.com'; diff --git a/src/fonts/Inter-SemiBold.ttf b/src/client/fonts/Inter-SemiBold.ttf similarity index 100% rename from src/fonts/Inter-SemiBold.ttf rename to src/client/fonts/Inter-SemiBold.ttf diff --git a/src/fonts/JetBrainsMono-Bold.woff b/src/client/fonts/JetBrainsMono-Bold.woff similarity index 100% rename from src/fonts/JetBrainsMono-Bold.woff rename to src/client/fonts/JetBrainsMono-Bold.woff diff --git a/src/fonts/JetBrainsMono-Bold.woff2 b/src/client/fonts/JetBrainsMono-Bold.woff2 similarity index 100% rename from src/fonts/JetBrainsMono-Bold.woff2 rename to src/client/fonts/JetBrainsMono-Bold.woff2 diff --git a/src/fonts/JetBrainsMono-ExtraBold.woff b/src/client/fonts/JetBrainsMono-ExtraBold.woff similarity index 100% rename from src/fonts/JetBrainsMono-ExtraBold.woff rename to src/client/fonts/JetBrainsMono-ExtraBold.woff diff --git a/src/fonts/JetBrainsMono-ExtraBold.woff2 b/src/client/fonts/JetBrainsMono-ExtraBold.woff2 similarity index 100% rename from src/fonts/JetBrainsMono-ExtraBold.woff2 rename to src/client/fonts/JetBrainsMono-ExtraBold.woff2 diff --git a/src/fonts/JetBrainsMono-Medium.woff b/src/client/fonts/JetBrainsMono-Medium.woff similarity index 100% rename from src/fonts/JetBrainsMono-Medium.woff rename to src/client/fonts/JetBrainsMono-Medium.woff diff --git a/src/fonts/JetBrainsMono-Medium.woff2 b/src/client/fonts/JetBrainsMono-Medium.woff2 similarity index 100% rename from src/fonts/JetBrainsMono-Medium.woff2 rename to src/client/fonts/JetBrainsMono-Medium.woff2 diff --git a/src/fonts/JetBrainsMono-Regular.woff b/src/client/fonts/JetBrainsMono-Regular.woff similarity index 100% rename from src/fonts/JetBrainsMono-Regular.woff rename to src/client/fonts/JetBrainsMono-Regular.woff diff --git a/src/fonts/JetBrainsMono-Regular.woff2 b/src/client/fonts/JetBrainsMono-Regular.woff2 similarity index 100% rename from src/fonts/JetBrainsMono-Regular.woff2 rename to src/client/fonts/JetBrainsMono-Regular.woff2 diff --git a/src/fonts/inter-v12-latin-200.woff b/src/client/fonts/inter-v12-latin-200.woff similarity index 100% rename from src/fonts/inter-v12-latin-200.woff rename to src/client/fonts/inter-v12-latin-200.woff diff --git a/src/fonts/inter-v12-latin-200.woff2 b/src/client/fonts/inter-v12-latin-200.woff2 similarity index 100% rename from src/fonts/inter-v12-latin-200.woff2 rename to src/client/fonts/inter-v12-latin-200.woff2 diff --git a/src/fonts/inter-v12-latin-500.woff b/src/client/fonts/inter-v12-latin-500.woff similarity index 100% rename from src/fonts/inter-v12-latin-500.woff rename to src/client/fonts/inter-v12-latin-500.woff diff --git a/src/fonts/inter-v12-latin-500.woff2 b/src/client/fonts/inter-v12-latin-500.woff2 similarity index 100% rename from src/fonts/inter-v12-latin-500.woff2 rename to src/client/fonts/inter-v12-latin-500.woff2 diff --git a/src/fonts/inter-v12-latin-600.woff b/src/client/fonts/inter-v12-latin-600.woff similarity index 100% rename from src/fonts/inter-v12-latin-600.woff rename to src/client/fonts/inter-v12-latin-600.woff diff --git a/src/fonts/inter-v12-latin-600.woff2 b/src/client/fonts/inter-v12-latin-600.woff2 similarity index 100% rename from src/fonts/inter-v12-latin-600.woff2 rename to src/client/fonts/inter-v12-latin-600.woff2 diff --git a/src/fonts/inter-v12-latin-700.woff b/src/client/fonts/inter-v12-latin-700.woff similarity index 100% rename from src/fonts/inter-v12-latin-700.woff rename to src/client/fonts/inter-v12-latin-700.woff diff --git a/src/fonts/inter-v12-latin-700.woff2 b/src/client/fonts/inter-v12-latin-700.woff2 similarity index 100% rename from src/fonts/inter-v12-latin-700.woff2 rename to src/client/fonts/inter-v12-latin-700.woff2 diff --git a/src/fonts/inter-v12-latin-regular.woff b/src/client/fonts/inter-v12-latin-regular.woff similarity index 100% rename from src/fonts/inter-v12-latin-regular.woff rename to src/client/fonts/inter-v12-latin-regular.woff diff --git a/src/fonts/inter-v12-latin-regular.woff2 b/src/client/fonts/inter-v12-latin-regular.woff2 similarity index 100% rename from src/fonts/inter-v12-latin-regular.woff2 rename to src/client/fonts/inter-v12-latin-regular.woff2 diff --git a/src/client/hooks/useReset/useReset.tsx b/src/client/hooks/useReset/useReset.tsx index 955dafe2..6d2a9d41 100644 --- a/src/client/hooks/useReset/useReset.tsx +++ b/src/client/hooks/useReset/useReset.tsx @@ -5,7 +5,7 @@ import { useMutation } from 'react-query'; import { ResetRequest, ResetResponse } from '../../../app/api/admin/reset/route'; import { useSnackbar } from 'notistack'; import styles from './userReset.module.scss'; -import { PLAYGROUND_METADATA, USE_CASES } from '../../components/common/content'; +import { PLAYGROUND_METADATA, USE_CASES } from '../../content'; import { TEST_IDS } from '../../testIDs'; import { usePathname } from 'next/navigation'; diff --git a/src/client/img/InfoIcon.svg b/src/client/img/InfoIconSvg.svg similarity index 100% rename from src/client/img/InfoIcon.svg rename to src/client/img/InfoIconSvg.svg diff --git a/src/client/seo.tsx b/src/client/seo.tsx new file mode 100644 index 00000000..e2b1800c --- /dev/null +++ b/src/client/seo.tsx @@ -0,0 +1,44 @@ +import { PRODUCTION_URL, UseCase } from './content'; +import { Metadata } from 'next'; + +type SeoProps = { + title: string; + description: string; + image?: string; + path?: string; +}; + +/** + * Generates Metadata object for Next `app` directory + * https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadata-fields + */ +export const generateMetadata = ({ title, description, image, path }: SeoProps): Metadata => { + const metaImage = image ?? `${PRODUCTION_URL}/fingerprintDefaultMetaImage.png`; + const metaUrl = `${PRODUCTION_URL}${path ?? ''}`; + return { + title, + description, + openGraph: { + type: 'website', + title, + description, + siteName: 'Fingerprint Use Cases', + images: [metaImage], + url: metaUrl, + }, + twitter: { + title, + description, + card: 'summary_large_image', + images: [metaImage], + site: metaUrl, + }, + }; +}; + +export const generateUseCaseMetadata = (useCase: Pick): Metadata => + generateMetadata({ + title: useCase.titleMeta, + description: useCase.descriptionMeta, + path: useCase.url, + }); diff --git a/src/styles/_animations.scss b/src/client/styles/_animations.scss similarity index 100% rename from src/styles/_animations.scss rename to src/client/styles/_animations.scss diff --git a/src/styles/_functions.scss b/src/client/styles/_functions.scss similarity index 100% rename from src/styles/_functions.scss rename to src/client/styles/_functions.scss diff --git a/src/styles/_mixins.scss b/src/client/styles/_mixins.scss similarity index 100% rename from src/styles/_mixins.scss rename to src/client/styles/_mixins.scss diff --git a/src/styles/_typography.scss b/src/client/styles/_typography.scss similarity index 100% rename from src/styles/_typography.scss rename to src/client/styles/_typography.scss diff --git a/src/styles/_variables.scss b/src/client/styles/_variables.scss similarity index 100% rename from src/styles/_variables.scss rename to src/client/styles/_variables.scss diff --git a/src/styles/common.scss b/src/client/styles/common.scss similarity index 100% rename from src/styles/common.scss rename to src/client/styles/common.scss diff --git a/src/styles/custom-properties.scss b/src/client/styles/custom-properties.scss similarity index 100% rename from src/styles/custom-properties.scss rename to src/client/styles/custom-properties.scss diff --git a/src/styles/forms.module.scss b/src/client/styles/forms.module.scss similarity index 100% rename from src/styles/forms.module.scss rename to src/client/styles/forms.module.scss diff --git a/src/styles/global-styles.scss b/src/client/styles/global-styles.scss similarity index 100% rename from src/styles/global-styles.scss rename to src/client/styles/global-styles.scss diff --git a/src/styles/vendors/code-theme.scss b/src/client/styles/vendors/code-theme.scss similarity index 100% rename from src/styles/vendors/code-theme.scss rename to src/client/styles/vendors/code-theme.scss diff --git a/src/styles/vendors/normalize.scss b/src/client/styles/vendors/normalize.scss similarity index 100% rename from src/styles/vendors/normalize.scss rename to src/client/styles/vendors/normalize.scss diff --git a/src/styles/vendors/swiper.scss b/src/client/styles/vendors/swiper.scss similarity index 100% rename from src/styles/vendors/swiper.scss rename to src/client/styles/vendors/swiper.scss diff --git a/src/styles/vendors/tippy.scss b/src/client/styles/vendors/tippy.scss similarity index 100% rename from src/styles/vendors/tippy.scss rename to src/client/styles/vendors/tippy.scss diff --git a/src/pages/.DS_Store b/src/pages/.DS_Store deleted file mode 100644 index db382ee5faefeec94fa08e599bdc7a458c441aad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyH3ME5S)b+k)TLPc|SnGADp7_1^EFG5j4m_kxcE1@8Z*#eF({NC@5&qth76K zdpl=&3a=M{ZO6kMumP~9JL1E`()`?gVHcG#BAs^}G2j-@IN@Ey`g% zQBev=fw=;gx!rjGzo-8&|IbO) { - return ( - <> - - - - Fingerprint Pro Use Cases - - - - - - - - ); -} - -export default CustomApp; diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx deleted file mode 100644 index c26e31a5..00000000 --- a/src/pages/_document.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { Html, Head, Main, NextScript } from 'next/document'; - -export default function Document() { - return ( - - - - - -
- - - - ); -} diff --git a/src/pages/api/event/[requestId].ts b/src/pages/api/event/[requestId].ts deleted file mode 100644 index 5df2b8e5..00000000 --- a/src/pages/api/event/[requestId].ts +++ /dev/null @@ -1,86 +0,0 @@ -import { isEventError } from '@fingerprintjs/fingerprintjs-pro-server-api'; -import { NextApiRequest, NextApiResponse } from 'next'; -import { fingerprintServerApiClient } from '../../../server/fingerprint-server-api'; -import Cors from 'cors'; -import { OUR_ORIGINS } from '../../../server/checks'; -import { IS_PRODUCTION } from '../../../envShared'; - -// Also allow our documentation to use the endpoint -const allowedOrigins = [...OUR_ORIGINS, 'https://dev.fingerprint.com']; - -// We need to set up CORS for that https://github.com/expressjs/cors#configuration-options -const cors = Cors({ - methods: ['POST', 'HEAD'], - origin: allowedOrigins, -}); - -// Helper method to wait for a middleware to execute before continuing -// And to throw an error when an error happens in a middleware -// https://github.com/vercel/next.js/blob/canary/examples/api-routes-cors/pages/api/cors.ts -function runMiddleware(req: NextApiRequest, res: NextApiResponse, fn: Function) { - return new Promise((resolve, reject) => { - fn(req, res, (result: any) => { - if (result instanceof Error) { - return reject(result); - } - - return resolve(result); - }); - }); -} - -export default async function getFingerprintEvent(req: NextApiRequest, res: NextApiResponse) { - // Run the CORS middleware - await runMiddleware(req, res, cors); - - /** - * In production, it's a good idea to validate the origin of the request, - * since this endpoint exposes the underlying authenticated Fingerprint Server API endpoint. - * It's just an extra precaution, you should primarily be using [Request filtering](https://dev.fingerprint.com/docs/request-filtering) - * to protect your Public API key from unauthorized usage. - */ - const origin = req.headers['origin'] as string; - if (IS_PRODUCTION && !allowedOrigins.includes(origin)) { - res.status(403).send({ message: `Origin ${origin} is not allowed to call this endpoint` }); - return; - } - - const { requestId } = req.query as { requestId: string }; - return await tryGetFingerprintEvent(res, requestId); -} - -/** - * It's possible the data about the specific event is not propagated to the Server API yet. This function retries for Not Found (404) requests. - * */ -async function tryGetFingerprintEvent( - res: NextApiResponse, - requestId: string, - retryCount = 5, - retryDelay: number = 3000, -) { - try { - const eventResponse = await fingerprintServerApiClient.getEvent(requestId); - res.status(200).json(eventResponse); - } catch (error) { - // Retry only Not Found (404) requests. - if (isEventError(error) && error.statusCode === 404 && retryCount > 1) { - setTimeout(() => tryGetFingerprintEvent(res, requestId, retryCount - 1, retryDelay), retryDelay); - } else { - console.error(error); - sendErrorResponse(res, error); - } - } -} - -function sendErrorResponse(res: NextApiResponse, error: unknown) { - if (isEventError(error)) { - res.statusMessage = `${error.errorCode} - ${error.message}`; - res.status(error.statusCode).json({ - message: error.message, - code: error.errorCode, - }); - } else { - res.statusMessage = `Something went wrong ${error}`; - res.status(500).end(); - } -} diff --git a/src/pages/sitemap.xml.ts b/src/pages/sitemap.xml.ts deleted file mode 100644 index 4b9c2a87..00000000 --- a/src/pages/sitemap.xml.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { GetServerSideProps } from 'next'; -import { HOMEPAGE_CARDS, PRODUCTION_URL } from '../client/components/common/content'; - -function generateSiteMap() { - return ` - - - ${PRODUCTION_URL} - - ${HOMEPAGE_CARDS.map(({ url }) => { - return ` - - ${`${PRODUCTION_URL}${url}`} - - `; - }).join('')} - - `; -} - -function SiteMap() { - // getServerSideProps will do the heavy lifting -} - -export const getServerSideProps: GetServerSideProps = async ({ res }) => { - const sitemap = generateSiteMap(); - - res.setHeader('Content-Type', 'text/xml'); - // we send the XML to the browser - res.write(sitemap); - res.end(); - - return { - props: {}, - }; -}; - -export default SiteMap; diff --git a/src/server/checks.ts b/src/server/checks.ts index 65265c19..3c1d1c49 100644 --- a/src/server/checks.ts +++ b/src/server/checks.ts @@ -4,7 +4,7 @@ import { Region, isEventError, } from '@fingerprintjs/fingerprintjs-pro-server-api'; -import { ValidationDataResult } from '../shared/types'; +import { ValidationDataResult } from '../utils/types'; import { decryptSealedResult } from './decryptSealedResult'; import { env } from '../env'; import { getServerRegion } from './fingerprint-server-api'; diff --git a/src/shared/utils/date.ts b/src/shared/utils/date.ts deleted file mode 100644 index 70442217..00000000 --- a/src/shared/utils/date.ts +++ /dev/null @@ -1,7 +0,0 @@ -export function getTodayDateRange(): [Date, Date] { - const timestampStart = new Date(); - const timestampEnd = new Date(); - timestampStart.setHours(0, 0, 0, 0); - timestampEnd.setHours(23, 59, 59, 59); - return [timestampStart, timestampEnd]; -} diff --git a/src/shared/utils/link.ts b/src/utils/link.ts similarity index 100% rename from src/shared/utils/link.ts rename to src/utils/link.ts diff --git a/src/shared/utils/locationUtils.test.ts b/src/utils/locationUtils.test.ts similarity index 100% rename from src/shared/utils/locationUtils.test.ts rename to src/utils/locationUtils.test.ts diff --git a/src/shared/utils/locationUtils.ts b/src/utils/locationUtils.ts similarity index 96% rename from src/shared/utils/locationUtils.ts rename to src/utils/locationUtils.ts index 32f76220..f91639f7 100644 --- a/src/shared/utils/locationUtils.ts +++ b/src/utils/locationUtils.ts @@ -1,5 +1,5 @@ import { EventResponse } from '@fingerprintjs/fingerprintjs-pro-server-api'; -import { EventResponseIpInfoV4Geolocation } from '../types'; +import { EventResponseIpInfoV4Geolocation } from './types'; export const UNKNOWN_LOCATION = 'Unknown'; export function getLocationName(ipLocation?: EventResponseIpInfoV4Geolocation, includeSubdivision = true) { diff --git a/src/shared/timeUtils.spec.ts b/src/utils/timeUtils.spec.ts similarity index 100% rename from src/shared/timeUtils.spec.ts rename to src/utils/timeUtils.spec.ts diff --git a/src/shared/timeUtils.ts b/src/utils/timeUtils.ts similarity index 86% rename from src/shared/timeUtils.ts rename to src/utils/timeUtils.ts index b17769fd..f06ffd63 100644 --- a/src/shared/timeUtils.ts +++ b/src/utils/timeUtils.ts @@ -53,3 +53,11 @@ export const timeAgoLabel = (dateString: string): string => { } return `More than 3 months ago`; }; + +export function getTodayDateRange(): [Date, Date] { + const timestampStart = new Date(); + const timestampEnd = new Date(); + timestampStart.setHours(0, 0, 0, 0); + timestampEnd.setHours(23, 59, 59, 59); + return [timestampStart, timestampEnd]; +} diff --git a/src/shared/types.ts b/src/utils/types.ts similarity index 100% rename from src/shared/types.ts rename to src/utils/types.ts diff --git a/src/shared/utils.test.ts b/src/utils/utils.test.ts similarity index 100% rename from src/shared/utils.test.ts rename to src/utils/utils.test.ts diff --git a/src/shared/utils.ts b/src/utils/utils.ts similarity index 100% rename from src/shared/utils.ts rename to src/utils/utils.ts