From dcb81052fa58e4512c88e979be15170179f073e2 Mon Sep 17 00:00:00 2001 From: Robert Jeutter Date: Tue, 31 Mar 2020 14:57:20 +0200 Subject: [PATCH] pruned security vulnerabilities and added mail route --- .env-cmdrc.json | 12 - .vs/ProjectSettings.json | 3 + .../config/applicationhost.config | 1021 +++++++++++++++++ .vs/nodejs-boilerplate/v16/.suo | Bin 0 -> 8192 bytes .vs/slnx.sqlite | Bin 0 -> 90112 bytes app.js | 49 +- config/.env-cmdrc.json | 12 + package-lock.json | 168 +-- package.json | 13 +- public/css/main.css | 13 +- readme.md | 44 +- routes/index.js | 64 +- views/index/index.pug | 2 + views/index/mail.pug | 17 + views/layout.pug | 4 +- 15 files changed, 1182 insertions(+), 240 deletions(-) delete mode 100644 .env-cmdrc.json create mode 100644 .vs/ProjectSettings.json create mode 100644 .vs/nodejs-boilerplate/config/applicationhost.config create mode 100644 .vs/nodejs-boilerplate/v16/.suo create mode 100644 .vs/slnx.sqlite create mode 100644 config/.env-cmdrc.json create mode 100644 views/index/mail.pug diff --git a/.env-cmdrc.json b/.env-cmdrc.json deleted file mode 100644 index 2253b15..0000000 --- a/.env-cmdrc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "development": { - "env": "development", - "IP": "localhost", - "PORT": "8080" - // add all environment variables for your development server - }, - "production": { - "env": "production", - // add all environment variables for your production server - } -} \ No newline at end of file diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..f8b4888 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/.vs/nodejs-boilerplate/config/applicationhost.config b/.vs/nodejs-boilerplate/config/applicationhost.config new file mode 100644 index 0000000..856145a --- /dev/null +++ b/.vs/nodejs-boilerplate/config/applicationhost.config @@ -0,0 +1,1021 @@ + + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.vs/nodejs-boilerplate/v16/.suo b/.vs/nodejs-boilerplate/v16/.suo new file mode 100644 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P`ld-fx-j*EhLdO`F}vFR`WA_zN!p)CnMpi9}`| z8AK$ToFiwpO=!z*-jjZ}z9y@-@U&~oO)nR_x8IJR%!=z29$Bba7TSK{-?YCTy=Z>0 O^633`X79a+LZ1Lhze?T! literal 0 HcmV?d00001 diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..842ce4eb0d2c1da7ec1a0617253a2d4eb2dbfc41 GIT binary patch literal 90112 zcmeI53v46Dd4P9CiWFZv(n&g=PWRwFKeN5A>4#p%hy1Cgt{Dq|_+kHBkYx>J5Ba`I|>wM)^h;gC0+2Q}~Q zuI9A7O1mp3?4X>La|e}};8G+%Gd0E9Iz5x0m@h;hy(j1miz5HH*py3E>TJ66d&p2` zVdC6Wp-am{{*yYF4v0l{3HUA)?k&tkX6K3*C+4n1E)=drCKeZFiqlZ+#lrLgXa)a^ zQ&XpnQfAldH!3P!x92uxbP?7GbA|JTxx#e5Fdw;U<|x#fmFDKs$yNju5w)^Fzb(#A zG7x|vKQUQoOPVZ96|5vv86DvC<%zlceG_vh6Ot5dDeT~CW;wr6t!`f0kgJt)g{s{O zXzvd*-vzJ|iw%1wvQuOwsU-P)fmNbuZ=5l@yw0oR08R|DZ&Y5KQnO%6C z(V^XR?y#ITkJIYi*X=PguL zX`?Bxt}R8_;IUA=2qP(sSIiPcpErCa%HJZIC7RW;@|Ia(M(B$9jc#3>E?!z}9eGTd zRwkQynQ2DD;22}Z=qft~l2+lpcOaedx!G|JyTtJ$Ghm|lGQH($FAwkO&w z&`hv*(k?7dw~Us;dULE{Hn!s^Yu4Lp>TWW#F1y?74HrbS%bbS1JS(r$T638V+s?GU zuKnkfvX@}%N~ai`FmyXQpN7Mkrh+pAv*oRG9&h+MjC`Bc$Y=9Hqw3C_w(-viK`4oHI!Ia?Tjqt?=W3v=FSL~byPRWhtOsPTF zZ%~*PStGA8TZ~K=&QB~(Eku-!blenET{1h%+cs_gFduDYcOkT|LSV98%N^F8W{g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ZHm#A*=7mPpojGmepH19rw8xkNIkW9h+74}dkwy&n+NVVw)iNsG7540) zu$6NM<+_27-oDSR57K#Skhals>e<`wAkJi)i#U_+%vE%qEi2!}Ok~?Wu*N!V9Aon- z_PT>9!OI)riw(wRDRQpZISrhW8_k(ggRbA8FfFo1USqZxnJk>2Se#mjC>!gV$2QGj z8l1fD@`mH1{MKR3P3CE{S*fjPK5fjm^%!@%J$1@yW~5E`^$goNZFIKB6Fzl{zoJ=A z;~|)%(d7nxXoJ>Z*4F;j)n+%2#FI5J{?m{%x^*w_4UdlUx2RU8p_}p6(^ke+Bi3ee zM$Avl(k{!@4d_RQb?OI6?fjp6k|Wc>Cj;LP%=E>*k9fY|o^pK@B7fqq$NGo7!=l*t z#Qira^d_6D&&tgQwIg7KHk{uL&XI17CXoOgDRV3OzO;k4e8hQ@U1rF-o9utCSf4nt1JZ}#r|_?u2U z^lr2aBjkTEWp|?_sJfkQoqYrbdLNu7cQ=+uabBCqZk-(ThOb8Xtt*aM#iZPnw>=B8 z_%N}(?L%pM;*(Sp3bLYv)=Lffp=gq17JkVRM&$-&M;R-W3|rHnPF;C8Tsh|KYs54;r~fUP>-K@0M`D&#FAT zHL%Ov#RmLpl)O=G&Nt=t=EfS_n|6&V&7WhpdL3myNO1ISc(1E8qSp{Pxh5;u{ res.redirect("/"); }); +app.use("/", indexRoute); +app.get('*', (req,res)=>{ res.redirect("/"); }); //fallback: redirect all website calls with no matching route to homesite (or 404 page) -/*## PORT ##*/ -app.listen(process.env.PORT, process.env.IP, function(){ +/*## init server ##*/ +app.listen(process.env.PORT, process.env.IP, function(){ //start your server console.log("Server is listening at " + process.env.IP + ":" + process.env.PORT + " with Environment: " + process.env.env); }); diff --git a/config/.env-cmdrc.json b/config/.env-cmdrc.json new file mode 100644 index 0000000..29d45fd --- /dev/null +++ b/config/.env-cmdrc.json @@ -0,0 +1,12 @@ +{ + "development": { + "desc": "all environment variables for your development server", + "env": "development", + "IP": "localhost", + "PORT": 8080 + }, + "production": { + "desc": "all environment variables for your production server", + "env": "production" + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3af3832..5a6ed8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nodejs-boilerplate", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -115,11 +115,6 @@ "picomatch": "^2.0.4" } }, - "append-field": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", - "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY=" - }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -255,43 +250,6 @@ "fill-range": "^7.0.1" } }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" - }, - "busboy": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", - "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", - "requires": { - "dicer": "0.2.5", - "readable-stream": "1.1.x" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, "bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", @@ -400,17 +358,6 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, "configstore": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz", @@ -533,38 +480,6 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, - "dicer": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", - "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", - "requires": { - "readable-stream": "1.1.x", - "streamsearch": "0.1.2" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, "doctypes": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz", @@ -1137,19 +1052,6 @@ "brace-expansion": "^1.1.7" } }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { - "minimist": "0.0.8" - } - }, "morgan": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", @@ -1174,21 +1076,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "multer": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.2.tgz", - "integrity": "sha512-xY8pX7V+ybyUpbYMxtjM9KAiD9ixtg5/JkeKUTD6xilfDv0vzzOFcCp4Ljb1UU3tSOM3VTZtKo63OmzOrGi3Cg==", - "requires": { - "append-field": "^1.0.0", - "busboy": "^0.2.11", - "concat-stream": "^1.5.2", - "mkdirp": "^0.5.1", - "object-assign": "^4.1.1", - "on-finished": "^2.3.0", - "type-is": "^1.6.4", - "xtend": "^4.0.0" - } - }, "mysql": { "version": "2.18.1", "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz", @@ -1535,20 +1422,6 @@ } } }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, "readdirp": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.3.0.tgz", @@ -1650,30 +1523,6 @@ } } }, - "serve-favicon": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/serve-favicon/-/serve-favicon-2.5.0.tgz", - "integrity": "sha1-k10kDN/g9YBTB/3+ln2IlCosvPA=", - "requires": { - "etag": "~1.8.1", - "fresh": "0.5.2", - "ms": "2.1.1", - "parseurl": "~1.3.2", - "safe-buffer": "5.1.1" - }, - "dependencies": { - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" - } - } - }, "serve-static": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", @@ -1723,11 +1572,6 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, - "streamsearch": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", - "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" - }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -1817,11 +1661,6 @@ "mime-types": "~2.1.24" } }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" - }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", @@ -2003,11 +1842,6 @@ "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=" }, - "xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" - }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", diff --git a/package.json b/package.json index 24d27fb..4fee963 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-boilerplate", - "version": "1.0.0", + "version": "1.0.1", "description": "NodeJS boilerplate for express apps", "main": "app.js", "dependencies": { @@ -12,23 +12,18 @@ "express-session": "^1.17.0", "method-override": "^3.0.0", "morgan": "^1.10.0", - "multer": "^1.4.2", "mysql": "^2.18.1", "nodemailer": "^6.4.6", "nodemon": "^2.0.2", - "pug": "^2.0.4", - "serve-favicon": "^2.5.0" + "pug": "^2.0.4" }, "devDependencies": {}, "scripts": { - "initPackage": "sh ./config/init.sh", - "createDB": "sh ./config/initDB.sh", - "startServer": "env-cmd -e development nodemon app.js", + "startDevServer": "env-cmd -e development -r ./config/.env-cmdrc.json nodemon app.js", "startDevDB": "sudo /etc/init.d/mysql start", "stopDevDB": "sudo /etc/init.d/mysql stop", "dev": "npm run startDevDB && npm run startDevServer", "start": "node app.js", - "test": "echo \"Error: no test specified\" && exit 1", "testDB": "node ./config/db-test.js" }, "repository": { @@ -41,7 +36,7 @@ "boilerplate" ], "author": "Robert Jeutter", - "license": "SEE LICENSE IN LICENSE", + "license": "GNU GENERAL PUBLIC LICENSE", "bugs": { "url": "https://github.com/wieerwill/nodejs-boilerplate/issues" }, diff --git a/public/css/main.css b/public/css/main.css index a9db5b7..8c00181 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -1,3 +1,14 @@ body{ - background-color: blue; + background-color: #94efef; + color: #000000; + text-align: center; + margin: 0 20% 0 20%; + padding: 10%; +} + +form { + border: 3px solid #00ff21; +} +.input{ + margin: 15px; } \ No newline at end of file diff --git a/readme.md b/readme.md index 3a69785..1479844 100644 --- a/readme.md +++ b/readme.md @@ -1,25 +1,48 @@ # NodeJS Boilerplate for Express Apps +This repository show you a simple but powerful way to start up your NodeJS Projects with Express. + + +## Get started +1. Clone/Fork this repository to your computer +2. install all requirements + 1. node + 2. mysql +2. set the config files + 1. change "mail.js" credentials + 2. change "database.js" credentials +3. start your development server with "npm run dev" +4. feel free to do what you want to do ## Routing | URL | Method | Desc | | --- | --- | --- | | / | GET | Index Site | +| / | POST | nothing yet, work on it | +| / | DELETE | nothing yet, work on it | +| /mail | GET | view Mail form | +| /mail | SEND | send mail via nodemailer | | /api | GET | Your API starts here | -## Requirements - - - -#### npm Packages -- express -- ejs -- [nodemailer](https://www.npmjs.com/package/advanced-sitemap-generator) -- mysql -- body-parser -- +## npm Packages + Name | Version | Description +--- | --- | --- +[body-parser](https://www.npmjs.com/package/body-parser) | ^1.19.0 | Parse incoming request bodies in a middleware before your handlers, available under the req.body property. +[connect-flash](https://www.npmjs.com/package/connect-flash) | ^0.1.1 | The flash is a special area of the session used for storing messages +[cookie-parser](https://www.npmjs.com/package/cookie-parser) | ^1.4.5 | Parse Cookie header and populate req.cookies with an object keyed by the cookie names +[env-cmd](https://www.npmjs.com/package/env-cmd) | ^10.1.0 | A simple node program for executing commands using an environment from an env file +[express](https://www.npmjs.com/package/express) | ^4.17.1 | Fast, unopinionated, minimalist web framework for node +[express-session](https://www.npmjs.com/package/express-session) | ^1.17.0 | Create a session middleware +[method-override](https://www.npmjs.com/package/method-override) | ^3.0.0 | Lets you use HTTP verbs such as PUT or DELETE in places where the client doesn't support it +[morgan](https://www.npmjs.com/package/morgan) | ^1.10.0 | HTTP request logger middleware for node.js +[mysql](https://www.npmjs.com/package/mysql) | ^2.18.1 | This is a node.js driver for mysql. It is written in JavaScript, does not require compiling, and is 100% MIT licensed. +[nodemailer](https://www.npmjs.com/package/nodemailer) | ^6.4.6 | Send e-mails from Node.js – easy as cake! +[nodemon](https://www.npmjs.com/package/nodemon) | ^2.0.2 | nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected. +[pug](https://www.npmjs.com/package/pug) | ^2.0.4 | Pug is a high performance template engine heavily influenced by Haml and implemented with JavaScript for Node.js and browsers ## Folder Overview - config: all your apps configuration files for databases, connections and other + - .env-cmdrc.json: all environment variables for your servers - database.js: your database connections and table overview - db-test.js: test your database connection with this js - mail.js: your mail connection @@ -38,7 +61,6 @@ - index: all files for index routes - index.pug: the index routes view - layout.pug: make it easy with a standarized layout for all your files - - .env-cmdrc.json: all environment variables for your servers - app.js: entry file to start everything up - gitignore: ignore some files in your git repository that don't matter - package.json: overview and scripts for your packages diff --git a/routes/index.js b/routes/index.js index 0fb6231..4af8bfd 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,24 +1,64 @@ -const express = require('express'), +/*## Get all necassary packages for this route ##*/ +const express = require('express'), router = express(), - mysql = require('mysql'), bodyParser= require('body-parser'), nodemailer = require('nodemailer'), - session = require('express-session'), flash = require('connect-flash'), - cookieParser = require('cookie-parser'), - dbconfig = require('../config/database'), - mailconfig = require('../config/mail'), - middlewear = require('./middlewear'), - con = mysql.createConnection(dbconfig.connection); + mailconfig = require('../config/mail'); +/*## SETUP nodemailer ''*/ +var transporter = nodemailer.createTransport({ + host: mailconfig.connection.host, + port: mailconfig.connection.port, + secure: mailconfig.connection.secure, + auth: { + user: mailconfig.connection.auth.user, + pass: mailconfig.connection.auth.pass + }, +}); +// verify mail connection configuration +transporter.verify(function (error, success) { + if (error) { + console.log(error); + } else { + console.log("Server is ready to take our messages"); + } +}); +/*## Start with routing ##*/ // Index -router.route("/") - .get((req, res)=> { // you got a GET request - res.render('index/index'); // get your index view file +router.route("/")//all routes from url "/" + .get((req, res) => { // you got a GET request to "/" + res.render('index/index'); // get your index view file }) - .post((req, res) => { + .post((req, res) => { //you got a POST request to "/" //do something with a POST request + }) + .delete((req, res) => { //you got a POST request to '/?method="DELETE"' but is overritten with DELETE request + //delete something + }); + +// MAIL +router.route("/mail") + .get((req, res) => { //GET request to "/mail" + //do something + res.render('index/mail'); + }) + .post((req, res) => { //you got a POST request to "/mail" + let mailOptions = { + from: req.body.email, + to: mailconfig.connection.auth.user, + subject: "Mail from NodeJS boilerplate", + text: req.body.message + }; + transporter.sendMail(mailOptions, function (error, info) { + if (error) { + req.flash('error', "Mail error. Please try again"); + } else { + req.flash('success', "Thanks for your Mail"); + } + }); + res.redirect("/"); }); module.exports = router; \ No newline at end of file diff --git a/views/index/index.pug b/views/index/index.pug index 5291543..925fc6b 100644 --- a/views/index/index.pug +++ b/views/index/index.pug @@ -3,3 +3,5 @@ extends ../layout block body div p Aspernatur laboriosam dolor praesentium soluta. Veniam soluta rerum fugit non vel est et fuga. Molestias a rerum nisi. Commodi explicabo est soluta quia doloribus deserunt nesciunt et. Consequatur necessitatibus deleniti eius ipsa voluptates tenetur. Molestiae ratione animi aut harum ex. Assumenda ad aperiam consequatur. Non exercitationem vel molestiae ut quas alias et suscipit. Aut nihil dolorum quo ipsa perspiciatis labore modi. Recusandae facere rerum aut totam. Quis ut dolorem sit corporis voluptate amet. Earum quo mollitia voluptas vitae est quo harum. Temporibus dolorem nam eum. Iure tempore rerum omnis. Eius quasi qui nostrum. Sequi dolorem labore ipsam et ut et quo. Explicabo aut praesentium voluptatem enim. Voluptatem sed cupiditate ea. Autem architecto maxime molestiae distinctio. Perferendis omnis aut dolorem. + + a(href="/mail") to mail form diff --git a/views/index/mail.pug b/views/index/mail.pug new file mode 100644 index 0000000..bb24fa5 --- /dev/null +++ b/views/index/mail.pug @@ -0,0 +1,17 @@ +extends ../layout + +block body + form(action="/mail" method="POST") + + .input + label(for="email") Your Email + input(type="email" id="email" name="email" placeholder="example@web.com" required) + + .input + label(for="message") Your message + textarea(name="message" id="message") + + .input + input(type="submit" id="submit" value="send mail") + + a(href="/") go back \ No newline at end of file diff --git a/views/layout.pug b/views/layout.pug index 797bdee..94f21cb 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -18,8 +18,8 @@ html(lang='de') block body footer - small Get me on - a(href="") Github + h3 Get me on + a(href="https://github.com/wieerwill/nodejs-boilerplate") Github script(src='js/index.js') \ No newline at end of file