From c95a9271e2472ca9fe89a28b81c204716a334cae Mon Sep 17 00:00:00 2001 From: Arnab Paryali Date: Mon, 14 Apr 2025 11:25:35 +0530 Subject: [PATCH 1/8] remove existing base --- .react-router/types/+register.ts | 11 + .react-router/types/+virtual.d.ts | 14 + .react-router/types/app/+types/root.ts | 42 + .../types/app/routes/+types/_index.ts | 42 + ...ae74653567866b23a3447f2708bab38d223.sqlite | Bin 0 -> 16384 bytes README.md | 20 - components/Breadcrumb.tsx | 66 - components/Icons.tsx | 27 - components/List.tsx | 151 -- components/Nav.tsx | 53 - components/index.ts | 4 - lib/dropbox.ts | 7 - next-env.d.ts | 5 - next.config.js | 4 - package.json | 32 - pages/[...path].tsx | 60 - pages/_app.tsx | 22 - pages/api/auth/index.ts | 34 - pages/api/auth/token.ts | 27 - pages/api/download/[...path].ts | 26 - pages/api/explore/[...path].ts | 28 - pages/api/explore/index.ts | 25 - pages/api/search.ts | 22 - pages/index.tsx | 32 - postcss.config.js | 6 - public/favicon.ico | Bin 15406 -> 0 bytes render.yaml | 16 - styles/globals.css | 75 - tailwind.config.js | 10 - tsconfig.json | 20 - vercel.json | 5 - yarn.lock | 2312 ----------------- 32 files changed, 109 insertions(+), 3089 deletions(-) create mode 100644 .react-router/types/+register.ts create mode 100644 .react-router/types/+virtual.d.ts create mode 100644 .react-router/types/app/+types/root.ts create mode 100644 .react-router/types/app/routes/+types/_index.ts create mode 100644 .wrangler/state/v3/kv/miniflare-KVNamespaceObject/dee9512fb86ba359c35318b9a7cb2ae74653567866b23a3447f2708bab38d223.sqlite delete mode 100644 README.md delete mode 100644 components/Breadcrumb.tsx delete mode 100644 components/Icons.tsx delete mode 100644 components/List.tsx delete mode 100644 components/Nav.tsx delete mode 100644 components/index.ts delete mode 100644 lib/dropbox.ts delete mode 100644 next-env.d.ts delete mode 100644 next.config.js delete mode 100644 package.json delete mode 100644 pages/[...path].tsx delete mode 100644 pages/_app.tsx delete mode 100644 pages/api/auth/index.ts delete mode 100644 pages/api/auth/token.ts delete mode 100644 pages/api/download/[...path].ts delete mode 100644 pages/api/explore/[...path].ts delete mode 100644 pages/api/explore/index.ts delete mode 100644 pages/api/search.ts delete mode 100644 pages/index.tsx delete mode 100644 postcss.config.js delete mode 100644 public/favicon.ico delete mode 100644 render.yaml delete mode 100644 styles/globals.css delete mode 100644 tailwind.config.js delete mode 100644 tsconfig.json delete mode 100644 vercel.json delete mode 100644 yarn.lock diff --git a/.react-router/types/+register.ts b/.react-router/types/+register.ts new file mode 100644 index 0000000..5c8cbde --- /dev/null +++ b/.react-router/types/+register.ts @@ -0,0 +1,11 @@ +import "react-router"; + +declare module "react-router" { + interface Register { + params: Params; + } +} + +type Params = { + "/": {}; +}; \ No newline at end of file diff --git a/.react-router/types/+virtual.d.ts b/.react-router/types/+virtual.d.ts new file mode 100644 index 0000000..512fadf --- /dev/null +++ b/.react-router/types/+virtual.d.ts @@ -0,0 +1,14 @@ +declare module "virtual:react-router/server-build" { + import { ServerBuild } from "react-router"; + export const assets: ServerBuild["assets"]; + export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"]; + export const basename: ServerBuild["basename"]; + export const entry: ServerBuild["entry"]; + export const future: ServerBuild["future"]; + export const isSpaMode: ServerBuild["isSpaMode"]; + export const prerender: ServerBuild["prerender"]; + export const publicPath: ServerBuild["publicPath"]; + export const routes: ServerBuild["routes"]; + export const ssr: ServerBuild["ssr"]; + export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"]; +} \ No newline at end of file diff --git a/.react-router/types/app/+types/root.ts b/.react-router/types/app/+types/root.ts new file mode 100644 index 0000000..d79f252 --- /dev/null +++ b/.react-router/types/app/+types/root.ts @@ -0,0 +1,42 @@ +// React Router generated types for route: +// root.tsx + +import type * as T from "react-router/route-module" + + + +type Module = typeof import("../root.js") + +export type Info = { + parents: [], + id: "root" + file: "root.tsx" + path: "" + params: {} & { [key: string]: string | undefined } + module: Module + loaderData: T.CreateLoaderData + actionData: T.CreateActionData +} + +export namespace Route { + export type LinkDescriptors = T.LinkDescriptors + export type LinksFunction = () => LinkDescriptors + + export type MetaArgs = T.CreateMetaArgs + export type MetaDescriptors = T.MetaDescriptors + export type MetaFunction = (args: MetaArgs) => MetaDescriptors + + export type HeadersArgs = T.HeadersArgs + export type HeadersFunction = (args: HeadersArgs) => Headers | HeadersInit + + export type unstable_MiddlewareFunction = T.CreateServerMiddlewareFunction + export type unstable_ClientMiddlewareFunction = T.CreateClientMiddlewareFunction + export type LoaderArgs = T.CreateServerLoaderArgs + export type ClientLoaderArgs = T.CreateClientLoaderArgs + export type ActionArgs = T.CreateServerActionArgs + export type ClientActionArgs = T.CreateClientActionArgs + + export type HydrateFallbackProps = T.CreateHydrateFallbackProps + export type ComponentProps = T.CreateComponentProps + export type ErrorBoundaryProps = T.CreateErrorBoundaryProps +} \ No newline at end of file diff --git a/.react-router/types/app/routes/+types/_index.ts b/.react-router/types/app/routes/+types/_index.ts new file mode 100644 index 0000000..734f0ec --- /dev/null +++ b/.react-router/types/app/routes/+types/_index.ts @@ -0,0 +1,42 @@ +// React Router generated types for route: +// routes/_index.tsx + +import type * as T from "react-router/route-module" + +import type { Info as Parent0 } from "../../+types/root.js" + +type Module = typeof import("../_index.js") + +export type Info = { + parents: [Parent0], + id: "routes/_index" + file: "routes/_index.tsx" + path: "undefined" + params: {} & { [key: string]: string | undefined } + module: Module + loaderData: T.CreateLoaderData + actionData: T.CreateActionData +} + +export namespace Route { + export type LinkDescriptors = T.LinkDescriptors + export type LinksFunction = () => LinkDescriptors + + export type MetaArgs = T.CreateMetaArgs + export type MetaDescriptors = T.MetaDescriptors + export type MetaFunction = (args: MetaArgs) => MetaDescriptors + + export type HeadersArgs = T.HeadersArgs + export type HeadersFunction = (args: HeadersArgs) => Headers | HeadersInit + + export type unstable_MiddlewareFunction = T.CreateServerMiddlewareFunction + export type unstable_ClientMiddlewareFunction = T.CreateClientMiddlewareFunction + export type LoaderArgs = T.CreateServerLoaderArgs + export type ClientLoaderArgs = T.CreateClientLoaderArgs + export type ActionArgs = T.CreateServerActionArgs + export type ClientActionArgs = T.CreateClientActionArgs + + export type HydrateFallbackProps = T.CreateHydrateFallbackProps + export type ComponentProps = T.CreateComponentProps + export type ErrorBoundaryProps = T.CreateErrorBoundaryProps +} \ No newline at end of file diff --git a/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/dee9512fb86ba359c35318b9a7cb2ae74653567866b23a3447f2708bab38d223.sqlite b/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/dee9512fb86ba359c35318b9a7cb2ae74653567866b23a3447f2708bab38d223.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..64913a28add6ce4658454787cbcccfc7685f0b3a GIT binary patch literal 16384 zcmeI#!Aiq07{Kwg8%_pu^Wv_7T{aLw#Jg3C3~Q&g!geYh%b>Wexi5|Xb?zWmxt?(e)rD>+Q3<5v?KT`QMHW}F8 z`-IN9=jKQ#nrHL12q1s}0tg_000IagfWT6K`#(Pd0tg_0 T00IagfB*srAb { - const [path, setPath] = useState([]); - - useEffect(() => { - if (!props.path) { - return setPath([]); - } - if (!props.path.includes("/")) { - return setPath([{ display: props.path }]); - } - const paths = props.path.split("/").map((value, index) => { - return { - display: value, - link: - index !== props.path!.split("/").length - 1 - ? "/" + - props - .path!.split("/") - .slice(0, index + 1) - .join("/") - : undefined, - }; - }); - setPath(paths); - }, [props.path]); - - return ( -
- - - - - - {path.length ? ( - path.map((p) => ( - - {" / "} - {p.link ? ( - -

{p.display}

- - ) : ( -

{p.display}

- )} -
- )) - ) : ( - <> - )} -
- ); -}; diff --git a/components/Icons.tsx b/components/Icons.tsx deleted file mode 100644 index d0bb4db..0000000 --- a/components/Icons.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React, { ReactChild } from "react"; - -const Loader = () => ( -
-
-
-
-
-
-
-
-); - -export const Loading = React.memo(Loader); - -interface IconButtonI { - children: ReactChild; - onClick?: () => any; -} - -export const IconButton = ({ children, onClick }: IconButtonI) => { - return ( -
- {children} -
- ); -}; diff --git a/components/List.tsx b/components/List.tsx deleted file mode 100644 index 5f4f3a4..0000000 --- a/components/List.tsx +++ /dev/null @@ -1,151 +0,0 @@ -import React, { useState, useEffect } from "react"; -import { - DownloadIcon, - DocumentIcon, - FolderIcon, - ClipboardIcon, -} from "@heroicons/react/solid"; -import { DropboxResponse, files } from "dropbox"; -import { useClipboard } from "@chakra-ui/hooks"; -import { Toaster, toast } from "react-hot-toast"; -import { useRouter } from "next/router"; - -import { IconButton } from "./Icons"; -import ky from "ky"; -import prettyBytes from "pretty-bytes"; - -interface ListProps { - entries: (files.FileMetadataReference | files.FolderMetadataReference)[]; - path?: string; -} - -export const List = (props: ListProps) => { - const [link, setLink] = useState(""); - const { onCopy } = useClipboard(link); - - const router = useRouter(); - - useEffect(() => { - if (link) { - onCopy(); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [link]); - - const getDownloadLink = async (path: string) => - await ky - .get("/api/download" + path) - .json< - DropboxResponse< - files.GetTemporaryLinkResult | files.GetTemporaryLinkError - > - >(); - - const copyToClipboard = async ( - data: files.FileMetadataReference | files.FolderMetadataReference - ) => { - if (data[".tag"] === "folder") { - setLink(window.location.origin + data.path_display); - } else { - let resp = await getDownloadLink(data.path_display!); - if ("link" in resp.result) { - setLink(resp.result.link); - } else { - throw new Error("Failed to generate download link"); - } - } - }; - - return ( -
-
-
Name
-
- Info -
-
- Actions -
-
- - {props.entries.map((file) => { - return ( -
-
{ - if (file[".tag"] === "folder") { - router.push(file.path_display || "/"); - } else { - getDownloadLink(file.path_display!).then((resp) => { - if ("link" in resp.result) { - router.push(resp.result.link); - } else { - toast.error("Failed to Download Generate Link"); - } - }); - } - }} - > - {file[".tag"] === "file" ? ( - - ) : ( - - )} -

{file.name}

-
-
- {file[".tag"] === "file" && prettyBytes(file.size)} -
-
- - toast.promise( - copyToClipboard(file), - { - success: "Link copied successfully", - error: "Failed to generate link", - loading: "Generating link", - }, - { - style: { - backgroundColor: "#1e293b", - borderWidth: 2, - borderColor: "#475569", - color: "white", - }, - } - ) - } - > - - - {file[".tag"] === "file" && ( - { - getDownloadLink(file.path_display!).then((resp) => { - if ("link" in resp.result) { - router.push(resp.result.link); - } else { - toast.error("Failed to Download Generate Link"); - } - }); - }} - > - - - )} -
-
- ); - })} -
- ); -}; diff --git a/components/Nav.tsx b/components/Nav.tsx deleted file mode 100644 index d9c471f..0000000 --- a/components/Nav.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import React from "react"; -import Link from "next/link"; -import { useDisclosure } from "@chakra-ui/hooks"; -import { SearchIcon } from "@heroicons/react/solid"; -import Head from "next/head"; - -export const Nav = () => { - const title = process.env.NEXT_PUBLIC_TITLE ?? "D-Index"; - const { isOpen, onToggle } = useDisclosure(); - return ( - <> - - {title} - - - - ); -}; diff --git a/components/index.ts b/components/index.ts deleted file mode 100644 index 6747adc..0000000 --- a/components/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { Breadcrumb } from "./Breadcrumb"; -export { Loading, IconButton } from "./Icons"; -export { List } from "./List"; -export { Nav } from "./Nav"; diff --git a/lib/dropbox.ts b/lib/dropbox.ts deleted file mode 100644 index 6691961..0000000 --- a/lib/dropbox.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Dropbox } from "dropbox"; - -export const dropbox = new Dropbox({ - clientId: process.env.APP_ID, - clientSecret: process.env.APP_SECRET, - refreshToken: process.env.REFRESH_TOKEN, -}); diff --git a/next-env.d.ts b/next-env.d.ts deleted file mode 100644 index 4f11a03..0000000 --- a/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// 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 deleted file mode 100644 index 8b61df4..0000000 --- a/next.config.js +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -module.exports = { - reactStrictMode: true, -} diff --git a/package.json b/package.json deleted file mode 100644 index 3f7e515..0000000 --- a/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "dropbox-index", - "private": true, - "scripts": { - "dev": "next dev", - "build": "next build", - "start": "next start", - "lint": "next lint" - }, - "dependencies": { - "@chakra-ui/hooks": "2.0.4", - "@heroicons/react": "1.0.6", - "dropbox": "10.32.0", - "ky": "0.31.1", - "next": "12.2.2", - "pretty-bytes": "6.0.0", - "react": "18.2.0", - "react-dom": "18.2.0", - "react-hot-toast": "2.3.0", - "react-query": "3.39.2" - }, - "devDependencies": { - "@types/node": "16.11.43", - "@types/react": "17.0.45", - "autoprefixer": "10.4.8", - "eslint": "8.22.0", - "eslint-config-next": "12.2.2", - "postcss": "8.4.14", - "tailwindcss": "3.1.7", - "typescript": "4.7.4" - } -} diff --git a/pages/[...path].tsx b/pages/[...path].tsx deleted file mode 100644 index decaa30..0000000 --- a/pages/[...path].tsx +++ /dev/null @@ -1,60 +0,0 @@ -import React, { useEffect, useState } from "react"; -import type { NextPage } from "next"; -import ky from "ky"; -import { useQuery } from "react-query"; -import { DropboxResponse, files } from "dropbox"; -import { useRouter } from "next/router"; -import { Nav, Loading, List, Breadcrumb } from "../components"; - -const Home: NextPage = () => { - const router = useRouter(); - const [path, setPath] = useState(""); - - useEffect(() => { - if (router.query.path) { - if (Array.isArray(router.query.path)) { - setPath(router.query.path.join("/")); - } else { - setPath(router.query.path); - } - } - }, [router.query]); - - const { data, isLoading, isFetching, refetch } = useQuery( - "path-" + path, - async () => { - const resp = await ky - .get("/api/explore/" + path) - .json< - DropboxResponse - >(); - if (resp.status === 200) { - const resp2 = resp as DropboxResponse; - return resp2.result.entries.filter( - (file) => file[".tag"] === "file" || file[".tag"] === "folder" - ) as (files.FileMetadataReference | files.FolderMetadataReference)[]; - } else { - throw new Error("Something Went Wrong"); - } - }, - { enabled: false } - ); - - useEffect(() => { - if (path) { - console.log(path); - refetch(); - } - }, [path, refetch]); - - return ( - <> -