{"id":25010892,"url":"https://github.com/jmlweb/file-picker-demo","last_synced_at":"2025-03-30T02:40:51.082Z","repository":{"id":274997164,"uuid":"923756760","full_name":"jmlweb/file-picker-demo","owner":"jmlweb","description":"File Picker Demo","archived":false,"fork":false,"pushed_at":"2025-02-07T00:31:41.000Z","size":540,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T01:26:09.627Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://file-picker-demo.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmlweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-28T19:29:58.000Z","updated_at":"2025-02-05T18:23:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"a35bd64f-c566-4306-90e1-2b441efdd8ca","html_url":"https://github.com/jmlweb/file-picker-demo","commit_stats":null,"previous_names":["jmlweb/file-picker-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmlweb%2Ffile-picker-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmlweb%2Ffile-picker-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmlweb%2Ffile-picker-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmlweb%2Ffile-picker-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmlweb","download_url":"https://codeload.github.com/jmlweb/file-picker-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246269911,"owners_count":20750319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-05T04:55:09.900Z","updated_at":"2025-03-30T02:40:51.066Z","avatar_url":"https://github.com/jmlweb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File Picker Demo\n\n## Running the Project\n\n- Create a `.env.local` file based on `.env.example` (or provide the necessary environment variables).\n- Install dependencies (`pnpm install`).\n- Build the app (`pnpm build`) and start the production server (`pnpm start`). Alternatively, run the development server (`pnpm dev`).\n\n## Technical Choices\n\n### Security\n\n- All data from untrusted sources (API calls, environment variables, etc.) is validated using Zod.\n- Email and password validation is handled server-side with Zod to prevent unnecessary requests to the service. At the same time, the form includes (currently rough-looking) client-side validation.\n- The authentication token is stored as an HTTP-only cookie, preventing client-side access by either the app itself or third parties.\n\n### Code Organization\n\n- The code is structured so that modules are as close as possible to the files that reference them.\n- The dashboard code is placed within a route group `(dashboard)`, allowing shared files and layout components to be kept together.\n\n### Authentication Flow\n\n- Token validation is handled within the dashboard layout. If validation fails, the user is redirected to the login page.\n- The login page also validates the token, displaying user information and allowing them to log out if a token already exists. We do not enforce a redirect here, ensuring that users can manually refresh their token if they become blocked for any reason.\n- The login process runs within a server action, where the resolved token is stored in a secure cookie. In a real-world scenario, a refresh token would also be stored to obtain a new token once the current one expires.\n\n### Data Fetching\n\n- Resource requests are handled client-side using React Query. This approach prevents significant delays that would occur if these expensive requests were moved to the server.\n- The Google Drive file picker modal is triggered by a button inside a component, and its initial request is prefetched as soon as the trigger component is rendered.\n- Resource fetching follows a uniform approach, regardless of whether a root ID is present. In this setup, the ID serves as a dependency key.\n- The connection ID is marked as a dependency of the resources query, ensuring that the query waits for resolution before making the actual request. Initially, we considered resolving it if it didn’t exist as a header, but this could introduce race conditions, which we wanted to avoid at all costs.\n\n### Performance\n\n- The modal dialog component is not rendered until it has been opened at least once.\n- That component (as well as the Google Drive section) is loaded dynamically to aid in code-splitting. However, SSR is enabled to prevent waterfall requests that would otherwise delay client-side component resolution.\n\n### File Picker\n\n- Selected file and folder IDs are not stored at the root level. Instead, they are included as form fields so they can be retrieved when needed without causing unnecessary re-renders.\n- Since we do not want to include child IDs when a folder is selected, we mark the checkbox as selected but do not include the hidden field. This prevents the need for deep traversal of the array to disable individual values.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmlweb%2Ffile-picker-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmlweb%2Ffile-picker-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmlweb%2Ffile-picker-demo/lists"}