Commit 162f198
authored
fix(api): pass gradient_stops and gradient_dir through validation and… (JhaSourav07#2244)
## Description
Fixes JhaSourav07#2238
Custom gradient colors passed via `gradient_stops` and `gradient_dir`
URL parameters were silently ignored, causing the badge to always render
with the default blue gradient.
This PR fixes the issue by:
- Adding `gradient_stops` and `gradient_dir` to `streakParamsSchema` in
`lib/validations.ts`, preventing them from being stripped during Zod
validation.
- Destructuring both fields from `parseResult.data` and passing them
into the `BadgeParams` object in `app/api/streak/route.ts`.
- Calling `generateCustomGradients(params)` before `renderTowers()` in
`lib/svg/generator.ts` so `params.__customGradientId` is populated
before tower rendering begins.
## Pillar
- [ ] 🎨 Pillar 1 — New Theme Design
- [ ] 📐 Pillar 2 — Geometric SVG Improvement
- [ ] 🕐 Pillar 3 — Timezone Logic Optimization
- [X] 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
<img width="1614" height="1007" alt="image"
src="https://github.com/user-attachments/assets/3db5ed79-2b78-4d94-83a7-6ab65dcd20bb"
/>
## Checklist before requesting a review:
- [X] I have read the `CONTRIBUTING.md` file.
- [X] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
- [X] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
- [X] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
- [ ] I have updated `README.md` if I added a new theme or URL
parameter.
- [X] I have started the repo.
- [X] I have made sure that i have only one commit to merge in this PR.
- [X] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
- [X] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.3 files changed
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| |||
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
| 178 | + | |
| 179 | + | |
176 | 180 | | |
177 | 181 | | |
178 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
649 | 652 | | |
650 | 653 | | |
651 | 654 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| 311 | + | |
| 312 | + | |
311 | 313 | | |
312 | 314 | | |
313 | 315 | | |
| |||
0 commit comments