Skip to content

Wire admin UI to the core API#12

Merged
LahkLeKey merged 1 commit into
mainfrom
feature/admin-ui-http-handler
Jul 11, 2026
Merged

Wire admin UI to the core API#12
LahkLeKey merged 1 commit into
mainfrom
feature/admin-ui-http-handler

Conversation

@LahkLeKey

Copy link
Copy Markdown
Owner

Closes #11

This branch adds a thin HTTP handler layer in src/admin-ui/ that exposes CoreApi operations as JSON endpoints using only Node built-ins.

Endpoints:

  • POST /deploymentscreateDeployment
  • GET /deploymentslistDeployments
  • GET /deployments/:idgetDeployment
  • POST /deployments/:id/versionscreateDeploymentVersion
  • PUT /deployments/:id/statusmarkDeploymentStatus

All routes are covered by 7 node:test tests. No external runtime dependencies.

Copilot AI review requested due to automatic review settings July 11, 2026 07:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a thin src/admin-ui/ HTTP handler/adapter layer that maps admin UI JSON endpoints onto CoreApi operations using Node built-ins, plus node:test coverage.

Changes:

  • Introduces AdminHandler for routing Core API operations by (method, path) and returning {status, body}.
  • Adds nodeHttpAdapter + matchRoute to adapt node:http requests into HttpRequest and emit JSON responses.
  • Adds tests for handler-level route behavior using InMemoryDeploymentRepository.

Standards (axis)

  • No repo-documented coding standards violations found in the provided standards sources (notably CONTEXT.md is domain language guidance, not a hard code-style rule).
  • Baseline smells (judgement calls): a growing if cascade in AdminHandler.handle may become a “Repeated Switches” hotspot as routes expand, but this is consistent with the “thin handler” scope.

Spec (axis)

  • Matches the requested endpoints and injectability requirement (constructor accepts CoreApi) and uses no external runtime deps.
  • Gaps vs acceptance criteria/PR claim: current tests cover AdminHandler.handle directly but do not validate the full HTTP wiring (nodeHttpAdapter + URL parsing + JSON parsing), which is part of “exposes operations as JSON endpoints”.
  • Behavioral correctness gaps: invalid JSON and “unknown deployment id” for version/status routes currently throw/bubble instead of returning JSON error responses.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/admin-ui/handler.ts Adds routing + Node HTTP adapter to expose CoreApi as JSON endpoints.
src/admin-ui/handler.test.ts Adds handler-level tests using node:test and InMemoryDeploymentRepository.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/admin-ui/handler.ts
res: ServerResponse): Promise<void> {
const rawBody = await readBody(req);
const body = rawBody.length > 0 ? JSON.parse(rawBody) : null;
const url = req.url ?? '/';
Comment thread src/admin-ui/handler.ts
Comment on lines +45 to +52
if (method === 'POST' && path === '/deployments/:id/versions') {
const input = body as Omit<CreateDeploymentVersionInput, 'deploymentId'>;
const version = await this.core.createDeploymentVersion({
...input,
deploymentId: params['id'] as DeploymentId,
});
return {status: 201, body: version};
}
Comment thread src/admin-ui/handler.ts
Comment on lines +54 to +59
if (method === 'PUT' && path === '/deployments/:id/status') {
const {status: newStatus} = body as {status: DeploymentStatus};
const deployment =
await this.core.markDeploymentStatus(params['id'] as DeploymentId, newStatus);
return {status: 200, body: deployment};
}
Comment on lines +74 to +78
const res = await handler.handle({
method: 'GET',
path: '/deployments/:id',
params: {id: 'does-not-exist'},
body: null,
Comment thread src/admin-ui/handler.ts
Comment on lines +97 to +98
const rawBody = await readBody(req);
const body = rawBody.length > 0 ? JSON.parse(rawBody) : null;
@LahkLeKey
LahkLeKey merged commit 2fbb905 into main Jul 11, 2026
1 check passed
@LahkLeKey
LahkLeKey deleted the feature/admin-ui-http-handler branch July 11, 2026 11:23
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.

Wire admin UI to the core API

2 participants