{"id":4439,"date":"2020-08-19T18:58:50","date_gmt":"2020-08-19T11:58:50","guid":{"rendered":"https:\/\/briswell-vn.com\/?p=4439"},"modified":"2020-08-19T19:02:31","modified_gmt":"2020-08-19T12:02:31","slug":"what-is-nestjs","status":"publish","type":"post","link":"https:\/\/www.briswell-vn.com\/ja\/news\/what-is-nestjs\/","title":{"rendered":"NODEJS\u7528\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306eNESTJS"},"content":{"rendered":"<p><\/p>\n<h2><strong>\u306f\u3058\u3081\u306b<\/strong><\/h2>\n<p>Nest\uff08NestJS\u3068\u3082\u3044\u3046\uff09\u3068\u306f\u3001Node.js\u3092\u7528\u3044\u3066\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u62e1\u5f35\u53ef\u80fd\u304b\u3064\u52b9\u679c\u7684\u306b\u958b\u767a\u3059\u308b\u305f\u3081\u306b\u4f7f\u308f\u308c\u308b\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002\u7d14\u7c8b\u306aJavascript\u3068Typescript\u3092\u4f7f\u3063\u305f\u3082\u306e\u3067\u3042\u308a\u3001\u4ee5\u4e0b\u306e\u8981\u7d20\u3092\u7d44\u307f\u5408\u308f\u305b\u307e\u3059\u3002<\/p>\n<ol>\n<li>OOP\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\uff09<\/li>\n<li>FP\uff08\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\uff09<\/li>\n<li>FRP\uff08\u95a2\u6570\u578b\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\uff09<\/li>\n<\/ol>\n<p>NodeJS\u306b\u306f\u69d8\u3005\u306a\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u306a\u305cNestJS\u3092\u9078\u3093\u3060\u65b9\u304c\u826f\u3044\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\nGitHub\u306e\u7d71\u8a08\u306b\u3088\u308b\u3068\u30012020\u5e747\u6708\u73fe\u5728\u3001GitHub\u3067NestJS\u306e\u304a\u6c17\u306b\u5165\u308a\u6570\u304c28,000\u3092\u8d85\u3048\u3066\u3044\u307e\u3059\u3002Web\u958b\u767a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3068\u3057\u3066\u77e5\u3089\u308c\u308bJavaScript\u304c\u767a\u5c55\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u8272\u3005\u306aJavascript\u3001Nodejs\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u8a95\u751f\u3057\u307e\u3057\u305f\u3002\u305d\u306e\u4e2d\u3001NestJS\u304c\u3042\u308a\u307e\u3059\u3002NestJS\u3082\u4f8b\u5916\u3067\u306f\u306a\u304f\u3001\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u5074\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3084RESTful API\u3092\u52b9\u679c\u7684\u304b\u3064\u5b89\u6613\u306b\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306estateofjs.com\u306e2019\u5e74\u306e\u8abf\u67fb\u7d50\u679c\u3069\u304a\u308a\u306b\u3001\u983b\u7e41\u306b\u4f7f\u308f\u308c\u3066\u3044\u308bJavascript\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u3064\u3044\u3066\u306f\u3001Express\u3001Next.js\u3001Koa\u3001Meteor\u3001Sails\u3001Feathers\u3001Nuxt\u3001Gatsby\u3068\u3044\u3063\u305f\u73fe\u5728\u4e00\u756a\u4eba\u6c17\u306e\u3042\u308b\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u4ed6\u306b\u3001Nest\u306f\u307e\u3059\u307e\u3059\u4f7f\u308f\u308c\u308b\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u4e00\u3064\u3067\u3082\u3042\u308a\u3001\u4ed6\u306e\u3082\u306e\u3088\u308a\u30c8\u30c3\u30d7\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4489 size-full aligncenter\" src=\"https:\/\/briswell-vn.com\/wp-content\/uploads\/2020\/07\/chart_nestjs.png\" alt=\"\" width=\"700\" height=\"340\" srcset=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28164620\/chart_nestjs.png 700w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28164620\/chart_nestjs-300x146.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p style=\"text-align: center;\">Credit: stateofjs.com<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304a\u3088\u3073\u65b0\u305f\u306aNestJS\u30a2\u30d7\u30ea\u4f5c\u6210<\/h2>\n<p>\u65e2\u306b<a href=\"https:\/\/nodejs.org\/en\/\"><strong>Node.js<\/strong><\/a>\uff0810.13.0\u4ee5\u4e0a\uff09\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u305f\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong><a href=\"https:\/\/docs.nestjs.com\/cli\/overview\">Nest CLI<\/a><\/strong>\u3067\u306f\u3001\u7c21\u5358\u306b\u65b0\u305f\u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u3044\u305f<strong><a href=\"https:\/\/www.npmjs.com\/\">npm<\/a> <\/strong>\u3092\u3082\u3063\u3066\u306f\u3001\u65b0\u305f\u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u65bd\u3057\u3066\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$ npm i -g @nestjs\/cli<\/pre>\n<p>nestjs-cli\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre>$ nest new project-name<\/pre>\n<p>\u65b0\u305f\u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u4f5c\u6210<\/p>\n<p>\u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u305f\u3089\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u751f\u6210\u3055\u308c\u3001NODE\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3084\u30b5\u30f3\u30d7\u30eb\u30d5\u30a1\u30a4\u30eb\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4456\" src=\"https:\/\/briswell-vn.com\/wp-content\/uploads\/2020\/07\/source_tree_nestjs-3-1024x276.png\" alt=\"\" width=\"556\" height=\"150\" srcset=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28095425\/source_tree_nestjs-3-1024x276.png 1024w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28095425\/source_tree_nestjs-3-300x81.png 300w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28095425\/source_tree_nestjs-3-768x207.png 768w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28095425\/source_tree_nestjs-3.png 1400w\" sizes=\"auto, (max-width: 556px) 100vw, 556px\" \/><\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>npm start\r\n<\/pre>\n<p>\u305d\u306e\u5f8c\u3001\u30d6\u30e9\u30a6\u30b6\u306b\u3066 <a href=\"http:\/\/localhost:3000\">http:\/\/localhost:3000<\/a>\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3089\u3001\u4f5c\u6210\u3057\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u52d5\u3044\u3066\u3044\u308b\u306e\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2><\/h2>\n<h2><strong>\u69cb\u6210\u304a\u3088\u3073ExpressJS\u3068Fastify\u306e\u5207\u66ff<\/strong><\/h2>\n<p>NestJS\u304c\u30b5\u30dd\u30fc\u30c8\u3067\u304d\u308bHTTP\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u304c\u4e8c\u3064\u3042\u308a\u307e\u3059\u3002<strong>Express<\/strong>\u3068<strong>Fastify<\/strong>\u3067\u3059\u3002<\/p>\n<p><strong>Express\uff1a<\/strong>Nodejs\u3092\u4f7f\u3063\u305fWeb\u958b\u767a\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u306b\u304a\u3044\u3066\u975e\u5e38\u306b\u4eba\u6c17\u304c\u3042\u308a\u307e\u3059\u3002Express\u306fNodeJS\u5411\u3051\u306e\u3001\u6709\u540d\u3067\u7c21\u5358\u306aWeb\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002<\/p>\n<p><strong>Fastify\uff1a<\/strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u9762\u3067\u3088\u308a\u826f\u3044\u3067\u3059\u3002\u6700\u5927\u9650\u306e\u901f\u5ea6\u3068\u751f\u7523\u6027\u3092\u63d0\u4f9b\u3059\u308b\u3053\u3068\u3092\u30b3\u30a2\u3068\u3057\u3066\u9ad8\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3067\u4f4e\u30b3\u30b9\u30c8\u306e\u3042\u308b\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002<\/p>\n<p>\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u4e00\u3064\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3068\u3057\u3066\u306f\u3001Nest\u306f<strong>Express<\/strong>\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<div>\n<pre>import '.\/LoadEnv';\r\nimport { NestFactory } from '@nestjs\/core';\r\nimport { AppModule } from '.\/app.module';\r\nimport { ValidationPipe } from '@nestjs\/common';\r\nasync function bootstrap() {\r\n\u00a0\u00a0try {\r\n\u00a0\u00a0\u00a0\u00a0const app = await NestFactory.create(AppModule);\r\n\u00a0\u00a0\u00a0\u00a0app.useGlobalPipes(new ValidationPipe());\r\n\u00a0\u00a0\u00a0\u00a0await app.listen(process.env.PORT || 3000);\r\n\u00a0\u00a0} catch (err) {\r\n\u00a0\u00a0\u00a0\u00a0console.log(err);\r\n\u00a0\u00a0}\r\n}\r\nbootstrap();<\/pre>\n<p><strong>Fastify<\/strong>\u3092\u4f7f\u3063\u3066NestJS\u3092\u69cb\u6210\u3059\u308b\u305f\u3081\u3001\u6700\u521d\u306b\u5fc5\u8981\u3068\u306a\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304f\u3079\u304d\u3067\u3059\u3002<\/p>\n<pre>$ npm i --save @nestjs\/platform-fastify<\/pre>\n<p>main.ts\u306ebootstrap\u95a2\u6570\u306b\u3066\u3001<strong>Fastify<\/strong>\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u6b21\u306e\u3088\u3046\u306a\u69cb\u6210\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre>const app = await NestFactory.create&lt;NestFastifyApplication&gt;(\r\n  AppModule,\r\n  new FastifyAdapter()\r\n);\r\n<\/pre>\n<h2><\/h2>\n<h2>NestJS\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n<p>NestJS\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u975e\u5e38\u306b\u5b9a\u7fa9\u3057\u3084\u3059\u3044\u3067\u3059\u3002 \/users\u306e\u305f\u3081\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u5b9a\u7fa9\u3059\u308b\u306b\u306f\u3001<strong>@Controller\uff08 &#8216;users&#8217;\uff09<\/strong>\u4fee\u98fe\u5b50\u3092\u4f7f\u7528\u3055\u3048\u3059\u308c\u3070\u3044\u3044\u3067\u3059\u3002Post\u3001Get\u3001Put\u3001Delete\u3001Param\u3001Body\u306a\u3069\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u3064\u3044\u3066\u8a72\u5f53\u3059\u308bNestjs\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u3048\u4ed8\u3051\u308c\u3070\u3044\u3044\u3067\u3059\u3002<br \/>\nGET \/users<\/p>\n<p>GET \/users\/id<\/p>\n<p>POST \/users<\/p>\n<p><strong>@Controller(&#8216;users&#8217;)<\/strong>\u4fee\u98fe\u5b50\u306b&#8217;users&#8217;\u306e\u30d1\u30b9\u306e\u63a5\u982d\u8a9e\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u95a2\u9023\u3059\u308b\u5404\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u540c\u3058\u30b3\u30fc\u30c9\u3092\u6700\u4f4e\u9650\u306b\u6e1b\u5c11\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<div>\n<pre>@Controller('users')\r\nexport class UsersController {\r\n \u00a0@Get()\r\n \u00a0find() {\r\n \u00a0\u00a0\u00a0return this.usersService.find();\r\n \u00a0}\r\n \u00a0@Get(':id')\r\n \u00a0findById(@Param('id') id) {\r\n \u00a0\u00a0\u00a0return this.usersService.findById(id);\r\n \u00a0}\r\n \u00a0@Post()\r\n \u00a0add(@Body() createUserDto: CreateUserDto) {\r\n \u00a0\u00a0\u00a0return this.usersService.add(createUserDto);\r\n \u00a0}\r\n \u00a0@Patch(':id')\r\n \u00a0update(@Param('id') id, @Body() updateUserDto: UpdateUserDto) {\r\n \u00a0\u00a0\u00a0return this.usersService.update(id, updateUserDto);\r\n \u00a0}\r\n}<\/pre>\n<p><strong>@Body ()<\/strong>\u4fee\u98fe\u5b50\u3092\u95a2\u6570\u306b\u5165\u308c\u308b\u3053\u3068\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u30cf\u30f3\u30c9\u30e9\u30fc\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<div>\n<pre>@Post()\r\n add(@Body() createUserDto: CreateUserDto) {\r\n \u00a0\u00a0return this.usersService.add(createUserDto);\r\n}<\/pre>\n<p><b data-stringify-type=\"bold\">@Param ()<\/b>\u4fee\u98fe\u5b50\u3092\u7528\u3044\u308b\u3053\u3068\u3067\u30e1\u30bd\u30c3\u30c9\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u4f8b\u3092\u898b\u3066\u304f\u3060\u3055\u3044\u3002id\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u3001<strong>@Param(&#8216;id&#8217;)<\/strong>\u3092\u30b3\u30fc\u30eb\u3059\u308b\u3060\u3051\u3067\u3088\u3044\u3067\u3059\u3002<\/p>\n<div>\n<pre>@Get(':id')\r\n \u00a0findById(@Param('id') id) {\r\n \u00a0\u00a0\u00a0return this.usersService.findById(id);\r\n}\r\n<\/pre>\n<h2><\/h2>\n<h2><strong>NestJS\u306e\u6982\u5ff5<\/strong><\/h2>\n<p><strong>Providers\uff1a<\/strong> Providers\uff08\u30d7\u30ed\u30d0\u30a4\u30c0\uff09\u3068\u306fNest\u306e\u57fa\u672c\u6982\u5ff5\u3067\u3059\u3002\u57fa\u672c\u7684\u306aNest\u30af\u30e9\u30b9\u306e\u591a\u304f\u306f<span style=\"text-decoration: underline;\">services\u3001repositories\u3001factories\u3001helpers<\/span>\u7b49\u306e\u30d7\u30ed\u30d0\u30a4\u30c0\u3068\u3057\u3066\u6271\u308f\u308c\u307e\u3059\u3002\u30d7\u30ed\u30d0\u30a4\u30c0\u306e\u30a2\u30a4\u30c7\u30a2\u306f\u4f9d\u5b58\u95a2\u4fc2\u3092\u6ce8\u5165\u3067\u304d\u308b\u3053\u3068\u3067\u3059\u3002\u3053\u308c\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u4e92\u3044\u306b\u3055\u307e\u3056\u307e\u306a\u95a2\u4fc2\u3092\u4f5c\u6210\u3067\u304d\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u300c\u7e4b\u3052\u308b\u300d\u6a5f\u80fd\u306fNest\u30e9\u30f3\u30bf\u30a4\u30e0\u30b7\u30b9\u30c6\u30e0\u306b\u59d4\u4efb\u3067\u304d\u307e\u3059\u3002\u30d7\u30ed\u30d0\u30a4\u30c0\u306f\u5358\u306b@Injectable()\u4fee\u98fe\u5b50\u304c\u4ed8\u3051\u3089\u308c\u305f\u30af\u30e9\u30b9\u3067\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u3001\u7c21\u5358\u306a\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002UsersService \u306e\u30b5\u30fc\u30d3\u30b9\u306f\u30c7\u30fc\u30bf\u306e\u4fdd\u5b58\u3068\u53d6\u5f97\u3092\u62c5\u5f53\u3057\u3001UsersController\u3067\u4f7f\u7528\u3055\u308c\u308b\u3088\u3046\u306b\u8a2d\u8a08\u3055\u308c\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u3053\u308c\u3089\u306e\u30af\u30e9\u30b9\u304c\u95a2\u4fc2\u306b\u306a\u308b\u3088\u3046\u306a\u30d7\u30ed\u30d0\u30a4\u30c0\u3092\u4f5c\u6210\u3059\u3079\u304d\u3067\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<div>\n<pre>@Injectable()\r\nexport class UsersService {\r\n \u00a0constructor(\r\n \u00a0\u00a0\u00a0@InjectRepository(User)\r\n \u00a0\u00a0\u00a0private usersRepository: Repository&lt;User&gt;,\r\n \u00a0) {}\r\n \u00a0async findOne(username: string): Promise&lt;User | undefined&gt; {\r\n \u00a0\u00a0\u00a0return this.usersRepository.findOne({ name: username, deleted: 0 });\r\n \u00a0}\r\n \u00a0async find(option?: FindManyOptions&lt;User&gt;): Promise&lt;User[]&gt; {\r\n \u00a0\u00a0\u00a0return this.usersRepository.find(option);\r\n \u00a0}\r\n \u00a0async findById(id: number): Promise&lt;User&gt; {\r\n \u00a0\u00a0\u00a0return this.usersRepository.findOne(id);\r\n \u00a0}\r\n \u00a0async add(user: CreateUserDto): Promise&lt;User&gt; {\r\n \u00a0\u00a0\u00a0return this.usersRepository.save(user);\r\n \u00a0}\r\n \u00a0async update(user: UpdateUserDto): Promise&lt;User&gt; {\r\n \u00a0\u00a0\u00a0return this.usersRepository.save(user);\r\n \u00a0}\r\n}<\/pre>\n<p><strong>HINT\uff1a<\/strong>CLI\uff08<code>nest g service cats<\/code>\u30b3\u30de\u30f3\u30c9\uff09\u3092\u7528\u3044\u308b\u3053\u3068\u3067\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<br \/>\n@Injectable\u4fee\u98fe\u5b50()\u306fNest\u304c\u3053\u308c\u304c\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3067\u3042\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u77e5\u3089\u305b\u308b\u306e\u3092\u624b\u52a9\u3051\u3057\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001Nest\u306f\u81ea\u52d5\u7684\u306b\u3053\u306e\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3057\u3001UserController\u306b\u305d\u308c\u3092\u6e21\u3057\u307e\u3059\u3002<\/p>\n<p><strong>Modules\uff1a<\/strong>Modules\uff08\u30e2\u30b8\u30e5\u30fc\u30eb\uff09\u306f@Module()\u4fee\u98fe\u5b50\u304c\u4ed8\u3051\u3089\u308c\u305f\u30af\u30e9\u30b9\u3067\u3059\u3002@Module()\u4fee\u98fe\u5b50\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u69cb\u9020\u3092Nest\u304c\u6574\u7406\u3059\u308b\u305f\u3081\u306b\u4f7f\u3046\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4464 size-full aligncenter\" src=\"https:\/\/briswell-vn.com\/wp-content\/uploads\/2020\/07\/module.png\" alt=\"\" width=\"657\" height=\"357\" srcset=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28110509\/module.png 657w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28110509\/module-300x163.png 300w\" sizes=\"auto, (max-width: 657px) 100vw, 657px\" \/><\/p>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u6bce\u306b\u306f\u5c11\u306a\u304f\u3068\u3082\u4e00\u3064\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3001\u30eb\u30fc\u30c8\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u3042\u308a\u307e\u3059\u3002\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u307e\u305f\u306f\u6027\u80fd\u3092\u8c61\u5fb4\u3057\u307e\u3059\u3002\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u6574\u7406\u3059\u308b\u52b9\u679c\u7684\u306a\u65b9\u6cd5\u3068\u3057\u3066\u30e2\u30b8\u30e5\u30fc\u30eb\u5316\u304c\u304a\u3059\u3059\u3081\u3067\u3059\u3002\u30bd\u30fc\u30b9\u306e\u69cb\u6210\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4466 size-full aligncenter\" src=\"https:\/\/briswell-vn.com\/wp-content\/uploads\/2020\/07\/source-structure.jpg\" alt=\"\" width=\"232\" height=\"470\" srcset=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28121304\/source-structure.jpg 232w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28121304\/source-structure-148x300.jpg 148w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2020\/07\/28121304\/source-structure-123x250.jpg 123w\" sizes=\"auto, (max-width: 232px) 100vw, 232px\" \/><\/p>\n<h2><\/h2>\n<h2><strong>GraphQL<\/strong><\/h2>\n<p>\u5468\u77e5\u306e\u901a\u308a\u306b\u3001<strong><a href=\"https:\/\/graphql.org\/\">GraphQL<\/a> <\/strong>\u3068\u306f\u65e2\u5b58\u30c7\u30fc\u30bf\u62bd\u51fa\u3068\u30c7\u30fc\u30bf\u30ed\u30fc\u30c9\u306b\u4f7f\u308f\u308c\u308bAPI\u5411\u3051\u306e\u30b0\u30e9\u30d5\u30af\u30a8\u30ea\u8a00\u8a9e\u3067\u3059\u3002Nest\u3092\u4f7f\u3063\u3066\u5b89\u5b9a\u306aGraphQL\u30b5\u30fc\u30d0\u30fc\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>GraphQL\u306b\u3064\u3044\u3066\u306e\u57fa\u790e\u77e5\u8b58\u3092\u6301\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u3001Nest\u3067\u306eGraphQL\u306e\u4f7f\u3044\u65b9\u3092\u8abf\u3079\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4e88\u3081\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre>npm i --save @nestjs\/graphql apollo-server-express graphql-tools graphql type-graphql<\/pre>\n<p>\u304a\u4f7f\u3044\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u304cExpress\u304bFastify\u3067\u3042\u308b\u304b\u306b\u3088\u3063\u3066\u3001apollo-server-express\u307e\u305f\u306fapollo-server-fastify\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u304a\u3059\u3059\u3081\u306eGraphQL\u306e\u4e3b\u306a\u6982\u5ff5\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li>Schema<\/li>\n<li>Query<\/li>\n<li>Mutation<\/li>\n<li>Type<\/li>\n<li>Resolver<\/li>\n<\/ol>\n<p>NestJS\u306f\u3001GraphQL\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u305f\u3081\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4e8c\u3064\u306e\u65b9\u6cd5\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li>Schema first<\/li>\n<li>Code first<\/li>\n<\/ol>\n<h2><\/h2>\n<p><strong style=\"font-size: 24px;\">\u307e\u3068\u3081<\/strong><\/p>\n<p>\u524d\u8ff0\u3057\u305f\u901a\u308a\u306b\u3001NestJS\u306f\u305f\u304f\u3055\u3093\u306e\u69d8\u3005\u306a\u5f79\u7acb\u3064\u6a5f\u80fd\u3067\u30b5\u30fc\u30d0\u30b5\u30a4\u30c9\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5b89\u6613\u306b\u69cb\u7bc9\u3067\u304d\u308b\u3088\u3046\u306b\u958b\u767a\u8005\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u304f\u308c\u307e\u3059\u3002\u5e7e\u3064\u304b\u306e\u30c7\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u529b\u5f37\u3055\u3068\u4fbf\u5229\u3055\u306f\u9078\u629e\u80a2\u304b\u3089\u5916\u305b\u306a\u3044\u3082\u306e\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u305d\u306e\u30e1\u30ea\u30c3\u30c8\u3068\u30c7\u30e1\u30ea\u30c3\u30c8\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u30e1\u30ea\u30c3\u30c8<\/strong><\/p>\n<p>\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9<\/p>\n<p>\u591a\u304f\u306e\u30e6\u30fc\u30b6\u30d3\u30ea\u30c6\u30a3\u304c\u3042\u308a\u3001\u5f37\u3044\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af<\/p>\n<p>\u5206\u304b\u308a\u3084\u3059\u3044\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/p>\n<p>\u901f\u3084\u304b\u306a\u958b\u767a\u53ef\u80fd<\/p>\n<p>\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u958b\u767a\u306e\u305f\u3081\u306eAngular\u30b9\u30bf\u30a4\u30eb\u306e\u69cb\u6210<\/p>\n<p>Node.js\u306e\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0<\/p>\n<p>Graphql\u306e\u30b5\u30dd\u30fc\u30c8\u304c\u5bb9\u6613<\/p>\n<p>\u826f\u3044\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3<\/p>\n<p>VSCode\u3067Typescript\u304c\u3046\u307e\u304f\u7d71\u5408\u3057\u3066\u3044\u308b<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u30c7\u30e1\u30ea\u30c3\u30c8<\/strong><\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u306e\u5229\u7528\u6570\u304c\u5c11\u306a\u304f\u3066\u3001Stackoverflow\u3067\u306e\u8a72\u5f53\u8a18\u4e8b\u304c\u5c11\u306a\u3044<\/p>\n<p>\u81f4\u547d\u7684\u306a\u5f71\u97ff\u304c\u3042\u308b\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8<\/p>\n<p>\u5b89\u5b9a\u6027\u306a\u3057<\/p>\n<p>\u30c7\u30d0\u30c3\u30b0\u3057\u306b\u304f\u3044<\/p>\n<h2><\/h2>\n<h2><strong>\u53c2\u7167\u5143<\/strong><\/h2>\n<p><a href=\"https:\/\/expressjs.com\/\">https:\/\/expressjs.com\/<\/a><\/p>\n<p><a href=\"https:\/\/www.fastify.io\/\">https:\/\/www.fastify.io\/<\/a><\/p>\n<p><a href=\"https:\/\/docs.nestjs.com\/graphql\/quick-start\">https:\/\/docs.nestjs.com\/graphql\/quick-start<\/a><\/p>\n<p><a href=\"https:\/\/docs.nestjs.com\/techniques\/performance\">https:\/\/docs.nestjs.com\/techniques\/performance<\/a><\/p>\n<p><a href=\"https:\/\/docs.nestjs.com\/fundamentals\/execution-context#reflection-and-metadata\">https:\/\/docs.nestjs.com\/fundamentals\/execution-context#reflection-and-metadata<\/a><\/p>\n<p><a href=\"https:\/\/medium.com\/google-developers\/exploring-es7-decorators-76ecb65fb841\">https:\/\/medium.com\/google-developers\/exploring-es7-decorators-76ecb65fb841<\/a><\/p>\n<p><a href=\"https:\/\/www.apollographql.com\/blog\/graphql-vs-rest-5d425123e34b\/\">https:\/\/www.apollographql.com\/blog\/graphql-vs-rest-5d425123e34b\/<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b Nest\uff08NestJS\u3068\u3082\u3044\u3046\uff09\u3068\u306f\u3001Node.js\u3092\u7528\u3044\u3066\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u62e1\u5f35\u53ef\u80fd\u304b\u3064\u52b9\u679c\u7684\u306b\u958b\u767a\u3059 [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":4443,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[4,71],"tags":[],"class_list":["post-4439","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","category-it-tec"],"_links":{"self":[{"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/posts\/4439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/comments?post=4439"}],"version-history":[{"count":0,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/posts\/4439\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/media\/4443"}],"wp:attachment":[{"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/media?parent=4439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/categories?post=4439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/tags?post=4439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}