Add protected admin submission exports#11
Open
Spbd1 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
validateAdminRequestthat readsADMIN_EXPORT_TOKEN, returns a safe 500 setup error when the token is not configured, returns 401 for missing/invalid bearer tokens, and uses SHA-256 digest +timingSafeEqualfor constant-time comparison without exposing token values (lib/adminAuth.server.ts).GET /api/admin/submissionsreturning JSON withok,items, andnextCursorand cursor pagination based onsubmittedAt+idwithlimitdefault100and max500(app/api/admin/submissions/route.ts,lib/adminSubmissions.ts).GET /api/admin/submissions.csvreturningtext/csvwith one row per submission and proper CSV escaping, outputting empty strings for missing fields and including the requested columns from submission/game/survey/background/metrics (app/api/admin/submissions.csv/route.ts,lib/adminSubmissions.ts).scripts/export-submissions.tsthat readsAPP_BASE_URLandADMIN_EXPORT_TOKEN, calls/api/admin/submissions, createsexports/, and writesexports/submissions-[timestamp].json; add npm scriptexport:submissions(package.json).README.mdwith curl examples for JSON and CSV exports and a usage example for the export script.Testing
npm run typecheckbut it could not complete becausenpm installfailed to fetch@prisma/clientfrom the registry, so typechecking failed due to missing dependencies/types (registry 403); result: not completed.npm run lintandnpm run buildbut both could not run because dependencies (includingnext) were not installed; result: not completed.rg/grep, confirming the admin routes are not linked from frontend code; result: success.Codex Task