[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6XCBZZK7HCWQP6N9AV60NWV":3,"skill-same:01M6XCBZZK7HCWQP6N9AV60NWV":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":13,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":48,"install":49,"resources":62},"01M6XCBZZK7HCWQP6N9AV60NWV","vanilla-ts-http-route-handler",null,"How to correctly add route handlers in a vanilla TypeScript project that uses http.createServer with a manual switch\u002Fcase router — without introducing Express Router or Next.js patterns.","UF-gzj\u002Fopenspace-claude-evolution","UF-gzj","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F272393507?v=4","01M6XBCZB755P01VVYGQWPYZY3","01M6XBCZFJA5AREA17WGETA3FW",0,"MIT","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvanilla-ts-http-route-handler\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"http","handler","vanilla ts http route handler","route","js","router","switch","patterns","how","next","project","express","how to","add","case","with","manual","route handlers","Next.js","typescript","2026-11-10 10:12:30",false,"---\nname: vanilla-ts-http-route-handler\ndescription: How to correctly add route handlers in a vanilla TypeScript project that uses http.createServer with a manual switch\u002Fcase router — without introducing Express Router or Next.js patterns.\n---\n\n# Adding Route Handlers to a Vanilla TypeScript HTTP Server\n\nUse this skill whenever you need to add a new route to a TypeScript project\nthat uses Node's built-in `http` module and a `switch\u002Fcase` pathname router\n**without Express or Next.js**.\n\n---\n\n## Step 0 — Confirm the routing style\n\nBefore writing any code, inspect `server\u002Findex.ts` (or whichever file starts\nthe HTTP server).  Look for:\n\n```ts\nhttp.createServer((req, res) => {\n  const { pathname } = new URL(req.url!, `http:\u002F\u002F${req.headers.host}`);\n  switch (pathname) {\n    case '\u002Fapi\u002Ffoo': ...\n  }\n});\n```\n\nIf you see this pattern, follow the steps below.  \n**Do NOT use `express.Router`, `next\u002Fserver`, or any framework-specific\nhandler signature** — even if other files in `server\u002Froutes\u002F` happen to\nuse those patterns.\n\n---\n\n## Step 1 — Create the route file\n\nCreate `server\u002Froutes\u002F\u003Cfeature>.ts`.  \nUse **only** the native Node types: `http.IncomingMessage` and\n`http.ServerResponse`.\n\n```ts\n\u002F\u002F server\u002Froutes\u002Fhealth.ts\nimport http from 'http';\n\nexport async function handleHealth(\n  req: http.IncomingMessage,\n  res: http.ServerResponse\n): Promise\u003Cvoid> {\n  \u002F\u002F Parse body for POST\u002FPUT if needed\n  const body = await readBody(req);   \u002F\u002F helper shown in Step 3\n\n  res.writeHead(200, { 'Content-Type': 'application\u002Fjson' });\n  res.end(JSON.stringify({ status: 'ok' }));\n}\n```\n\nRules for the route file:\n- Export the handler as a **named async function** (`handle\u003CFeature>`).\n- Accept exactly `(req: http.IncomingMessage, res: http.ServerResponse)`.\n- Return `Promise\u003Cvoid>`.\n- Do **not** call `next()` or return a `Response` object.\n- Handle errors internally and write an appropriate HTTP status + JSON body.\n\n---\n\n## Step 2 — Import the handler in `server\u002Findex.ts`\n\nAdd a named import at the top of the file alongside any existing imports:\n\n```ts\nimport { handleHealth } from '.\u002Froutes\u002Fhealth';\n```\n\n---\n\n## Step 3 — Add a `case` entry to the switch block\n\nLocate the existing `switch (pathname)` block and add a new `case`:\n\n```ts\nswitch (pathname) {\n  case '\u002Fapi\u002Fhealth':\n    await handleHealth(req, res);\n    break;\n\n  \u002F\u002F … existing cases …\n\n  default:\n    res.writeHead(404, { 'Content-Type': 'application\u002Fjson' });\n    res.end(JSON.stringify({ error: 'Not found' }));\n}\n```\n\n- Match the exact pathname string used by the client.\n- Always `break` (or `return`) after calling the handler.\n- Keep the `default` case last.\n\n---\n\n## Step 4 — Optional: shared body-reading helper\n\nIf multiple routes need to parse a JSON request body, add a small utility\nrather than duplicating the logic:\n\n```ts\n\u002F\u002F server\u002Futils\u002FreadBody.ts\nimport http from 'http';\n\nexport function readBody(req: http.IncomingMessage): Promise\u003Cunknown> {\n  return new Promise((resolve, reject) => {\n    let data = '';\n    req.on('data', (chunk) => (data += chunk));\n    req.on('end', () => {\n      try {\n        resolve(data ? JSON.parse(data) : {});\n      } catch {\n        reject(new Error('Invalid JSON'));\n      }\n    });\n    req.on('error', reject);\n  });\n}\n```\n\nImport and use it inside any route handler that needs it.\n\n---\n\n## Checklist\n\n- [ ] `server\u002Froutes\u002F\u003Cfeature>.ts` exists and exports a named async handler.\n- [ ] Handler signature is `(req: http.IncomingMessage, res: http.ServerResponse): Promise\u003Cvoid>`.\n- [ ] Handler always calls `res.writeHead(...)` and `res.end(...)` on every code path.\n- [ ] Handler is imported in `server\u002Findex.ts`.\n- [ ] A matching `case` entry is present in the `switch (pathname)` block.\n- [ ] No Express \u002F Next.js \u002F Koa types or patterns were introduced.\n\n---\n\n## Anti-patterns to avoid\n\n| ❌ Wrong | ✅ Correct |\n|---|---|\n| `import { Router } from 'express'` | `import http from 'http'` |\n| `export default function handler(req: NextApiRequest, ...)` | `export async function handleFoo(req: http.IncomingMessage, ...)` |\n| `router.get('\u002Ffoo', ...)` | `case '\u002Fapi\u002Ffoo': await handleFoo(req, res); break;` |\n| Returning a value from the handler | Calling `res.end(...)` and returning `void` |","# Adding Route Handlers to a Vanilla TypeScript HTTP Server\n\nUse this skill whenever you need to add a new route to a TypeScript project\nthat uses Node's built-in `http` module and a `switch\u002Fcase` pathname router\n**without Express or Next.js**.\n\n---\n\n## Step 0 — Confirm the routing style\n\nBefore writing any code, inspect `server\u002Findex.ts` (or whichever file starts\nthe HTTP server).  Look for:\n\n```ts\nhttp.createServer((req, res) => {\n  const { pathname } = new URL(req.url!, `http:\u002F\u002F${req.headers.host}`);\n  switch (pathname) {\n    case '\u002Fapi\u002Ffoo': ...\n  }\n});\n```\n\nIf you see this pattern, follow the steps below.  \n**Do NOT use `express.Router`, `next\u002Fserver`, or any framework-specific\nhandler signature** — even if other files in `server\u002Froutes\u002F` happen to\nuse those patterns.\n\n---\n\n## Step 1 — Create the route file\n\nCreate `server\u002Froutes\u002F\u003Cfeature>.ts`.  \nUse **only** the native Node types: `http.IncomingMessage` and\n`http.ServerResponse`.\n\n```ts\n\u002F\u002F server\u002Froutes\u002Fhealth.ts\nimport http from 'http';\n\nexport async function handleHealth(\n  req: http.IncomingMessage,\n  res: http.ServerResponse\n): Promise\u003Cvoid> {\n  \u002F\u002F Parse body for POST\u002FPUT if needed\n  const body = await readBody(req);   \u002F\u002F helper shown in Step 3\n\n  res.writeHead(200, { 'Content-Type': 'application\u002Fjson' });\n  res.end(JSON.stringify({ status: 'ok' }));\n}\n```\n\nRules for the route file:\n- Export the handler as a **named async function** (`handle\u003CFeature>`).\n- Accept exactly `(req: http.IncomingMessage, res: http.ServerResponse)`.\n- Return `Promise\u003Cvoid>`.\n- Do **not** call `next()` or return a `Response` object.\n- Handle errors internally and write an appropriate HTTP status + JSON body.\n\n---\n\n## Step 2 — Import the handler in `server\u002Findex.ts`\n\nAdd a named import at the top of the file alongside any existing imports:\n\n```ts\nimport { handleHealth } from '.\u002Froutes\u002Fhealth';\n```\n\n---\n\n## Step 3 — Add a `case` entry to the switch block\n\nLocate the existing `switch (pathname)` block and add a new `case`:\n\n```ts\nswitch (pathname) {\n  case '\u002Fapi\u002Fhealth':\n    await handleHealth(req, res);\n    break;\n\n  \u002F\u002F … existing cases …\n\n  default:\n    res.writeHead(404, { 'Content-Type': 'application\u002Fjson' });\n    res.end(JSON.stringify({ error: 'Not found' }));\n}\n```\n\n- Match the exact pathname string used by the client.\n- Always `break` (or `return`) after calling the handler.\n- Keep the `default` case last.\n\n---\n\n## Step 4 — Optional: shared body-reading helper\n\nIf multiple routes need to parse a JSON request body, add a small utility\nrather than duplicating the logic:\n\n```ts\n\u002F\u002F server\u002Futils\u002FreadBody.ts\nimport http from 'http';\n\nexport function readBody(req: http.IncomingMessage): Promise\u003Cunknown> {\n  return new Promise((resolve, reject) => {\n    let data = '';\n    req.on('data', (chunk) => (data += chunk));\n    req.on('end', () => {\n      try {\n        resolve(data ? JSON.parse(data) : {});\n      } catch {\n        reject(new Error('Invalid JSON'));\n      }\n    });\n    req.on('error', reject);\n  });\n}\n```\n\nImport and use it inside any route handler that needs it.\n\n---\n\n## Checklist\n\n- [ ] `server\u002Froutes\u002F\u003Cfeature>.ts` exists and exports a named async handler.\n- [ ] Handler signature is `(req: http.IncomingMessage, res: http.ServerResponse): Promise\u003Cvoid>`.\n- [ ] Handler always calls `res.writeHead(...)` and `res.end(...)` on every code path.\n- [ ] Handler is imported in `server\u002Findex.ts`.\n- [ ] A matching `case` entry is present in the `switch (pathname)` block.\n- [ ] No Express \u002F Next.js \u002F Koa types or patterns were introduced.\n\n---\n\n## Anti-patterns to avoid\n\n| ❌ Wrong | ✅ Correct |\n|---|---|\n| `import { Router } from 'express'` | `import http from 'http'` |\n| `export default function handler(req: NextApiRequest, ...)` | `export async function handleFoo(req: http.IncomingMessage, ...)` |\n| `router.get('\u002Ffoo', ...)` | `case '\u002Fapi\u002Ffoo': await handleFoo(req, res); break;` |\n| Returning a value from the handler | Calling `res.end(...)` and returning `void` |",{"name":5,"description":7},"main","0650921d63895de3997bc81f1ff1d0ac67032072","showcase\u002Fskills\u002Fvanilla-ts-http-route-handler","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution","https:\u002F\u002Fgithub.com\u002FUF-gzj","2026-04-16 09:31:03",{"source":8,"skillName":5,"commands":50,"prompt":60,"zipAvailable":61},[51,54,57],{"tool":52,"command":53},"npx","npx skills add UF-gzj\u002Fopenspace-claude-evolution --skill vanilla-ts-http-route-handler",{"tool":55,"command":56},"bunx","bunx skills add UF-gzj\u002Fopenspace-claude-evolution --skill vanilla-ts-http-route-handler",{"tool":58,"command":59},"pnpm","pnpm dlx skills add UF-gzj\u002Fopenspace-claude-evolution --skill vanilla-ts-http-route-handler","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvanilla-ts-http-route-handler\u002FSKILL.md",true,[63],{"path":64,"resourceType":65,"resourceTypeDesc":66,"sizeBytes":67,"sourceHtmlUrl":68},".skill_id","OTHER","其他",43,"https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvanilla-ts-http-route-handler\u002F.skill_id",[70,94,110,119,148,164],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":38},"01M6XCCXD3NCM2YKR3WNGBASPC","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[77,78,79,37,80,81,82,83,84,85,86,87,88,89,90,91,92,93],"check","write","write special chars ts check","filters","characters","Existing","type-checking","for","errors","script","output","type","files","only","template","file","python",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":38},"01M6XCCT7E3J922Q345PBGSHPN","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[101,102,78,92,103,93,104,105,106,107,108,91,109,33,81,84,86],"readback","write special chars readback","helper","post","via","scripts","cleanup","read","verification",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":38},"01M6XCCMQX1R8B6FECWB3P63T7","write-special-chars-heredoc","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) by using a Python heredoc script executed via shell.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-heredoc\u002FSKILL.md",[],[117,78,81,118,86,105,91,92,93,84],"write special chars heredoc","shell",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":130,"publishedAt":38},"01M6XCCG41M994JJEX6VN52PEP","worldmonitor-reference","Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[125],{"categoryNo":126,"categoryName":127,"taxonomyType":128,"taxonomyTypeDesc":129},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[131,132,133,134,135,37,136,137,138,139,140,84,141,142,25,143,144,145,146,147],"reference","worldmonitor","worldmonitor reference","architecture","dashboard","css","scheduler","layer","hierarchy","source","extracting","panel","edge functions","integrations","open","api","data",{"skillNo":149,"name":150,"nameZh":6,"description":151,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":152,"categories":153,"keywords":154,"publishedAt":38},"01M6XCCCHWNKG2W4VH9E6A10HF","virtual-list","Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvirtual-list\u002FSKILL.md",[],[155,156,157,158,84,159,33,160,161,162,163],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":165,"name":166,"nameZh":6,"description":167,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":168,"categories":169,"keywords":170,"publishedAt":38},"01M6XCC7X8PKMR2DEW91XGHYSV","verify-directory-structure","Diagnose and resolve file access issues by first verifying the directory structure.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure\u002FSKILL.md",[],[171,172,173,174,175,176,92,177,178,179],"directory","verify directory structure","structure","verify","access","first","issues","diagnose","file access"]