{"id":5893,"date":"2020-02-20T02:48:08","date_gmt":"2020-02-19T17:48:08","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=5893"},"modified":"2020-03-12T07:49:06","modified_gmt":"2020-03-11T22:49:06","slug":"express%e3%81%a7%e3%83%a6%e3%83%bc%e3%82%b6%e3%83%bc%e7%99%bb%e9%8c%b2%e6%a9%9f%e8%83%bd%ef%bc%88%e3%83%a1%e3%83%bc%e3%83%ab%e8%aa%8d%e8%a8%bc%e3%81%a4%e3%81%8d%e3%80%81%e3%83%80%e3%82%a6%e3%83%b3","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=5893","title":{"rendered":"Express\u3067\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6a5f\u80fd\uff08\u30e1\u30fc\u30eb\u8a8d\u8a3c\u3064\u304d\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\uff09"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u4ee5\u524d\u3053\u306e\u30d6\u30ed\u30b0\u3067\u516c\u958b\u3057\u305f\u300c<a href=\"https:\/\/blog.capilano-fw.com\/?p=5655\">\u30b3\u30d4\u30da\u3067OK\uff01Express\u306b\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u3064\u304f\u308b<\/a>\u300d\u3068\u3044\u3046\u8a18\u4e8b\u3067\u306f\u3001\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u4eca\u56de\u306f\u305d\u306e\u7d9a\u304d\u3068\u3057\u3066\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3059\u308b\u6a5f\u80fd<\/strong><\/p>\n<p>\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u8ab0\u3067\u3082\u767b\u9332\u3067\u304d\u308b\u30aa\u30fc\u30d7\u30f3\u306a\u30b5\u30a4\u30c8\u3092\u516c\u958b\u3059\u308b\u306b\u306f\u3001\u5fc5\u9808\u306e\u6a5f\u80fd\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u305d\u3053\u3067\uff01<\/p>\n<p>\u4eca\u56de\u306f\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3067\u304d\u308b\u3088\u3046\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<ol>\n<li>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\uff06\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u9001\u4fe1<\/li>\n<li>\u4eee\u767b\u9332\u5b8c\u4e86\uff08\u672c\u767b\u9332\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\uff09<\/li>\n<li>\u30e1\u30fc\u30eb\u306b\u66f8\u304b\u308c\u305fURL\u3092\u30af\u30ea\u30c3\u30af<\/li>\n<li>\u672c\u767b\u9332\u304c\u5b8c\u4e86<\/li>\n<\/ol>\n<p>\u305c\u3072\u307f\u306a\u3055\u3093\u306e\u304a\u5f79\u306b\u7acb\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728<br \/>\n\uff08\u6700\u5f8c\u306b\u4eca\u56de\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\uff01\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2173 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png\" alt=\"\" width=\"300\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24-281x300.png 281w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Node 8\u3001Express 4.1<\/p>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p>\u4eca\u56de\u5b9f\u88c5\u3059\u308b\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6a5f\u80fd\u306b\u306f\u3001\u4ee5\u4e0b\uff14\u3064\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u305d\u308c\u305e\u308c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306e\u30b3\u30de\u30f3\u30c9\u3068\u53c2\u8003\u8a18\u4e8b\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u5148\u306b\u6e96\u5099\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306f<code>mustache<\/code>\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u304c\u3001<code>ejs<\/code>\u3084<code>pug<\/code>\u3067\u3082\u5b9f\u884c\u53ef\u80fd\u3067\u3059\u3002\u8a73\u3057\u304f\u306f\u300c<a href=\"https:\/\/blog.capilano-fw.com\/?p=5485#i-6\" target=\"_blank\" rel=\"noopener noreferrer\">\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3<\/a>\u300d\u3092\u4f7f\u3046\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002\uff08\u305f\u3060\u3057\u3001\u4ed6\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3092\u4f7f\u3046\u5834\u5408\u306f\u30d3\u30e5\u30fc\u306e\u62e1\u5f35\u5b50\u304c<code>.mst<\/code>\u3067\u306f\u306a\u304f\u306a\u308a\u307e\u3059\u306e\u3067\u3054\u6ce8\u610f\u304f\u3060\u3055\u3044\uff09<\/p>\n<h2>Sequelize<\/h2>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u64cd\u4f5c\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3002<\/p>\n<pre><strong>npm i --save sequelize<\/strong><\/pre>\n<pre><strong>sudo npm i -g sequelize-cli<\/strong><\/pre>\n<p>\u3010\u53c2\u8003\u8a18\u4e8b\u3011<br \/>\n<a href=\"https:\/\/blog.capilano-fw.com\/?p=5546\" target=\"_blank\" rel=\"noopener noreferrer\">Node.js\u306bDB\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3001Seed\u3001\u30e2\u30c7\u30eb\u3092\u7528\u610f\u3059\u308b\u300cSequelize\u300d<\/a><\/p>\n<h2>express-validator<\/h2>\n<p>\u5165\u529b\u3055\u308c\u305f\u5185\u5bb9\u3092\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3002<\/p>\n<pre><strong>npm i --save express-validator<\/strong><\/pre>\n<p>\u3010\u53c2\u8003\u8a18\u4e8b\u3011<br \/>\n<a href=\"https:\/\/blog.capilano-fw.com\/?p=5619\" target=\"_blank\" rel=\"noopener noreferrer\">Express\u3067\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3059\u308b\u300cexpress-validator\u300d<\/a><\/p>\n<h2>nodemailer<\/h2>\n<p>\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<pre><strong>npm i --save nodemailer<\/strong><\/pre>\n<p>\u3010\u53c2\u8003\u8a18\u4e8b\u3011<br \/>\n<a href=\"https:\/\/blog.capilano-fw.com\/?p=5673\" target=\"_blank\" rel=\"noopener noreferrer\">\u7c21\u5358\uff01Express\u3067\u30e1\u30fc\u30eb\u9001\u4fe1\u3059\u308b\u65b9\u6cd5<\/a><\/p>\n<h2>bcrypt<\/h2>\n<p><code>bcrypt<\/code>\u30cf\u30c3\u30b7\u30e5\u5024\u3092\u8a08\u7b97\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\uff08\u7c21\u5358\u306b\u8a00\u3046\u3068\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u6697\u53f7\u5316\u3067\u3059\uff09<\/p>\n<pre><strong>npm i --save bcrypt<\/strong><\/pre>\n<p>\u3010\u53c2\u8003\u8a18\u4e8b\u3011<br \/>\n<a href=\"https:\/\/blog.capilano-fw.com\/?p=5655\" target=\"_blank\" rel=\"noopener noreferrer\">Express\u306b\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u3064\u304f\u308b<\/a><\/p>\n<h1>\u6e96\u5099\u3092\u3059\u308b\uff08Users\u30c6\u30fc\u30d6\u30eb\uff09<\/h1>\n<p>\u3067\u306f\u3001\u306f\u3058\u3081\u306b\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u7ba1\u7406\u3059\u308b<code>Users<\/code>\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e<code>sequelize-cli<\/code>\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001<code>User<\/code>\u30e2\u30c7\u30eb\u3068<code>Users<\/code>\u30c6\u30fc\u30d6\u30eb\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>npx sequelize-cli model:generate --name User --attributes name:string,email:string,emailVerifiedAt:date,password:string<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\uff12\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li>\/models\/user.js<\/li>\n<li>\/migrations\/**************-create-user.js<\/li>\n<\/ul>\n<p>\u306a\u304a\u3001<code>emailVerifiedAt<\/code>\u304c\u4eca\u56de\u306e\u30e1\u30fc\u30eb\u8a8d\u8a3c\uff08\u672c\u767b\u9332\u30e1\u30fc\u30eb\uff09\u306b\u95a2\u9023\u3059\u308b\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u3059\u3002<\/p>\n<p>\u3053\u3053\u306f\u521d\u671f\u72b6\u614b\u3067\u306f<code>NULL<\/code>\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u30e1\u30fc\u30eb\u8a8d\u8a3c\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u65e5\u6642\u3092\u767b\u9332\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u3064\u307e\u308a\u672c\u767b\u9332\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u5224\u5225\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff09<\/p>\n<p>\u307e\u305f\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306f\u91cd\u8907\u3055\u305b\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u306e\u3067\u3001\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306b<code>unique<\/code>\u3092\u8ffd\u52a0\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>email: {\n    type: Sequelize.STRING,\n    <strong>unique: true<\/strong>\n},<\/pre>\n<p>\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>npx sequelize-cli db:migrate<\/strong><\/pre>\n<p>\u5b9f\u969b\u306eDB\u30c6\u30fc\u30d6\u30eb\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5895\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_1.png\" alt=\"\" width=\"351\" height=\"295\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_1.png 351w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_1-300x252.png 300w\" sizes=\"auto, (max-width: 351px) 100vw, 351px\" \/><\/p>\n<h1>\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u30d5\u30a9\u30fc\u30e0\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3059\u308b\u30d5\u30a9\u30fc\u30e0\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u300c<strong>app.js<\/strong>\u300d\u306b\u4ee5\u4e0b\u306e\u30eb\u30fc\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>app.get('\/register', (req, res) =&gt; {<\/strong>\n\n<strong>  return res.render('auth\/register');<\/strong>\n\n<strong>});<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u3001\u300c<strong>views\/auth\/register.mst<\/strong>\u300d\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3001\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;html&gt;\n&lt;head&gt;\n    &lt;link href=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.4.1\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div id=\"app\"&gt;\n    &lt;div class=\"card-body\"&gt;\n        &lt;div class=\"form-group row\"&gt;\n            &lt;label for=\"name\" class=\"col-md-4 col-form-label text-md-right\"&gt;\u540d\u524d&lt;\/label&gt;\n            &lt;div class=\"col-md-6\"&gt;\n                &lt;input type=\"text\" class=\"form-control\" v-model=\"params.name\"&gt;\n                &lt;div class=\"alert alert-danger\" v-if=\"errors.name\" v-text=\"errors.name\"&gt;&lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n        &lt;div class=\"form-group row\"&gt;\n            &lt;label for=\"email\" class=\"col-md-4 col-form-label text-md-right\"&gt;\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9&lt;\/label&gt;\n            &lt;div class=\"col-md-6\"&gt;\n                &lt;input type=\"email\" class=\"form-control\" v-model=\"params.email\"&gt;\n                &lt;div class=\"alert alert-danger\" v-if=\"errors.email\" v-text=\"errors.email\"&gt;&lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n        &lt;div class=\"form-group row\"&gt;\n            &lt;label for=\"password\" class=\"col-md-4 col-form-label text-md-right\"&gt;\u30d1\u30b9\u30ef\u30fc\u30c9&lt;\/label&gt;\n            &lt;div class=\"col-md-6\"&gt;\n                &lt;input type=\"password\" class=\"form-control\" v-model=\"params.password\"&gt;\n                &lt;div class=\"alert alert-danger\" v-if=\"errors.password\" v-text=\"errors.password\"&gt;&lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n        &lt;div class=\"form-group row\"&gt;\n            &lt;label for=\"password-confirm\" class=\"col-md-4 col-form-label text-md-right\"&gt;\u30d1\u30b9\u30ef\u30fc\u30c9\uff08\u78ba\u8a8d\uff09&lt;\/label&gt;\n            &lt;div class=\"col-md-6\"&gt;\n                &lt;input type=\"password\" class=\"form-control\" v-model=\"params.passwordConfirmation\"&gt;\n                &lt;div class=\"alert alert-danger\" v-if=\"errors.passwordConfirmation\" v-text=\"errors.passwordConfirmation\"&gt;&lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n        &lt;div class=\"form-group row mb-0\"&gt;\n            &lt;div class=\"col-md-6 offset-md-4\"&gt;\n                &lt;button type=\"submit\" class=\"btn btn-primary\" @click=\"onSubmit\"&gt;\u767b\u9332\u3059\u308b&lt;\/button&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n    &lt;\/div&gt;\n    &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.6.11\"&gt;&lt;\/script&gt;\n    &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/axios\/0.19.2\/axios.min.js\"&gt;&lt;\/script&gt;\n    &lt;script&gt;\n\n        new Vue({\n            el: '#app',\n            data: {\n                params: {\n                    name: '',\n                    email: '',\n                    password: '',\n                    passwordConfirmation: ''\n                },\n                errors: {}\n            },\n            methods: {\n                onSubmit() {\n\n                    this.errors = {\n                        name: '',\n                        email: '',\n                        password: '',\n                        passwordConfirmation: ''\n                    };\n\n                    axios.post('\/register', this.params)\n                        .then(response =&gt; {\n\n                            if(response.data.result) {\n\n                                alert('\u5165\u529b\u3055\u308c\u305f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1\u3057\u307e\u3057\u305f\u3002');\n\n                            }\n\n                        })\n                        .catch(error =&gt; {\n\n                            const errors = error.response.data.errors;\n\n                            errors.forEach(error =&gt; {\n\n                                const key = error.param;\n\n                                if(this.errors[key] === '') {\n\n                                    this.errors[key] = error.msg;\n\n                                }\n\n                            });\n\n                        });\n\n                }\n            }\n        });\n\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p>\u4e2d\u8eab\u3068\u3057\u3066\u306f\u3001<code>Vue<\/code> + <code>axios<\/code>\u3067\u30c7\u30fc\u30bf\u9001\u4fe1\u3059\u308b\u30b7\u30f3\u30d7\u30eb\u306a\u69cb\u6210\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u30d6\u30e9\u30a6\u30b6\u3067\u8868\u793a\u3059\u308b\u3068\u3053\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5899\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_2.png\" alt=\"\" width=\"640\" height=\"290\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_2.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_2-300x136.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<h1>\u4eee\u767b\u9332\u3057\u3066\u672c\u767b\u9332\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u4eca\u56de\u306e\u30e1\u30a4\u30f3\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u5c11\u3057\u3084\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u5206\u5272\u3057\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u30e2\u30c7\u30eb\u306e\u8aad\u307f\u8fbc\u307f<\/h2>\n<p>\u5148\u307b\u3069\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u3068<code>Sequlize<\/code>\u30e2\u30c7\u30eb\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\uff08\u306a\u304a\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e0d\u8981\u306a<code>crypto<\/code>\u30d1\u30c3\u30b1\u30fc\u30b8\u3082\u8aad\u307f\u8fbc\u3093\u3067\u3044\u307e\u3059\uff09<\/p>\n<pre><strong>const { check, validationResult } = require('express-validator');<\/strong>\n<strong>const nodemailer = require('nodemailer');<\/strong>\n<strong>const bcrypt = require('bcrypt');<\/strong>\n<strong>const crypto = require('crypto');<\/strong>\n<strong>const User = require('.\/models').User;<\/strong><\/pre>\n<h2>\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u8a2d\u5b9a<\/h2>\n<p><code>Express<\/code>\u3067\u306fPOST\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>app.use(express.json());<\/strong>\n<strong>app.use(express.urlencoded({ extended: true }));<\/strong><\/pre>\n<h2>\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u306b\u5fc5\u8981\u306a\u4e8b\u524d\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3059\u308b<\/h2>\n<p>\u3067\u304d\u308b\u3060\u3051\u30b7\u30f3\u30d7\u30eb\u306b\u3057\u3088\u3046\u3068\u5fc3\u639b\u3051\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u3069\u3046\u3057\u3066\u3082\u30b3\u30fc\u30c9\u304c\u591a\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u305b\u3081\u3066\u3044\u304f\u3064\u304b\u3092\u5909\u6570\u306b\u683c\u7d0d\u3057\u3066\u304a\u304f\u3053\u3068\u306b\u3057\u307e\u3059\u3002\u6b21\u306e\u9805\u76ee\u3067\u8ffd\u52a0\u3059\u308b<code>app.post('\/register', ...)<\/code>\u30eb\u30fc\u30c8\u306e\u76f4\u524d\u306b\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\uff08\u3055\u3089\u306b\u3044\u3046\u3068\u3001\u672c\u6765\u306f<code>.env<\/code>\u306a\u3069\u3092\u4f7f\u3046\u3079\u304d\u3067\u3059\u304c\u4eca\u56de\u306f\u5272\u611b\u3057\u307e\u3059\u3002\u8a73\u3057\u304f\u306f\u3001<a href=\"https:\/\/blog.capilano-fw.com\/?p=5546#Nodejsenv\" target=\"_blank\" rel=\"noopener noreferrer\">Node.js\u3067.env\u3092\u4f7f\u3046\u65b9\u6cd5<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\uff09<\/p>\n<pre>\/\/ \u6697\u53f7\u5316\u306b\u3064\u304b\u3046\u30ad\u30fc\n<strong>const appKey = 'YOUR-SECRET-KEY';<\/strong>\n\n\/\/ \u30e1\u30fc\u30eb\u9001\u4fe1\u8a2d\u5b9a\n<strong>const transporter = nodemailer.createTransport({<\/strong>\n<strong>  host: '127.0.0.1',<\/strong>\n<strong>  port: 1025,<\/strong>\n<strong>  secure: '',<\/strong>\n<strong>  auth: {<\/strong>\n<strong>    user: '',<\/strong>\n<strong>    pass: ''<\/strong>\n<strong>  }<\/strong>\n<strong>});<\/strong>\n\n\/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30fb\u30eb\u30fc\u30eb\n<strong>const registrationValidationRules = [<\/strong>\n<strong>  check('name')<\/strong>\n<strong>    .not().isEmpty().withMessage('\u3053\u306e\u9805\u76ee\u306f\u5fc5\u9808\u5165\u529b\u3067\u3059\u3002'),<\/strong>\n<strong>  check('email')<\/strong>\n<strong>    .not().isEmpty().withMessage('\u3053\u306e\u9805\u76ee\u306f\u5fc5\u9808\u5165\u529b\u3067\u3059\u3002')<\/strong>\n<strong>    .isEmail().withMessage('\u6709\u52b9\u306a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u5f62\u5f0f\u3067\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002'),<\/strong>\n<strong>  check('password')<\/strong>\n<strong>    .not().isEmpty().withMessage('\u3053\u306e\u9805\u76ee\u306f\u5fc5\u9808\u5165\u529b\u3067\u3059\u3002')<\/strong>\n<strong>    .isLength({ min:8, max:25 }).withMessage('8\u6587\u5b57\u304b\u308925\u6587\u5b57\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002')<\/strong>\n<strong>    .custom((value, { req }) =&gt; {<\/strong>\n\n<strong>      if(req.body.password !== req.body.passwordConfirmation) {<\/strong>\n\n<strong>        throw new Error('\u30d1\u30b9\u30ef\u30fc\u30c9\uff08\u78ba\u8a8d\uff09\u3068\u4e00\u81f4\u3057\u307e\u305b\u3093\u3002');<\/strong>\n\n<strong>      }<\/strong>\n\n<strong>      return true;<\/strong>\n\n<strong>    })<\/strong>\n<strong>];<\/strong><\/pre>\n<p>\u8a73\u3057\u3044\u5185\u5bb9\u306f\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/blog.capilano-fw.com\/?p=5673\" target=\"_blank\" rel=\"noopener noreferrer\">Express\u3067\u30e1\u30fc\u30eb\u9001\u4fe1\u3059\u308b\u65b9\u6cd5<\/a><\/li>\n<li><a href=\"https:\/\/blog.capilano-fw.com\/?p=5619\" target=\"_blank\" rel=\"noopener noreferrer\">Express\u3067\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3059\u308b<\/a><\/li>\n<\/ul>\n<h2>\u9001\u4fe1\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092DB\u306b\u4fdd\u5b58\u3057\u3001\u672c\u767b\u9332\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b<\/h2>\n<p>\u3067\u306f\u3001\u9001\u4fe1\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092<code>User<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u767b\u9332\u3057\u3001\u3055\u3089\u306b\u300c\u672c\u767b\u9332\u30e1\u30fc\u30eb\u300d\u3092\u9001\u4fe1\u3059\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<pre>\/\/ \u3053\u3053\u306b\u5148\u307b\u3069\u306e\u4e8b\u524d\u30c7\u30fc\u30bf\n\n<strong>app.post('\/register', registrationValidationRules, (req, res) =&gt; {<\/strong>\n\n  <strong>const errors = validationResult(req);<\/strong>\n\n<strong>  if(!errors.isEmpty()) {<\/strong> \/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5931\u6557\n\n<strong>    return res.status(422).json({ errors: errors.array() });<\/strong>\n\n<strong>  }<\/strong>\n\n  \/\/ \u9001\u4fe1\u3055\u308c\u305f\u30c7\u30fc\u30bf\n<strong>  const name = req.body.name;<\/strong>\n<strong>  const email = req.body.email;<\/strong>\n<strong>  const password = req.body.password;<\/strong>\n\n  \/\/ \u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u3092\u767b\u9332\uff08\u4eee\u767b\u9332\uff09\n  <strong>User.findOrCreate({<\/strong>\n<strong>    where: { email: email },<\/strong>\n<strong>    defaults: {<\/strong>\n<strong>      name: name,<\/strong>\n<strong>      email: email,<\/strong>\n<strong>      password: bcrypt.hashSync(password, bcrypt.genSaltSync(8))<\/strong>\n<strong>    }<\/strong>\n<strong>  }).then(([user]) =&gt; {<\/strong>\n\n<strong>    if(user.emailVerifiedAt) { <\/strong>\/\/ \u3059\u3067\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u6642\n\n<strong>      return res.status(422).json({<\/strong>\n<strong>        errors: [<\/strong>\n<strong>          {<\/strong>\n<strong>            value: email,<\/strong>\n<strong>            msg: '\u3059\u3067\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u307e\u3059\u3002',<\/strong>\n<strong>            param: 'email',<\/strong>\n<strong>            location: 'body'<\/strong>\n<strong>          }<\/strong>\n<strong>        ]<\/strong>\n<strong>      });<\/strong>\n\n<strong>    }<\/strong>\n    \/\/ \u672c\u767b\u9332URL\u3092\u4f5c\u6210\n<strong>    const hash = crypto.createHash('sha1')<\/strong>\n<strong>      .update(user.email)<\/strong>\n<strong>      .digest('hex');<\/strong>\n<strong>    const now = new Date();<\/strong>\n<strong>    const expiration = now.setHours(now.getHours() + 1); <\/strong>\/\/ 1\u6642\u9593\u3060\u3051\u6709\u52b9\n<strong>    let verificationUrl = req.get('origin') +'\/verify\/'+ user.id +'\/'+ hash +'?expires='+ expiration;<\/strong>\n<strong>    const signature = crypto.createHmac('sha256', appKey)<\/strong>\n<strong>      .update(verificationUrl)<\/strong>\n<strong>      .digest('hex');<\/strong>\n<strong>    verificationUrl += '&amp;signature='+ signature;<\/strong>\n\n<strong>    <\/strong>\/\/ \u672c\u767b\u9332\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\n<strong>    transporter.sendMail({<\/strong>\n<strong>      from: 'from@example.com',<\/strong>\n<strong>      to: 'to@example.com',<\/strong>\n<strong>      text: \"\u4ee5\u4e0b\u306eURL\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u672c\u767b\u9332\u3092\u5b8c\u4e86\u3055\u305b\u3066\u304f\u3060\u3055\u3044\u3002\\n\\n\"+ verificationUrl,<\/strong>\n<strong>      subject: '\u672c\u767b\u9332\u30e1\u30fc\u30eb',<\/strong>\n<strong>    });<\/strong>\n\n<strong>    return res.json({<\/strong>\n<strong>      result: true<\/strong>\n<strong>    });<\/strong>\n\n<strong>  });<\/strong>\n\n<strong>});<\/strong><\/pre>\n<p>\u306a\u304a\u3001\u672c\u767b\u9332\u30e1\u30fc\u30eb\u3067\u9001\u4fe1\u3059\u308bURL\u306f<code>Laravel<\/code>\u306e\u30b3\u30fc\u30c9\u3092\u53c2\u8003\uff08\u3068\u3044\u3046\u304b\u307b\u307c\u79fb\u690d\uff09\u3057\u307e\u3057\u305f\u3002\u3044\u3064\u3082\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u6709\u52b9\u671f\u9650\u306f\uff11\u6642\u9593\u3067\u3059\u3002<\/p>\n<h2>\u672c\u767b\u9332\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u6700\u5f8c\u306b\u3001\u672c\u767b\u9332\u30e1\u30fc\u30eb\u306b\u8a18\u8f09\u3055\u308c\u3066\u3044\u308bURL\u306b\u30a2\u30af\u30bb\u30b9\u3055\u308c\u305f\u3068\u304d\u306e\u30da\u30fc\u30b8\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>app.get('\/verify\/:id\/:hash', (req, res) =&gt; {<\/strong>\n\n<strong>  const userId = req.params.id;<\/strong>\n<strong>  User.findByPk(userId)<\/strong>\n<strong>    .then(user =&gt; {<\/strong>\n\n<strong>      if(!user) {<\/strong>\n\n<strong>        res.status(422).send('\u3053\u306eURL\u306f\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002');<\/strong>\n\n<strong>      } else if(user.emailVerifiedAt) {<\/strong>  \/\/ \u3059\u3067\u306b\u672c\u767b\u9332\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u5834\u5408\n\n        \/\/ \u30ed\u30b0\u30a4\u30f3\uff06\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\uff08Passport.js\uff09\n<strong>        req.login(user, () =&gt; res.redirect('\/user'));<\/strong>\n\n<strong>      } else {<\/strong>\n\n<strong>        const now = new Date();<\/strong>\n<strong>        const hash = crypto.createHash('sha1')<\/strong>\n<strong>          .update(user.email)<\/strong>\n<strong>          .digest('hex');<\/strong>\n<strong>        const isCorrectHash = (hash === req.params.hash);<\/strong>\n<strong>        const isExpired = (now.getTime() &gt; parseInt(req.query.expires));<\/strong>\n<strong>        const verificationUrl = APP_URL + req.originalUrl.split('&amp;signature=')[0];<\/strong>\n<strong>        const signature = crypto.createHmac('sha256', APP_KEY)<\/strong>\n<strong>          .update(verificationUrl)<\/strong>\n<strong>          .digest('hex');<\/strong>\n<strong>        const isCorrectSignature = (signature === req.query.signature);<\/strong>\n\n<strong>        if(!isCorrectHash || !isCorrectSignature || isExpired) {<\/strong>\n\n<strong>          res.status(422).send('\u3053\u306eURL\u306f\u3059\u3067\u306b\u6709\u52b9\u671f\u9650\u5207\u308c\u304b\u3001\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002');<\/strong>\n\n<strong>        } else {<\/strong>  \/\/ \u672c\u767b\u9332\n\n<strong>          user.emailVerifiedAt = new Date();<\/strong>\n<strong>          user.save();<\/strong>\n\n<strong>          <\/strong>\/\/ \u30ed\u30b0\u30a4\u30f3\uff06\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\uff08Passport.js\uff09\n<strong>          req.login(user, () =&gt; res.redirect('\/user'));<\/strong>\n\n<strong>        }<\/strong>\n\n<strong>      }<\/strong>\n\n<strong>    });<\/strong>\n\n<strong>});<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u3084\u3063\u3066\u3044\u308b\u3053\u3068\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ol>\n<li>URL\u306b\u542b\u307e\u308c\u305f\u30e6\u30fc\u30b6\u30fcID\u304b\u3089User\u30c7\u30fc\u30bf\u3092\u53d6\u5f97<\/li>\n<li>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3001\u6709\u52b9\u6642\u9593\u3001\u6b63\u3057\u3044URL\u304b\u3092\u30c1\u30a7\u30c3\u30af<\/li>\n<li>\u5168\u3066\u30af\u30ea\u30a2\u3057\u305f\u3089 emailVerifiedAt \u306b\u73fe\u5728\u6642\u9593\u3092\u4fdd\u5b58<\/li>\n<\/ol>\n<p>\u306a\u304a\u3001\u30ed\u30b0\u30a4\u30f3\uff06\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3092\u3059\u308b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u304c\uff12\u30f6\u6240\u51fa\u3066\u304d\u307e\u3059\u304c\u3001\u3053\u308c\u306f<code>Passport.js<\/code>\u3067\u306e\u30ed\u30b0\u30a4\u30f3\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u8a73\u3057\u304f\u306f\u3001\u300c<a href=\"https:\/\/blog.capilano-fw.com\/?p=5655\">Express\u306b\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u3064\u304f\u308b<\/a>\u300d\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>req.login(user, () =&gt; res.redirect('\/user'));<\/pre>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u3001\u30d5\u30a9\u30fc\u30e0\u306b\u5fc5\u8981\u306a\u5165\u529b\u3092\u3057\u3066\u9001\u4fe1\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5911\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_3.png\" alt=\"\" width=\"775\" height=\"287\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_3.png 775w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_3-300x111.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_3-768x284.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5910\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_4.png\" alt=\"\" width=\"517\" height=\"205\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_4.png 517w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_4-300x119.png 300w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/p>\n<p>\u30e1\u30fc\u30eb\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5909\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_5.png\" alt=\"\" width=\"447\" height=\"219\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_5.png 447w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_5-300x147.png 300w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/><\/p>\n<p>URL\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u524d\u306b\u3001<code>Users<\/code>\u30c6\u30fc\u30d6\u30eb\u3082\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5908\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_6.png\" alt=\"\" width=\"531\" height=\"272\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_6.png 531w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_6-300x154.png 300w\" sizes=\"auto, (max-width: 531px) 100vw, 531px\" \/><\/p>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u30e1\u30fc\u30eb\u306eURL\u3092\u30af\u30ea\u30c3\u30af\u3057\u3001\u518d\u5ea6<code>Users<\/code>\u30c6\u30fc\u30d6\u30eb\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5907\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_7.png\" alt=\"\" width=\"536\" height=\"270\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_7.png 536w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_7-300x151.png 300w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><\/p>\n<p>\u306f\u3044\uff01<br \/>\n\u3046\u307e\u304f<code>emailVerifiedAt<\/code>\u304c\u66f4\u65b0\u3055\u308c\u307e\u3057\u305f\ud83d\ude0a\u2728<\/p>\n<p>\u306a\u304a\u3001\u308f\u3056\u3068\u9593\u9055\u3048\u305fURL\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8868\u793a\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5912\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/02\/express_registration_8.png\" alt=\"\" width=\"235\" height=\"41\"><\/p>\n<p>\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\uff01<\/p>\n<h1>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/h1>\n<p>\u4ee5\u4e0b\u304b\u3089\u5b9f\u969b\u4eca\u56de\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b\u305f\u3060\u3057\u3001\u3053\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001<code>passport.js<\/code>\u3084<code>mustache-express<\/code>\u306a\u3069\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3082\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u78ba\u8a8d\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=5916&amp;tmstv=1777532640\" rel=\"nofollow\" id=\"download-link-5916\" data-redirect=\"false\" >\n\tExpress\u3067\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6a5f\u80fd\uff08\u30e1\u30fc\u30eb\u8a8d\u8a3c\u3064\u304d\uff09<\/a>\n\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>Express<\/code>\u3067\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6a5f\u80fd\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u3092\u8a00\u3046\u3068\u3001\u3053\u306e\u6a5f\u80fd\u3092\u958b\u767a\u3057\u306f\u3058\u3081\u305f\u9803\u306f\u3082\u3063\u3068\u7c21\u5358\u306b\u3067\u304d\u308b\u3060\u308d\u3046\u3068\u9ad8\u3092\u304f\u304f\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u5b9f\u969b\u306f\u60f3\u50cf\u4ee5\u4e0a\u306b\u3084\u308b\u3053\u3068\u304c\u591a\u304f\u3001\u306a\u304b\u306a\u304b\u5927\u5909\u306a\u4f5c\u696d\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3093\u306a\u3053\u3068\u3082\u3042\u3063\u3066\u3001\u4eca\u56de\u306e\u8a18\u4e8b\u306e\u4e2d\u3067\u300c\u30d1\u30b9\u30ef\u30fc\u30c9\u30ea\u30de\u30a4\u30f3\u30c0\u30fc\u300d\u3082\u7d39\u4ecb\u3057\u3088\u3046\u3068\u601d\u3063\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u305d\u308c\u306f\u5225\u306e\u8a18\u4e8b\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u4f55\u5ea6\u3082\u540c\u3058\u3088\u3046\u306a\u3053\u3068\u3092\u8a00\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u4eca\u56de\u306e\u300c<strong>\u30e6\u30fc\u30b6\u30fc\u767b\u9332<\/strong>\u300d\u3068\u300c<strong>\u30ed\u30b0\u30a4\u30f3<\/strong>\u300d\u3001\u305d\u3057\u3066\u300c<strong>\u30d1\u30b9\u30ef\u30fc\u30c9\u30ea\u30de\u30a4\u30f3\u30c0\u30fc<\/strong>\u300d\u306e\uff13\u3064\u304c<code>Laravel<\/code>\u306b\u306f\u6a19\u6e96\u3067\u642d\u8f09\u3055\u308c\u3066\u3044\u308b\uff086.x\u304b\u3089\u306f\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u5206\u96e2\u3055\u308c\u307e\u3057\u305f\u304c\uff09\u3063\u3066\u3084\u3063\u3071\u308a\u3059\u3054\u3044\u3067\u3059\u306d\u3002<\/p>\n<p><code>Express<\/code>\u3067\u958b\u767a\u3092\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u958b\u767a\u8cbb\u3082\u305d\u306e\u5206\u8df3\u306d\u4e0a\u304c\u308b\u306e\u306f\u5f53\u7136\u3068\u3044\u3063\u3066\u3044\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u3061\u3087\u3063\u3068\u9055\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001IE\u3067\u3082\u52d5\u304f\u30b5\u30a4\u30c8\u3092\u3064\u304f\u308d\u3046\u3068\u3059\u308b\u3068\u3001\u305d\u308c\u3060\u3051\u3067\u958b\u767a\u8cbb\u304c\u3042\u304c\u308b\u3068\u3044\u3046\u306e\u3068\u4f3c\u3066\u3044\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\ud83d\ude05<\/p>\n<p>\u4eca\u56de\u306f\u305d\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2035 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4.png\" alt=\"\" width=\"320\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4.png 320w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4-150x150.png 150w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4-300x300.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4-100x100.png 100w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u4ee5\u524d\u3053\u306e\u30d6\u30ed\u30b0\u3067\u516c\u958b\u3057\u305f\u300c\u30b3\u30d4\u30da\u3067OK\uff01Express\u306b\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u3064\u304f\u308b\u300d\u3068\u3044\u3046\u8a18\u4e8b\u3067\u306f\u3001\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002 \u305d\u3057\u3066\u3001\u4eca\u56de\u306f\u305d\u306e\u7d9a\u304d &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=5893\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Express\u3067\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6a5f\u80fd\uff08\u30e1\u30fc\u30eb\u8a8d\u8a3c\u3064\u304d\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\uff09&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":5920,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[201,97],"tags":[61],"class_list":["post-5893","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-express","category-97","tag-61"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/5893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5893"}],"version-history":[{"count":19,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/5893\/revisions"}],"predecessor-version":[{"id":6182,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/5893\/revisions\/6182"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/5920"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}