From c515c21f9ef4813b64aee7787c850a57e1dc16a4 Mon Sep 17 00:00:00 2001 From: agentdmai Date: Wed, 22 Apr 2026 09:40:43 -0400 Subject: [PATCH] [agent: eng-bot] add product routes module with GET /products and GET /products/:id stubs Mounts Express Router at /products in app.ts. Returns stub product data with id, name, price_cents, description, stock_qty. 404 JSON on unknown id. TypeScript strict, no any, no DB. Co-Authored-By: apilsinillc-eng-bot Agent-Session: 2026-04-22T13:39:49Z --- agents/eng-bot/src/app.ts | 20 ++++++++++++ agents/eng-bot/src/routes/products.ts | 44 +++++++++++++++++++++++++++ agents/eng-bot/src/server.ts | 8 +++++ 3 files changed, 72 insertions(+) create mode 100644 agents/eng-bot/src/app.ts create mode 100644 agents/eng-bot/src/routes/products.ts create mode 100644 agents/eng-bot/src/server.ts diff --git a/agents/eng-bot/src/app.ts b/agents/eng-bot/src/app.ts new file mode 100644 index 0000000..49ca1a4 --- /dev/null +++ b/agents/eng-bot/src/app.ts @@ -0,0 +1,20 @@ +import express, { Request, Response, NextFunction } from "express"; +import productsRouter from "./routes/products"; + +export function createApp(): express.Application { + const app = express(); + + app.use(express.json()); + + app.get("/health", (_req: Request, res: Response) => { + res.json({ status: "ok" }); + }); + + app.use("/products", productsRouter); + + app.use((_req: Request, res: Response, _next: NextFunction) => { + res.status(404).json({ error: "Not found" }); + }); + + return app; +} diff --git a/agents/eng-bot/src/routes/products.ts b/agents/eng-bot/src/routes/products.ts new file mode 100644 index 0000000..88730a6 --- /dev/null +++ b/agents/eng-bot/src/routes/products.ts @@ -0,0 +1,44 @@ +import { Router, Request, Response } from "express"; + +const router = Router(); + +interface Product { + id: number; + name: string; + price_cents: number; + description: string; + stock_qty: number; +} + +const STUB_PRODUCTS: Product[] = [ + { + id: 1, + name: "Classic T-Shirt", + price_cents: 2999, + description: "A comfortable everyday t-shirt.", + stock_qty: 100, + }, + { + id: 2, + name: "Canvas Tote Bag", + price_cents: 1499, + description: "Durable canvas bag for daily use.", + stock_qty: 50, + }, +]; + +router.get("/", (_req: Request, res: Response) => { + res.json(STUB_PRODUCTS); +}); + +router.get("/:id", (req: Request, res: Response) => { + const id = parseInt(req.params.id, 10); + const product = STUB_PRODUCTS.find((p) => p.id === id); + if (!product) { + res.status(404).json({ error: "not found" }); + return; + } + res.json(product); +}); + +export default router; diff --git a/agents/eng-bot/src/server.ts b/agents/eng-bot/src/server.ts new file mode 100644 index 0000000..b5cc795 --- /dev/null +++ b/agents/eng-bot/src/server.ts @@ -0,0 +1,8 @@ +import { createApp } from "./app"; + +const port = parseInt(process.env.PORT ?? "3000", 10); +const app = createApp(); + +app.listen(port, () => { + console.log(`Server listening on http://localhost:${port}`); +});