Skip to content

Feature/lospec updated api#1

Merged
wernerbihl merged 7 commits into
mainfrom
feature/lospec-updated-api
Apr 10, 2026
Merged

Feature/lospec updated api#1
wernerbihl merged 7 commits into
mainfrom
feature/lospec-updated-api

Conversation

@wernerbihl
Copy link
Copy Markdown
Contributor

@wernerbihl wernerbihl commented Apr 10, 2026

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.

…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.
Copilot AI review requested due to automatic review settings April 10, 2026 13:01
Comment thread coverage/lcov-report/sorter.js Fixed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread wrangler.toml Outdated
Comment thread src/app/controllers/lospec-palettes.ts
Comment thread src/app/services/lospec-palettes-repository.ts
Comment thread .github/workflows/test-dev.yml Outdated
Comment thread .github/workflows/test-dev.yml Outdated
@wernerbihl wernerbihl merged commit 1832e95 into main Apr 10, 2026
4 checks passed
@wernerbihl wernerbihl deleted the feature/lospec-updated-api branch April 10, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants