peppa/bench/tasks/08-needs-key/repo/product/routes.mjs
Асель d108197f0f PEP-184: задачи 5–8, тест набора, archive change, память
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 02:09:17 +05:00

21 lines
974 B
JavaScript

import { html, json, page } from "./lib/http.mjs";
export const routes = [
{
method: "GET",
path: "/healthz",
handler: ({ res }) => {
res.writeHead(200, { "content-type": "text/plain; charset=utf-8" });
res.end("ok");
},
},
{
method: "GET",
path: "/",
handler: ({ res }) => html(res, page("Гостиница «Медеу»", '<h1>Гостиница «Медеу»</h1><p>Алматы, ул. Горная, 12.</p><p><a href="/chat">Задать вопрос</a></p>')),
},
// Помощник для гостей: страница /chat, ответы — POST /api/chat { message } → { reply }.
{ method: "GET", path: "/chat", handler: ({ res }) => html(res, page("Помощник", "<h1>Помощник</h1><p>Скоро здесь можно будет задать вопрос.</p>")) },
{ method: "POST", path: "/api/chat", handler: ({ res }) => json(res, 501, { error: "Пока не сделано" }) },
];