Conversation
Graphemes API database connection
Build graphemes-api Postgres connection string from multiple environment variables
Graphemes API endpoint to get languages
Filter empty strings from database before sending API response
Promote dev to test
There was a problem hiding this comment.
Pull Request Overview
Adds string-splitting utility with tests, implements a new languages API (v1) backed by Zod schema transformations, and configures database connectivity alongside deployment setup.
- Introduces
splitCommaSeparatedStringhelper and corresponding Vitest suite - Defines
LanguageSchemaand exposes GET endpoints for/api/v1/languagesand/api/v1/languages/:id - Configures Knex via environment variables, integrates routers, loads
.env, and adds OpenShift deployment manifest
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| utils/splitCommaSeparatedString.ts | Add utility to split and trim comma-separated text |
| utils/splitCommaSeparatedString.test.ts | Add Vitest cases for utility behavior |
| routes/api/v1/languages/index.ts | Add GET all and GET by ID for languages |
| routes/api/v1/index.ts | Register /languages under v1 router |
| routes/api/index.ts | Mount v1 router and remove default /api endpoint |
| models/Language.ts | Define Zod schema with transforms |
| index.ts | Load dotenv before starting Express |
| db/knexfile.ts | Introduce Knex configuration via env vars |
| db/index.ts | Initialize and export Knex instance |
| openshift/dev/deployment.yaml | Add OpenShift development deployment manifest |
Files not reviewed (1)
- graphemes-api/package.json: Language not supported
Comments suppressed due to low confidence (2)
graphemes-api/src/utils/splitCommaSeparatedString.ts:10
- There is no test case covering a whitespace-only input (e.g., " "), which triggers the early return. Consider adding a test to validate that whitespace-only strings return an empty array.
if (!str.trim()) {
graphemes-api/src/routes/api/index.ts:4
- [nitpick] Removing the default GET /api route removes a basic endpoint that clients may rely on for a health-check or welcome message; consider reintroducing a minimal route or documenting this breaking change.
// GET /api
Fix DB_PASS variable name in dev deployment
Add splitCommaSeparatedString() test for whitespace only input
…parameter Use structured log instead of string literal for case where language isn't found
Promote dev to test
Graphemes API rate limiting
Promote dev to test
There was a problem hiding this comment.
Pull Request Overview
Promote test branch changes into main, adding a new string-splitting utility, full language routes, rate limiting, and database configuration.
- Introduce
splitCommaSeparatedStringutil with comprehensive tests - Add
/api/v1/languagesendpoints with Zod-based parsing - Configure rate limiting, Knex setup, and deployment manifests
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/utils/splitCommaSeparatedString.ts | New helper to split and trim comma-separated text |
| src/utils/splitCommaSeparatedString.test.ts | Tests covering whitespace, empty segments, and grapheme handling |
| src/routes/api/v1/languages/index.ts | GET handlers for all languages and by ID, with Zod validation |
| src/routes/api/v1/index.ts | Mount /languages subrouter under /api/v1 |
| src/routes/api/index.ts | Switch from a root /api GET to versioned routing (/v1) |
| src/models/Language.ts | Zod schema using splitCommaSeparatedString transforms |
| src/index.ts | Add global rate limiting middleware |
| src/db/knexfile.ts | Knex configuration with environment warnings |
| src/db/index.ts | Initialize Knex client based on NODE_ENV |
| openshift/dev/deployment.yaml | Deployment manifest with environment variables for database |
Files not reviewed (1)
- graphemes-api/package.json: Language not supported
Comments suppressed due to low confidence (2)
graphemes-api/src/routes/api/index.ts:5
- The root GET
/apiendpoint was removed, which may break clients expecting a response at/api. Consider reintroducing a default route or redirect to/api/v1to maintain backward compatibility.
const apiRouter = Router();
graphemes-api/src/models/Language.ts:10
- Using
z.string().transform(...)assumes the database fields are always strings. If any field can benullorundefined, this will throw at runtime—consider usingz.string().nullable()or a preprocess to handle missing values before transforming.
.transform(splitCommaSeparatedString)
| # This is a literal value because `crunchy-postgres` | ||
| # is the default database name in the PostgresCluster. | ||
| # This database name does not appear in the Secret. | ||
| value: grapheme_v2 |
There was a problem hiding this comment.
[nitpick] Hardcoding the database name in the manifest can lead to drift and exposes configuration details. Consider sourcing DB_NAME from a secret or ConfigMap to centralize environment configuration.
No description provided.