Skip to content

Migrate locale endpoints from platform to nexus service#78

Merged
jeroenrinzema merged 4 commits intomainfrom
copilot/migrate-locale-endpoints
Dec 1, 2025
Merged

Migrate locale endpoints from platform to nexus service#78
jeroenrinzema merged 4 commits intomainfrom
copilot/migrate-locale-endpoints

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 30, 2025

Migrates the four project locale CRUD endpoints from the legacy platform service (TypeScript) to the nexus service (Go).

Implementation

OpenAPI Specification (oapi/resources.yml)

  • Added locale endpoints under /api/admin/projects/{projectID}/locales
  • Locale schema with id, project_id, key, label, timestamps
  • CreateLocale schema with key and label fields

Store Layer (internal/store/locales.go)

  • CRUD operations with multi-tenant isolation via project_id
  • List with pagination using COUNT(*) OVER ()
  • Get supports dual-lookup (UUID or key) with optimized query path selection
  • Hard delete on removal (no deleted_at column in schema)

Controller Layer (internal/http/controllers/v1/locales.go)

  • Project existence validation before all operations
  • HTTP 201 for create, 204 for delete, 404 for not found
  • Dual-lookup GET: accepts both UUID (/locales/{uuid}) and key (/locales/en)
  • DELETE accepts UUID only for safety

Tests (internal/http/controllers/v1/locales_test.go)

  • Full CRUD coverage with testcontainers
  • Pagination edge cases
  • Error scenarios (project not found, locale not found)
  • Dual-lookup validation

Query Optimization

// Avoids type conversion overhead by branching on UUID parse
id, err := uuid.Parse(localeID)
if err == nil {
    query = "WHERE project_id = $1 AND id = $2"  // Direct UUID comparison
} else {
    query = "WHERE project_id = $1 AND key = $2"  // String key lookup
}

This prevents id::text conversion on every row during key-based lookups.

Original prompt

This section details on the original issue you should resolve

<issue_title>Migrate locale endpoints to nexus service</issue_title>
<issue_description>The project locale endpoints in /services/platform/src/projects/ProjectLocaleController.ts have to be migrated to the nexus service. Please follow the style and architecture of the nexus project and include unit tests using test containers for the newly created controller and store if needed.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Migrate locale endpoints to nexus service Migrate locale endpoints from platform to nexus service Nov 30, 2025
Copilot AI requested a review from jeroenrinzema November 30, 2025 20:14
@jeroenrinzema jeroenrinzema requested review from Copilot and removed request for jeroenrinzema November 30, 2025 20:25
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 migrates four locale CRUD endpoints from the legacy TypeScript platform service to the Go-based nexus service. The migration follows nexus project conventions with OpenAPI-first design, separated store/controller layers, hard delete behavior, and comprehensive test coverage including testcontainers.

Key changes:

  • OpenAPI schema definitions for Locale and CreateLocale with four endpoints (GET list, POST create, GET by ID, DELETE)
  • Store layer with dual-lookup support (UUID or key) and query optimization
  • Controller layer with project existence validation and proper HTTP status codes

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
services/nexus/oapi/resources.yml Added locale endpoints and schemas to OpenAPI specification
services/nexus/oapi/resources_gen.go Generated Go types and client code from OpenAPI spec
services/nexus/internal/store/locales.go Implemented locale CRUD operations with dual-lookup GetLocale
services/nexus/internal/store/store.go Registered LocalesStore in store aggregator
services/nexus/internal/http/controllers/v1/locales.go Created locale controller with project validation and error handling
services/nexus/internal/http/controllers/v1/locales_test.go Added comprehensive tests for all locale operations
services/nexus/internal/http/controllers/v1/controller.go Registered LocalesController in main controller

@jeroenrinzema jeroenrinzema marked this pull request as ready for review November 30, 2025 20:30
Base automatically changed from refactor/users to main December 1, 2025 09:50
Copilot AI and others added 4 commits December 1, 2025 11:04
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
@jeroenrinzema jeroenrinzema force-pushed the copilot/migrate-locale-endpoints branch from f6b710e to 999a385 Compare December 1, 2025 10:07
@jeroenrinzema jeroenrinzema merged commit 357c2c9 into main Dec 1, 2025
3 checks passed
@jeroenrinzema jeroenrinzema deleted the copilot/migrate-locale-endpoints branch December 1, 2025 10:08
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.

Migrate locale endpoints to nexus service

3 participants