Add @neaps/api HTTP JSON API package#192
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #192 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 65 67 +2
Lines 531 581 +50
Branches 58 71 +13
=========================================
+ Hits 531 581 +50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new @neaps/api workspace package that exposes the neaps tide prediction functionality over an Express-based HTTP JSON REST API, including an OpenAPI 3.0 spec and endpoint-level tests.
Changes:
- Introduces
@neaps/apipackage with Express router, OpenAPI spec, and ESM build configuration. - Adds a comprehensive Vitest + Supertest suite covering the API endpoints and error cases.
- Updates the monorepo root README and workspaces list to include/document the new package.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/api/vitest.config.ts | Adds Vitest config for the new API package. |
| packages/api/tsdown.config.js | Adds tsdown build config targeting Node 18+ ESM output. |
| packages/api/tsconfig.json | Adds package-local TS config (typecheck-oriented). |
| packages/api/test/index.test.ts | Adds Supertest-driven endpoint tests. |
| packages/api/src/routes.ts | Implements Express routes + OpenAPI request/response validation + error middleware. |
| packages/api/src/openapi.ts | Defines the OpenAPI 3.0 document served/used for validation. |
| packages/api/src/index.ts | Exposes createApp and exports for router/spec. |
| packages/api/package.json | Defines new workspace package metadata, build scripts, and dependencies. |
| packages/api/README.md | Adds package-level usage and endpoint documentation. |
| package.json | Updates workspace list to include packages/api. |
| README.md | Documents @neaps/api usage and endpoints at the repo root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c25e81c to
d1d24a8
Compare
- Create new Express-based HTTP API package exposing tide prediction functionality - Implement REST endpoints for extremes, timeline, and station queries - Add comprehensive OpenAPI 3.0 specification - Support all GeolibInputCoordinates variations (lat/latitude, lon/lng/longitude) - Handle both reference and subordinate stations appropriately - Include 34 comprehensive tests with 93% code coverage - Configure Node-optimized tsdown build (ESM-only, target node18) - Update root README with API documentation and usage examples
- Remove startServer function in favor of calling .listen() directly on the Express app - Update all documentation to show the .listen() pattern - Add comprehensive error handling tests - Add tests for NaN coordinate validation across all endpoints - Achieve 99.05% test coverage (39 tests, all passing) - Simplify API usage patterns in README examples
- Add NextFunction parameter to error handler (required by Express) - Add comprehensive error validation tests for NaN coordinates - Achieve 97.16% coverage for API package (99.29% overall) - 37 tests passing - Remaining uncovered lines are edge cases (error fallback message)
17e3cc4 to
a5cd7e5
Compare
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
This PR adds a new @neaps/api package that provides a REST API for tide predictions with OpenAPI specification.
Key Features
API Endpoints
GET /extremes- Get high/low tide predictions for a locationGET /timeline- Get water level predictions at intervalsGET /stations- Find stations by ID or near coordinatesGET /stations/:id/extremes- Get extremes for a specific stationGET /stations/:id/timeline- Get timeline for a specific stationGET /openapi.json- OpenAPI 3.0 specificationUsage
Package Structure
src/index.ts- Main Express app with middlewaresrc/routes/index.ts- Route handlers for all endpointssrc/openapi.json- OpenAPI 3.0 specificationtest/index.test.ts- Comprehensive test suitetsdown.config.js- Node-optimized build configurationTesting
All tests pass with 93% code coverage:
Documentation
Build Configuration
Uses Node-optimized tsdown config: