{"id":2015,"date":"2026-11-17T06:26:15","date_gmt":"2026-11-16T22:26:15","guid":{"rendered":"https:\/\/www.zhukaifu.cn\/?p=2015"},"modified":"2026-11-17T06:26:15","modified_gmt":"2026-11-16T22:26:15","slug":"nestjs-nest-%c2%b7-%e4%b8%ad%e6%96%87%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.zhukaifu.cn\/?p=2015","title":{"rendered":"nestjs\/nest \u00b7 \u4e2d\u6587\u4ecb\u7ecd"},"content":{"rendered":"<!-- gh-sync:repo:nestjs\/nest -->\n\n<div id=\"gh-catalog\"><style>\/* \u4ec5\u4f5c\u7528\u4e8e\u540c\u6b65\u6587\u7ae0\uff1b\u4e0e Kai's Log \u6d45\u8272\u6587\u7ae0\u533a\u57df\u8854\u63a5\u3002 *\/\n#gh-catalog{color-scheme:light;--bg:#fff;--panel:#faf7fa;--line:#e7dee6;--text:#29252b;--muted:#69616b;--accent:#97447f;background:transparent;color:var(--text);font:inherit;line-height:1.8;min-height:0;width:100%;overflow-wrap:anywhere}\n#gh-catalog *,#gh-catalog *::before,#gh-catalog *::after{box-sizing:border-box}\n#gh-catalog main{width:100%;max-width:none;margin:0;padding:4px 0 20px}\n#gh-catalog h1,#gh-catalog h2,#gh-catalog h3{color:#29252b;font-family:inherit;font-weight:700;letter-spacing:normal;overflow-wrap:anywhere}\n#gh-catalog h1{font-size:clamp(24px,3.5vw,34px);line-height:1.4;margin:20px 0 12px}\n#gh-catalog h2{font-size:20px;line-height:1.55;margin:0 0 12px}\n#gh-catalog p{color:inherit;margin:12px 0}\n#gh-catalog a{color:var(--accent);text-decoration:none;box-shadow:none}\n#gh-catalog a:hover{text-decoration:underline;color:#753361}\n#gh-catalog .eyebrow{font-size:12px;letter-spacing:.14em;color:var(--accent);font-weight:700}\n#gh-catalog .meta,#gh-catalog .sort-note{color:var(--muted);font-size:13px}\n#gh-catalog article{background:#fff;border:1px solid var(--line);border-radius:12px;padding:24px;margin:18px 0;box-shadow:none;color:var(--text)}\n#gh-catalog article:hover{border-color:#cba8c3}\n#gh-catalog nav{display:flex;gap:12px;flex-wrap:wrap;align-items:center;margin:16px 0 0}\n#gh-catalog nav a{font-size:14px}\n#gh-catalog .rank{display:inline-flex;align-items:center;justify-content:center;min-width:38px;height:30px;border-radius:7px;background:#f3edf2;color:#715568;font-size:13px;margin-right:10px;font-variant-numeric:tabular-nums}\n#gh-catalog .top-rank{background:#f8efd9;color:#765516}\n#gh-catalog .search-panel{position:static;z-index:auto;padding:20px;background:#faf7fa;border:1px solid var(--line);border-radius:12px;margin:24px 0;box-shadow:none;backdrop-filter:none}\n#gh-catalog .search-panel label{color:var(--text);font-weight:600}\n#gh-catalog .search-row{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-top:10px}\n#gh-catalog .search-row input{flex:1 1 240px;width:auto}\n#gh-catalog input,#gh-catalog select,#gh-catalog button{border:1px solid #cdbfca;border-radius:8px;background:#fff;color:#29252b;font:inherit;line-height:1.5;max-width:100%;min-height:44px;box-shadow:none}\n#gh-catalog input{width:100%;min-width:0;padding:12px 14px}\n#gh-catalog input::placeholder{color:#756b76;opacity:1}\n#gh-catalog select{padding:11px 30px 11px 12px;width:auto}\n#gh-catalog button{padding:11px 16px;cursor:pointer;white-space:nowrap;background:#f2e6ef;color:#71345e}\n#gh-catalog button:hover{background:#ead5e5;border-color:#b98aab}\n#gh-catalog .sort-label{font-size:13px}\n#gh-catalog article nav a{display:inline-flex;align-items:center;justify-content:center;min-height:42px;padding:9px 15px;border-radius:8px;font-size:13px;font-weight:600;border:1px solid #ddccda;background:#faf5f9;color:#80366a;text-decoration:none;box-shadow:none}\n#gh-catalog article nav a:first-child{background:#97447f;border-color:#97447f;color:#fff}\n#gh-catalog article nav a:hover{background:#f0e0eb;border-color:#b784a8;color:#71345e;text-decoration:none}\n#gh-catalog article nav a:first-child:hover{background:#7a3566;border-color:#7a3566;color:#fff}\n#gh-catalog .collected{display:inline-flex;gap:6px;flex-wrap:wrap;margin:10px 0 0;padding:4px 10px;background:#f8f4f7;border:1px solid var(--line);border-radius:6px;font-size:12px;color:#69616b}\n#gh-catalog ul,#gh-catalog ol{padding-left:1.5em;margin:14px 0;color:var(--text)}\n#gh-catalog li{margin:10px 0;color:inherit}\n#gh-catalog .empty{border:1px dashed #cdbfca;border-radius:12px;text-align:center;padding:32px 18px;color:var(--muted);background:#faf7fa}\n#gh-catalog footer{margin-top:28px;border-top:1px solid var(--line);padding-top:16px;color:var(--muted);font-size:12px}\n#gh-catalog [hidden]{display:none!important}\n#gh-catalog a:focus-visible,#gh-catalog button:focus-visible,#gh-catalog input:focus-visible,#gh-catalog select:focus-visible{outline:3px solid #97447f;outline-offset:3px}\n@media(max-width:600px){#gh-catalog main{padding:0 0 12px}#gh-catalog article{padding:18px 14px}#gh-catalog h2{font-size:18px}#gh-catalog .search-panel{padding:16px 14px}#gh-catalog .search-row input{flex-basis:100%}#gh-catalog article nav a{flex:1;padding:9px 10px}#gh-catalog .rank{min-width:32px;margin-right:8px}}\n<\/style><main><nav><a href=\"https:\/\/www.zhukaifu.cn\/?p=575\">\u2190 \u70ed\u95e8\u4ed3\u5e93\u5217\u8868<\/a><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/nestjs\/nest\">\u6253\u5f00 GitHub \u4ed3\u5e93<\/a><\/nav><h1>nestjs\/nest<\/h1><p class=\"meta\">\u2605 77,109 \u00b7 Forks 8,726<\/p><article><h2>Nest \u662f\u7528 TypeScript \u5f00\u53d1 Node.js \u540e\u7aef\u7684\u6846\u67b6\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u4ece\u5c0f\u578b\u63a5\u53e3\u8d77\u6b65\uff0c\u9010\u6b65\u7ec4\u7ec7\u548c\u6269\u5c55\u6210\u5927\u578b\u5e94\u7528\u3002<\/h2><p>\u7528\u4e8e\u6784\u5efa Node.js \u540e\u7aef\u7684\u6e10\u8fdb\u5f0f TypeScript \u6846\u67b6\uff0c\u53ef\u4ece\u5355\u6587\u4ef6\u5c0f\u578b\u63a5\u53e3\u9010\u6b65\u6269\u5c55\u4e3a\u9ad8\u6548\u3001\u53ef\u6269\u5c55\u7684\u4f01\u4e1a\u7ea7\u7cfb\u7edf\u3002<\/p><ul><li>\u9002\u5408\u5f00\u53d1\u63a5\u53e3\u670d\u52a1\u7684\u4e2a\u4eba\u548c\u56e2\u961f\uff0c\u4e5f\u9002\u5408\u9700\u8981\u591a\u4eba\u534f\u4f5c\u3001\u6301\u7eed\u6269\u5c55\u7684\u4f01\u4e1a\u540e\u7aef\u9879\u76ee\u3002<\/li><li>\u901a\u8fc7\u6a21\u5757\u5212\u5206\u529f\u80fd\uff0c\u901a\u8fc7\u4f9d\u8d56\u6ce8\u5165\u81ea\u52a8\u63d0\u4f9b\u6240\u9700\u7ec4\u4ef6\uff0c\u5e76\u96c6\u4e2d\u5904\u7406\u6570\u636e\u6821\u9a8c\u3001\u8eab\u4efd\u9a8c\u8bc1\u548c\u9519\u8bef\uff0c\u65b9\u4fbf\u7ef4\u62a4\u3002<\/li><li>\u53ef\u8fd0\u884c\u5728 Express\u3001Fastify \u6216 Node.js \u81ea\u5e26\u7684 HTTP \u670d\u52a1\u4e4b\u4e0a\uff0c\u6309\u9700\u6dfb\u52a0\u6570\u636e\u5e93\u3001\u767b\u5f55\u3001\u6587\u4ef6\u5b58\u50a8\u3001\u4efb\u52a1\u961f\u5217\u548c AI \u7b49\u5b98\u65b9\u5305\u3002<\/li><li>\u5165\u95e8\u6d41\u7a0b\uff1a\u8fd0\u884c npx @nestjs\/cli new my-api \u521b\u5efa\u9879\u76ee \u2192 cd my-api \u8fdb\u5165\u76ee\u5f55 \u2192 npm run start:dev \u542f\u52a8\u5f00\u53d1\u670d\u52a1\u3002<\/li><li>\u521b\u5efa\u9879\u76ee\u65f6\u52a0 &#8211;minimal \u53ef\u4ece\u5355\u6587\u4ef6\u8d77\u6b65\uff1b\u82e5\u4f7f\u7528\u6309\u7c7b\u578b\u81ea\u52a8\u63d0\u4f9b\u7ec4\u4ef6\u6216 ValidationPipe \u6570\u636e\u6821\u9a8c\uff0c\u5e94\u6309 README \u6539\u7528 Nest CLI \u6216\u652f\u6301\u6240\u9700\u5143\u6570\u636e\u7684\u7f16\u8bd1\u65b9\u5f0f\u3002<\/li><\/ul><\/article><\/main><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u2190 \u70ed\u95e8\u4ed3\u5e93\u5217\u8868\u6253\u5f00 GitHub \u4ed3\u5e93 nestjs\/nest \u2605 77,10&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2015","post","type-post","status-publish","format-standard","hentry","category-thinking"],"_links":{"self":[{"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=\/wp\/v2\/posts\/2015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2015"}],"version-history":[{"count":2,"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=\/wp\/v2\/posts\/2015\/revisions"}],"predecessor-version":[{"id":2062,"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=\/wp\/v2\/posts\/2015\/revisions\/2062"}],"wp:attachment":[{"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhukaifu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}