Skip to content

Commit 419fdc5

Browse files
fixed paths
1 parent 85d53d4 commit 419fdc5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

apps/items-service/src/html.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function getSwaggerHtml(appPrefix: string): string {
2323
</html>`;
2424
}
2525

26-
export function getRootPageHtml(apiPrefix: string): string {
26+
export function getRootPageHtml(appPrefix: string, apiPrefix: string): string {
2727
return `<!DOCTYPE html>
2828
<html lang="en">
2929
<head>
@@ -46,11 +46,11 @@ export function getRootPageHtml(apiPrefix: string): string {
4646
4747
<p>A simple REST API service for managing items, built with Bun and PostgreSQL.</p>
4848
49-
<p><a href="/docs" target="_blank">Swagger Docs</a></p>
49+
<p><a href="${appPrefix}/docs" target="_blank">Swagger Docs</a></p>
5050
5151
<p><strong>API Endpoints:</strong></p>
52-
<p><a href="${apiPrefix}/health" target="_blank">${apiPrefix}/health</a> - Service and database health check</p>
53-
<p><a href="${apiPrefix}/items" target="_blank">${apiPrefix}/items</a> - List all items</p>
52+
<p><a href="${appPrefix}/${apiPrefix}/health" target="_blank">${apiPrefix}/health</a> - Service and database health check</p>
53+
<p><a href="${appPrefix}/${apiPrefix}/items" target="_blank">${apiPrefix}/items</a> - List all items</p>
5454
</article>
5555
</div>
5656
</body>

apps/items-service/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ async function handle(req: Request): Promise<Response> {
9595
try {
9696
const body = (await req.json()) as Partial<Item>;
9797
if (!body?.name || typeof body.name !== "string") return json({ error: "name required" }, { status: 400 });
98+
response = new Response(getRootPageHtml(APP_PREFIX, API_PREFIX), { headers: { "content-type": "text/html; charset=utf-8" } });
9899

99100
const [item] = await sql<Item[]>`
100101
INSERT INTO items (name)

0 commit comments

Comments
 (0)