> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://cla-demo.postmansolutions.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://cla-demo.postmansolutions.com/_mcp/server.

# Registration Service Evaluation

This documents the evaluation of the Registration Service as part of the code review and assessment process.
[User Story 729005](https://dev.azure.com/CLADevOps/Development/_workitems/edit/729005): SPIKE: Evaluate the Registration Service

Suggested changes and potential enhancements have been identified for each category. The items have been marked with **Severity** to indicate importance.

---

## Endpoints Overview

All endpoints are documented in OpenAPI 3.0.3 format with Swagger UI at `/docs`.

#### **Client Application Endpoints**

| Method | Path                                        | Purpose                         | Status      | Documented |
| ------ | ------------------------------------------- | ------------------------------- | ----------- | ---------- |
| POST   | `/v1/clientApplication/`                    | Register new client application | Implemented | Yes        |
| GET    | `/v1/clientApplication/delivery-route/`     | Get all delivery routes         | Implemented | Yes        |
| GET    | `/v1/clientApplication?clientId={id}`       | Get apps by client ID           | Implemented | Yes        |
| GET    | `/v1/clientApplication/folder/{folderId}`   | Get app by folder ID            | Implemented | Yes        |
| GET    | `/v1/clientApplication/application/{appId}` | Get app by application ID       | Implemented | Yes        |
| PATCH  | `/v1/clientApplication/{id}`                | Update client application       | Implemented | Yes        |
| DELETE | `/v1/clientApplication/{id}`                | Delete client application       | Implemented | Yes        |

**Implementation Files:**

* Routes: `src/routes/v1/clientApplication.ts`
* Controller: `src/controllers/clientApplicationController.ts`
* Repository: `src/repositories/clientApplicationRepository.ts`
* Schemas: `src/routes/v1/schemas.ts`

#### **Client Endpoints**

| Method | Path                                         | Purpose              | Status      | Documented |
| ------ | -------------------------------------------- | -------------------- | ----------- | ---------- |
| POST   | `/v1/client/`                                | Register new client  | Implemented | Yes        |
| GET    | `/v1/client/{clientId}`                      | Get client by ID     | Implemented | Yes        |
| GET    | `/v1/client/clientApplication/{clientAppId}` | Get client by app ID | Implemented | Yes        |
| PATCH  | `/v1/client/{clientId}`                      | Update client        | Implemented | Yes        |
| DELETE | `/v1/client/{clientId}`                      | Delete client        | Implemented | Yes        |

**Implementation Files:**

* Routes: `src/routes/v1/client.ts`
* Controller: `src/controllers/clientController.ts`
* Repository: `src/repositories/clientRepository.ts`

#### **File Extension Management Endpoints**

| Method | Path                            | Purpose                    | Status      | Documented |
| ------ | ------------------------------- | -------------------------- | ----------- | ---------- |
| POST   | `/v1/allowedFileExtension/`     | Register allowed extension | Implemented | Yes        |
| GET    | `/v1/allowedFileExtension/`     | Get all allowed extensions | Implemented | Yes        |
| GET    | `/v1/allowedFileExtension/{id}` | Get extension by ID        | Implemented | Yes        |
| DELETE | `/v1/allowedFileExtension/{id}` | Delete extension           | Implemented | Yes        |

**Implementation Files:**

* Routes: `src/routes/v1/allowedFileExtension.ts`
* Controller: `src/controllers/allowedFileExtensionController.ts`
* Repository: `src/repositories/allowedFileExtensionRepository.ts`

#### **Client Application Extension Mapping Endpoints**

| Method | Path                                    | Purpose                           | Status      | Documented |
| ------ | --------------------------------------- | --------------------------------- | ----------- | ---------- |
| POST   | `/v1/clientApplication/{id}/extension/` | Add extensions to client app      | Implemented | Yes        |
| GET    | `/v1/clientApplication/{id}/extension/` | Get extensions for client app     | Implemented | Yes        |
| DELETE | `/v1/clientApplication/{id}/extension/` | Remove extensions from client app | Implemented | Yes        |

**Implementation Files:**

* Routes: `src/routes/v1/clientApplicationAllowedExtension.ts`
* Controller: `src/controllers/clientApplicationAllowedExtensionController.ts`
* Repository: `src/repositories/clientApplicationAllowedExtensionRepository.ts`

#### **Extractor Management Endpoints**

| Method | Path                                                 | Purpose                       | Status      | Documented |
| ------ | ---------------------------------------------------- | ----------------------------- | ----------- | ---------- |
| POST   | `/v1/clientApplication/{id}/extractor/`              | Add extractor to client app   | Implemented | Yes        |
| GET    | `/v1/clientApplication/{id}/extractor/`              | Get extractors for client app | Implemented | Yes        |
| DELETE | `/v1/clientApplication/{id}/extractor/{extractorId}` | Remove extractor              | Implemented | Yes        |

**Implementation Files:**

* Routes: `src/routes/v1/clientApplicationExtractor.ts`
* Controller: `src/controllers/clientApplicationExtractorController.ts`
* Repository: `src/repositories/clientApplicationExtractorRepository.ts`

#### **Utility Endpoints**

| Method | Path            | Purpose                  | Status      | Documented                       |
| ------ | --------------- | ------------------------ | ----------- | -------------------------------- |
| GET    | `/docs`         | Swagger UI documentation | Implemented | Yes                              |
| GET    | `/openapi.yaml` | OpenAPI YAML spec        | Implemented | Yes                              |
| GET    | `/health`       | Health check endpoint    | Implemented | Yes, it is part of the framework |

---

## Recommended Changes

| No. | Severity | Description                                                                                                    |
| --- | -------- | -------------------------------------------------------------------------------------------------------------- |
| 1   | Medium   | Add integration test coverage for Client endpoints to match the coverage level of Client Application endpoints |

---

# Code

Potential optimizations and improvements have been included in the table below.

## Recommended Changes

| No. | Severity | Description                                                                                                                                                                                                                                | References                                                                                   |                                                                                                                                                                                                                                            |                                                                                              |
| --- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
| 1   | Low      | Validation logic is split between JSON schemas and `preValidation` hooks. Move simple validation (whitespace, min/max) into schemas.                                                                                                       | `src/routes/v1/clientApplication.ts`, `src/routes/v1/schemas.ts`                             |                                                                                                                                                                                                                                            |                                                                                              |
| 2   | Low      | Missing integration tests for Client endpoints. Unit tests exist but integration tests are not yet implemented for POST, GET, PATCH, and DELETE operations on `/v1/client/` endpoints.                                                     | `test/service/`                                                                              |                                                                                                                                                                                                                                            |                                                                                              |
| 3   | Low      | `@azure/storage-blob` is in `package.json` but not used anywhere. Remove if not needed.                                                                                                                                                    | `package.json`                                                                               |                                                                                                                                                                                                                                            |                                                                                              |
| 4   | Medium   | `src/routes/v1/schemas.ts` consider segregating the schema for each route                                                                                                                                                                  | `schemas.ts`                                                                                 |                                                                                                                                                                                                                                            |                                                                                              |
| 5   | Medium   | Consider another layer for `services` this should handle business rules/logic                                                                                                                                                              | `src/services/registrationService.ts`                                                        |                                                                                                                                                                                                                                            |                                                                                              |
| 7   | Medium   | Configuration keys are scattered across code using string-based `app.lookup()` calls. While ENV\_KEYS constant exists, it's not enforced. Consider creating a config validation function that verifies all required keys exist at startup. | `src/index.ts`, `src/services/topicService.ts`, `src/internal/createSqlConnectionOptions.ts` | Configuration keys are scattered across code using string-based `app.lookup()` calls. While ENV\_KEYS constant exists, it's not enforced. Consider creating a config validation function that verifies all required keys exist at startup. | `src/index.ts`, `src/services/topicService.ts`, `src/internal/createSqlConnectionOptions.ts` |

---

# Documentation

Below are the suggested changes to the documentation.

## Recommended Changes

| No. | Document      | Severity | Description                                                                                                                                                         | References                   |
| --- | ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| 1   | Code Comments | Low      | Document why trailing URL space handling exists or investigate if client-side bug can be fixed. Probably this is because of the fastify case sensitive in endpoints | `src/index.ts` lines 140-153 |