Feature/lospec updated api#1
Merged
Merged
Conversation
…ration, and add security vulnerability reporting guidelines
…RS middleware, and integrate palette syncing functionality
- Implement tests for the main app routes, including CORS handling and error responses. - Create unit tests for lospec palette models and services, ensuring correct mapping and fetching behavior. - Add tests for the syncPalettes job to verify the syncing logic and error handling. - Introduce a test environment setup to facilitate database interactions in tests. - Configure Vitest for testing with coverage reporting. - Generate initial coverage report for the application.
There was a problem hiding this comment.
Pull request overview
This PR updates the Lospec palettes API implementation by moving storage/sync logic to D1, restructuring the Worker into a routed Hono app with middleware/controllers/services, and adding a Vitest-based test + CI setup for the Worker.
Changes:
- Replace the prior KV-based palette storage with a D1-backed model/repository and a scheduled sync job that paginates Lospec’s palette list API.
- Introduce a Hono app structure (routes/controllers/middleware) with CORS enforcement and rate limiting.
- Add Vitest config, unit tests, and a GitHub Actions workflow to run tests with coverage gating.
Reviewed changes
Copilot reviewed 24 out of 55 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| wrangler.toml | Adds D1 binding; adjusts rate limiter period (now mismatched with “per hour” comment). |
| vitest.config.ts | Adds Vitest + Cloudflare workers pool configuration and coverage thresholds. |
| tsconfig.json | Includes tests/**/*.ts in TS project for typechecking. |
| TODO.txt | Updates project TODO items. |
| tests/worker.test.ts | Tests the Worker scheduled handler wiring to syncPalettes. |
| tests/sync-palettes.test.ts | Tests sync pagination/stop conditions and timeout handling. |
| tests/models-and-services.test.ts | Tests model normalization + Lospec API service + repository helpers. |
| tests/helpers/env.ts | Provides shared Env stubs for tests. |
| tests/app.test.ts | Tests health route, CORS behavior, rate limiting, and /lospec_palettes query behavior. |
| src/jobs/sync-palettes.ts | New scheduled job that fetches Lospec pages and inserts unseen palettes into D1. |
| src/index.ts | Simplifies Worker entrypoint to delegate HTTP to app and scheduled to syncPalettes. |
| src/config/types.ts | Defines Env/bindings types (DB, rate limiter, internal API key). |
| src/config/constants.ts | Adds constants for origins, internal header name, Lospec endpoints, page sizing. |
| src/app/services/lospec-palettes-repository.ts | Adds D1 queries for checking existing IDs, inserting palettes, and listing with filters/pagination. |
| src/app/services/lospec-api.ts | Adds Lospec palette list page fetch + filtering. |
| src/app/routes/lospec-palettes.ts | Registers /lospec_palettes route. |
| src/app/routes/health.ts | Registers / health route. |
| src/app/models/lospec-palette.ts | Adds palette types + normalization/serialization helpers for DB<->API mapping. |
| src/app/middleware/cors.ts | Adds CORS enforcement and internal-key bypass. |
| src/app/controllers/lospec-palettes.ts | Adds controller for listing palettes with validation + rate limiting. |
| src/app/controllers/health.ts | Adds health controller returning {}. |
| src/app.ts | Composes the Hono app with middleware and routes. |
| SECURITY.md | Adds a vulnerability reporting policy. |
| package.json | Adds typecheck and test scripts; adds Vitest + coverage deps. |
| .github/workflows/test-dev.yml | Adds PR workflow to run tests (name/permissions don’t match behavior). |
| coverage/lcov.info | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/jobs/sync-palettes.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/jobs/index.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/index.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/index.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/config/index.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/config/constants.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/services/lospec-palettes-repository.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/services/lospec-api.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/services/index.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/routes/lospec-palettes.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/routes/index.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/routes/health.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/models/lospec-palette.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/models/index.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/middleware/index.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/middleware/cors.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/controllers/lospec-palettes.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/controllers/index.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app/controllers/health.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/src/app.ts.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/sorter.js | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/sort-arrow-sprite.png | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/prettify.js | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/prettify.css | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/index.html | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/favicon.png | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/block-navigation.js | Generated coverage artifact committed (likely should be excluded). |
| coverage/lcov-report/base.css | Generated coverage artifact committed (likely should be excluded). |
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.
This PR updates the Lospec palettes API implementation by moving storage/sync logic to D1, restructuring the Worker into a routed Hono app with middleware/controllers/services, and adding a Vitest-based test + CI setup for the Worker.
Changes:
Replace the prior KV-based palette storage with a D1-backed model/repository and a scheduled sync job that paginates Lospec’s palette list API.
Introduce a Hono app structure (routes/controllers/middleware) with CORS enforcement and rate limiting.
Add Vitest config, unit tests, and a GitHub Actions workflow to run tests with coverage gating.