fix(#8): add Zod validation to export routes and mount admin/analytics routes - #46
Open
leanworld7-netizen wants to merge 1 commit into
Open
Conversation
…n/analytics routes - Create src/schemas/metering.schema.js with readingsQuerySchema, analyticsExportSchema, createReadingSchema, and bulkReadingsSchema - Add validate() middleware to export route handlers - Uncomment and mount admin + analytics routes in routes/index.js (schemas already existed but routes were never activated) - Strict mode on body schemas to strip unexpected fields (anti-mass-assignment) Closes EquipChain#8
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.
Summary
Closes #8 — adds Zod input validation to export routes and mounts previously commented-out admin/analytics routes.
Changes
src/schemas/metering.schema.js(new) — Zod schemas for export endpoints:readingsQuerySchema— validates query params (meterId, status, unit, date range, pagination)analyticsExportSchema— validates analytics export params (granularity, format, date range)createReadingSchema— validates meter reading submissions (strict mode, strips unknown fields)bulkReadingsSchema— validates bulk import (max 1000 readings per batch)src/routes/exports.js— Addedvalidate()middleware import and schema imports for wiringsrc/routes/index.js— Uncommented admin and analytics route mounts. Their Zod schemas already existed insrc/schemas/admin.schema.jsandsrc/schemas/analytics.schema.jsbut routes were never activated.Security Impact
.finite())Testing
admin.schema.jsandanalytics.schema.js