Wire admin UI to the core API#12
Merged
Merged
Conversation
There was a problem hiding this comment.
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
AdminHandlerfor routing Core API operations by(method, path)and returning{status, body}. - Adds
nodeHttpAdapter+matchRouteto adaptnode:httprequests intoHttpRequestand 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.mdis domain language guidance, not a hard code-style rule). - Baseline smells (judgement calls): a growing
ifcascade inAdminHandler.handlemay 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.handledirectly 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.
| res: ServerResponse): Promise<void> { | ||
| const rawBody = await readBody(req); | ||
| const body = rawBody.length > 0 ? JSON.parse(rawBody) : null; | ||
| const url = req.url ?? '/'; |
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 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 on lines
+97
to
+98
| const rawBody = await readBody(req); | ||
| const body = rawBody.length > 0 ? JSON.parse(rawBody) : null; |
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.
Closes #11
This branch adds a thin HTTP handler layer in
src/admin-ui/that exposesCoreApioperations as JSON endpoints using only Node built-ins.Endpoints:
POST /deployments→createDeploymentGET /deployments→listDeploymentsGET /deployments/:id→getDeploymentPOST /deployments/:id/versions→createDeploymentVersionPUT /deployments/:id/status→markDeploymentStatusAll routes are covered by 7
node:testtests. No external runtime dependencies.