├── 06 - Enhancing the App └── section-code │ ├── .gitignore │ ├── views │ ├── shop │ │ ├── checkout.ejs │ │ ├── product-detail.ejs │ │ ├── cart.ejs │ │ └── orders.ejs │ ├── admin │ │ └── edit-product.ejs │ ├── includes │ │ ├── end.ejs │ │ └── head.ejs │ └── 404.ejs │ ├── util │ └── path.js │ ├── controllers │ └── error.js │ ├── data │ └── products.json │ ├── public │ └── css │ │ ├── product.css │ │ └── forms.css │ ├── routes │ ├── shop.js │ └── admin.js │ ├── package.json │ └── app.js ├── 12 - Sessions & Cookies ├── assignment │ ├── .gitignore │ ├── views │ │ ├── shop │ │ │ ├── checkout.ejs │ │ │ └── product-detail.ejs │ │ ├── includes │ │ │ ├── end.ejs │ │ │ ├── add-to-cart.ejs │ │ │ └── head.ejs │ │ ├── 404.ejs │ │ └── auth │ │ │ └── login.ejs │ ├── data │ │ ├── cart.json │ │ └── products.json │ ├── util │ │ └── path.js │ ├── public │ │ ├── css │ │ │ ├── auth.css │ │ │ ├── forms.css │ │ │ ├── cart.css │ │ │ ├── product.css │ │ │ └── orders.css │ │ └── js │ │ │ └── main.js │ ├── controllers │ │ ├── error.js │ │ └── auth.js │ ├── routes │ │ ├── auth.js │ │ ├── shop.js │ │ └── admin.js │ ├── models │ │ └── order.js │ └── package.json └── section-code │ ├── .gitignore │ ├── views │ ├── shop │ │ ├── checkout.ejs │ │ └── product-detail.ejs │ ├── includes │ │ ├── end.ejs │ │ ├── add-to-cart.ejs │ │ └── head.ejs │ ├── 404.ejs │ └── auth │ │ └── login.ejs │ ├── data │ ├── cart.json │ └── products.json │ ├── util │ └── path.js │ ├── public │ ├── css │ │ ├── auth.css │ │ ├── forms.css │ │ ├── cart.css │ │ ├── product.css │ │ └── orders.css │ └── js │ │ └── main.js │ ├── controllers │ ├── error.js │ └── auth.js │ ├── routes │ ├── auth.js │ ├── shop.js │ └── admin.js │ ├── models │ └── order.js │ └── package.json ├── 17 - Error Handling └── section-code │ ├── .gitignore │ ├── views │ ├── shop │ │ ├── checkout.ejs │ │ └── product-detail.ejs │ ├── includes │ │ ├── end.ejs │ │ ├── add-to-cart.ejs │ │ └── head.ejs │ ├── 404.ejs │ └── 500.ejs │ ├── data │ ├── cart.json │ └── products.json │ ├── util │ └── path.js │ ├── public │ ├── css │ │ ├── auth.css │ │ ├── cart.css │ │ ├── product.css │ │ ├── orders.css │ │ └── forms.css │ └── js │ │ └── main.js │ ├── middleware │ └── is-auth.js │ ├── controllers │ └── error.js │ ├── models │ └── order.js │ └── routes │ └── shop.js ├── 11 - Working with Mongoose ├── section-code │ ├── .gitignore │ ├── views │ │ ├── shop │ │ │ ├── checkout.ejs │ │ │ └── product-detail.ejs │ │ ├── includes │ │ │ ├── end.ejs │ │ │ ├── add-to-cart.ejs │ │ │ └── head.ejs │ │ └── 404.ejs │ ├── data │ │ ├── cart.json │ │ └── products.json │ ├── util │ │ └── path.js │ ├── controllers │ │ └── error.js │ ├── public │ │ ├── css │ │ │ ├── forms.css │ │ │ ├── cart.css │ │ │ ├── product.css │ │ │ └── orders.css │ │ └── js │ │ │ └── main.js │ ├── models │ │ └── order.js │ ├── routes │ │ ├── shop.js │ │ └── admin.js │ └── package.json └── README.md ├── 13 - Adding Authentication ├── section-code │ ├── .gitignore │ ├── views │ │ ├── shop │ │ │ ├── checkout.ejs │ │ │ └── product-detail.ejs │ │ ├── includes │ │ │ ├── end.ejs │ │ │ ├── add-to-cart.ejs │ │ │ └── head.ejs │ │ └── 404.ejs │ ├── data │ │ ├── cart.json │ │ └── products.json │ ├── util │ │ └── path.js │ ├── public │ │ ├── css │ │ │ ├── auth.css │ │ │ ├── forms.css │ │ │ ├── cart.css │ │ │ ├── product.css │ │ │ └── orders.css │ │ └── js │ │ │ └── main.js │ ├── middleware │ │ └── is-auth.js │ ├── controllers │ │ └── error.js │ ├── routes │ │ ├── auth.js │ │ ├── shop.js │ │ └── admin.js │ └── models │ │ └── order.js └── README.md ├── 03 - Working with Express.js ├── 1 - assignment │ ├── .gitignore │ ├── README.md │ ├── app.js │ └── package.json ├── 2 - assignment │ ├── .gitignore │ ├── public │ │ └── css │ │ │ └── style.css │ ├── routes │ │ ├── main.js │ │ └── users.js │ ├── README.md │ ├── app.js │ ├── views │ │ ├── users.html │ │ └── index.html │ └── package.json └── section-code │ ├── .gitignore │ ├── util │ └── path.js │ ├── routes │ ├── shop.js │ └── admin.js │ ├── package.json │ ├── app.js │ ├── public │ └── css │ │ ├── product.css │ │ └── main.css │ └── views │ └── 404.html ├── 15 - Advanced Authentication ├── section-code │ ├── .gitignore │ ├── views │ │ ├── shop │ │ │ ├── checkout.ejs │ │ │ └── product-detail.ejs │ │ ├── includes │ │ │ ├── end.ejs │ │ │ ├── add-to-cart.ejs │ │ │ └── head.ejs │ │ └── 404.ejs │ ├── data │ │ ├── cart.json │ │ └── products.json │ ├── util │ │ └── path.js │ ├── public │ │ ├── css │ │ │ ├── auth.css │ │ │ ├── forms.css │ │ │ ├── cart.css │ │ │ ├── product.css │ │ │ └── orders.css │ │ └── js │ │ │ └── main.js │ ├── middleware │ │ └── is-auth.js │ ├── controllers │ │ └── error.js │ ├── models │ │ └── order.js │ └── routes │ │ ├── auth.js │ │ ├── shop.js │ │ └── admin.js └── README.md ├── 16 - Understanding Validation ├── assignment-code │ ├── .gitignore │ ├── views │ │ ├── shop │ │ │ ├── checkout.ejs │ │ │ └── product-detail.ejs │ │ ├── includes │ │ │ ├── end.ejs │ │ │ ├── add-to-cart.ejs │ │ │ └── head.ejs │ │ └── 404.ejs │ ├── data │ │ ├── cart.json │ │ └── products.json │ ├── util │ │ └── path.js │ ├── public │ │ ├── css │ │ │ ├── auth.css │ │ │ ├── forms.css │ │ │ ├── cart.css │ │ │ ├── product.css │ │ │ └── orders.css │ │ └── js │ │ │ └── main.js │ ├── middleware │ │ └── is-auth.js │ ├── controllers │ │ └── error.js │ ├── models │ │ └── order.js │ └── routes │ │ └── shop.js ├── section-code │ ├── .gitignore │ ├── views │ │ ├── shop │ │ │ ├── checkout.ejs │ │ │ └── product-detail.ejs │ │ ├── includes │ │ │ ├── end.ejs │ │ │ ├── add-to-cart.ejs │ │ │ └── head.ejs │ │ └── 404.ejs │ ├── data │ │ ├── cart.json │ │ └── products.json │ ├── util │ │ └── path.js │ ├── public │ │ ├── css │ │ │ ├── auth.css │ │ │ ├── cart.css │ │ │ ├── product.css │ │ │ ├── orders.css │ │ │ └── forms.css │ │ └── js │ │ │ └── main.js │ ├── middleware │ │ └── is-auth.js │ ├── controllers │ │ └── error.js │ ├── models │ │ └── order.js │ └── routes │ │ └── shop.js └── README.md ├── 05 - The Model View Controller (MVC) ├── section-code │ ├── .gitignore │ ├── views │ │ ├── includes │ │ │ ├── end.ejs │ │ │ ├── head.ejs │ │ │ └── navigation.ejs │ │ ├── 404.ejs │ │ └── add-product.ejs │ ├── data │ │ └── products.json │ ├── util │ │ └── path.js │ ├── controllers │ │ ├── error.js │ │ └── products.js │ ├── routes │ │ ├── shop.js │ │ └── admin.js │ ├── public │ │ └── css │ │ │ ├── forms.css │ │ │ └── product.css │ ├── package.json │ ├── app.js │ └── models │ │ └── product.js └── README.md ├── 10 - Working with NoSQL & Using MongoDB └── section-code │ ├── .gitignore │ ├── views │ ├── shop │ │ ├── checkout.ejs │ │ └── product-detail.ejs │ ├── includes │ │ ├── end.ejs │ │ ├── add-to-cart.ejs │ │ └── head.ejs │ └── 404.ejs │ ├── data │ ├── cart.json │ └── products.json │ ├── util │ ├── path.js │ └── database.js │ ├── controllers │ └── error.js │ ├── public │ ├── css │ │ ├── forms.css │ │ ├── cart.css │ │ ├── product.css │ │ └── orders.css │ └── js │ │ └── main.js │ ├── routes │ ├── shop.js │ └── admin.js │ └── package.json ├── 22 - Working with REST APIs - The Basics ├── section-code │ ├── .gitignore │ ├── routes │ │ └── feed.js │ ├── controllers │ │ └── feed.js │ ├── package.json │ └── app.js └── README.md ├── 24 - Understanding Async Await in Node.js ├── assignment-code │ ├── frontend │ │ ├── src │ │ │ ├── App.css │ │ │ ├── index.css │ │ │ ├── components │ │ │ │ ├── Image │ │ │ │ │ ├── Image.css │ │ │ │ │ ├── Avatar.css │ │ │ │ │ ├── Avatar.js │ │ │ │ │ └── Image.js │ │ │ │ ├── Toolbar │ │ │ │ │ ├── Toolbar.css │ │ │ │ │ └── Toolbar.js │ │ │ │ ├── Logo │ │ │ │ │ ├── Logo.css │ │ │ │ │ └── Logo.js │ │ │ │ ├── Backdrop │ │ │ │ │ ├── Backdrop.css │ │ │ │ │ └── Backdrop.js │ │ │ │ ├── Loader │ │ │ │ │ └── Loader.js │ │ │ │ ├── Layout │ │ │ │ │ ├── Layout.css │ │ │ │ │ └── Layout.js │ │ │ │ ├── Navigation │ │ │ │ │ ├── MobileToggle │ │ │ │ │ │ ├── MobileToggle.js │ │ │ │ │ │ └── MobileToggle.css │ │ │ │ │ ├── MainNavigation │ │ │ │ │ │ ├── MainNavigation.css │ │ │ │ │ │ └── MainNavigation.js │ │ │ │ │ └── MobileNavigation │ │ │ │ │ │ ├── MobileNavigation.css │ │ │ │ │ │ └── MobileNavigation.js │ │ │ │ ├── Paginator │ │ │ │ │ ├── Paginator.css │ │ │ │ │ └── Paginator.js │ │ │ │ ├── Form │ │ │ │ │ └── Input │ │ │ │ │ │ ├── FilePicker.js │ │ │ │ │ │ └── Input.css │ │ │ │ ├── ErrorHandler │ │ │ │ │ └── ErrorHandler.js │ │ │ │ ├── Feed │ │ │ │ │ └── Post │ │ │ │ │ │ └── Post.css │ │ │ │ └── Modal │ │ │ │ │ └── Modal.css │ │ │ ├── pages │ │ │ │ ├── Auth │ │ │ │ │ ├── Auth.js │ │ │ │ │ └── Auth.css │ │ │ │ └── Feed │ │ │ │ │ ├── Feed.css │ │ │ │ │ └── SinglePost │ │ │ │ │ └── SinglePost.css │ │ │ ├── util │ │ │ │ ├── image.js │ │ │ │ └── validators.js │ │ │ └── index.js │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── manifest.json │ │ ├── .gitignore │ │ └── package.json │ └── backend │ │ ├── .gitignore │ │ ├── models │ │ ├── user.js │ │ └── post.js │ │ ├── middleware │ │ └── is-auth.js │ │ └── package.json ├── section-code │ ├── .gitignore │ ├── models │ │ ├── user.js │ │ └── post.js │ ├── middleware │ │ └── is-auth.js │ └── package.json └── README.md ├── 23 - Working with REST APIs - The Practical Application ├── assignment-code │ ├── frontend │ │ ├── src │ │ │ ├── App.css │ │ │ ├── index.css │ │ │ ├── components │ │ │ │ ├── Image │ │ │ │ │ ├── Image.css │ │ │ │ │ ├── Avatar.css │ │ │ │ │ ├── Avatar.js │ │ │ │ │ └── Image.js │ │ │ │ ├── Toolbar │ │ │ │ │ ├── Toolbar.css │ │ │ │ │ └── Toolbar.js │ │ │ │ ├── Logo │ │ │ │ │ ├── Logo.css │ │ │ │ │ └── Logo.js │ │ │ │ ├── Backdrop │ │ │ │ │ ├── Backdrop.css │ │ │ │ │ └── Backdrop.js │ │ │ │ ├── Loader │ │ │ │ │ └── Loader.js │ │ │ │ ├── Layout │ │ │ │ │ ├── Layout.css │ │ │ │ │ └── Layout.js │ │ │ │ ├── Navigation │ │ │ │ │ ├── MobileToggle │ │ │ │ │ │ ├── MobileToggle.js │ │ │ │ │ │ └── MobileToggle.css │ │ │ │ │ ├── MainNavigation │ │ │ │ │ │ └── MainNavigation.css │ │ │ │ │ └── MobileNavigation │ │ │ │ │ │ ├── MobileNavigation.css │ │ │ │ │ │ └── MobileNavigation.js │ │ │ │ ├── Paginator │ │ │ │ │ ├── Paginator.css │ │ │ │ │ └── Paginator.js │ │ │ │ ├── Form │ │ │ │ │ └── Input │ │ │ │ │ │ ├── FilePicker.js │ │ │ │ │ │ └── Input.css │ │ │ │ ├── ErrorHandler │ │ │ │ │ └── ErrorHandler.js │ │ │ │ ├── Feed │ │ │ │ │ └── Post │ │ │ │ │ │ └── Post.css │ │ │ │ └── Modal │ │ │ │ │ └── Modal.css │ │ │ ├── pages │ │ │ │ ├── Auth │ │ │ │ │ ├── Auth.js │ │ │ │ │ └── Auth.css │ │ │ │ └── Feed │ │ │ │ │ ├── Feed.css │ │ │ │ │ └── SinglePost │ │ │ │ │ └── SinglePost.css │ │ │ ├── util │ │ │ │ ├── image.js │ │ │ │ └── validators.js │ │ │ └── index.js │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── manifest.json │ │ ├── .gitignore │ │ └── package.json │ └── backend │ │ ├── .gitignore │ │ ├── models │ │ ├── user.js │ │ └── post.js │ │ ├── middleware │ │ └── is-auth.js │ │ └── package.json ├── section-code │ ├── .gitignore │ ├── models │ │ ├── user.js │ │ └── post.js │ ├── middleware │ │ └── is-auth.js │ └── package.json └── README.md ├── 04 - Working with Dynamic Content & Adding Templating Engines ├── assignment │ ├── .gitignore │ ├── routes │ │ ├── main.js │ │ └── users.js │ ├── README.md │ ├── app.js │ ├── views │ │ ├── users.ejs │ │ └── index.ejs │ └── package.json ├── section-code │ ├── .gitignore │ ├── views │ │ ├── includes │ │ │ ├── end.ejs │ │ │ ├── head.ejs │ │ │ └── navigation.ejs │ │ ├── 404.pug │ │ ├── 404.ejs │ │ ├── add-product.hbs │ │ ├── add-product.pug │ │ ├── add-product.ejs │ │ ├── 404.hbs │ │ ├── 404.html │ │ └── layouts │ │ │ └── main-layout.pug │ ├── util │ │ └── path.js │ ├── public │ │ └── css │ │ │ ├── forms.css │ │ │ └── product.css │ ├── routes │ │ ├── shop.js │ │ └── admin.js │ ├── package.json │ └── app.js └── README.md ├── 01 - Understanding the Basics ├── assignment │ ├── app.js │ └── README.md └── section-code │ └── app.js ├── README.md └── 02 - Improved Development Workflow and Debugging └── section-code ├── app.js ├── package.json └── .vscode └── launch.json /06 - Enhancing the App/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /17 - Error Handling/section-code/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /03 - Working with Express.js/1 - assignment/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /03 - Working with Express.js/2 - assignment/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /03 - Working with Express.js/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/views/admin/edit-product.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/views/shop/checkout.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /22 - Working with REST APIs - The Basics/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/App.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/backend/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/App.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /03 - Working with Express.js/2 - assignment/public/css/style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | color: purple; 3 | } -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/assignment/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/backend/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/data/cart.json: -------------------------------------------------------------------------------- 1 | {"products":[{"id":"0.41607315815753076","qty":1}],"totalPrice":12} -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/data/cart.json: -------------------------------------------------------------------------------- 1 | {"products":[{"id":"0.41607315815753076","qty":1}],"totalPrice":12} -------------------------------------------------------------------------------- /17 - Error Handling/section-code/data/cart.json: -------------------------------------------------------------------------------- 1 | {"products":[{"id":"0.41607315815753076","qty":1}],"totalPrice":12} -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/data/cart.json: -------------------------------------------------------------------------------- 1 | {"products":[{"id":"0.41607315815753076","qty":1}],"totalPrice":12} -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/data/cart.json: -------------------------------------------------------------------------------- 1 | {"products":[{"id":"0.41607315815753076","qty":1}],"totalPrice":12} -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/data/cart.json: -------------------------------------------------------------------------------- 1 | {"products":[{"id":"0.41607315815753076","qty":1}],"totalPrice":12} -------------------------------------------------------------------------------- /17 - Error Handling/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/data/cart.json: -------------------------------------------------------------------------------- 1 | {"products":[{"id":"0.41607315815753076","qty":1}],"totalPrice":12} -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/data/cart.json: -------------------------------------------------------------------------------- 1 | {"products":[{"id":"0.41607315815753076","qty":1}],"totalPrice":12} -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/data/cart.json: -------------------------------------------------------------------------------- 1 | {"products":[{"id":"0.41607315815753076","qty":1}],"totalPrice":12} -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/views/includes/end.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /03 - Working with Express.js/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"title":"dffsa"},{"title":"Another"},{"title":"fasdfdas"},{"title":"Second Book"}] -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /11 - Working with Mongoose/README.md: -------------------------------------------------------------------------------- 1 | # Module Summary 2 | 3 | ## Useful Resources & Links 4 | 5 | - [Mongoose Official Docs](https://mongoosejs.com/docs/) 6 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/public/css/auth.css: -------------------------------------------------------------------------------- 1 | .login-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/public/css/auth.css: -------------------------------------------------------------------------------- 1 | .login-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/public/css/auth.css: -------------------------------------------------------------------------------- 1 | .login-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/public/css/auth.css: -------------------------------------------------------------------------------- 1 | .login-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/404.pug: -------------------------------------------------------------------------------- 1 | extends layouts/main-layout.pug 2 | 3 | block content 4 | h1 Page Not Found! -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/public/css/auth.css: -------------------------------------------------------------------------------- 1 | .login-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/public/css/auth.css: -------------------------------------------------------------------------------- 1 | .login-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/public/css/auth.css: -------------------------------------------------------------------------------- 1 | .login-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/index.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | body { 6 | font-family: sans-serif; 7 | } -------------------------------------------------------------------------------- /01 - Understanding the Basics/assignment/app.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | const { routesHandler } = require('./routes') 3 | 4 | http.createServer(routesHandler).listen(3000) -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/util/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = path.dirname(process.mainModule.filename); -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/index.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | body { 6 | font-family: sans-serif; 7 | } -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { pageTitle: 'Page Not Found' }); 3 | }; 4 | -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { pageTitle: 'Page Not Found', path: '/404' }); 3 | }; 4 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Image/Image.css: -------------------------------------------------------------------------------- 1 | .image { 2 | width: 100%; 3 | height: 100%; 4 | background-repeat: no-repeat; 5 | } -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Toolbar/Toolbar.css: -------------------------------------------------------------------------------- 1 | .toolbar { 2 | width: 100%; 3 | height: 3.5rem; 4 | background: #3b0062; 5 | } -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { pageTitle: 'Page Not Found', path: '/404' }); 3 | }; 4 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { pageTitle: 'Page Not Found', path: '/404' }); 3 | }; 4 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/middleware/is-auth.js: -------------------------------------------------------------------------------- 1 | module.exports = (req, res, next) => { 2 | if (!req.session.isLoggedIn) { 3 | return res.redirect('/login'); 4 | } 5 | next(); 6 | } -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Image/Image.css: -------------------------------------------------------------------------------- 1 | .image { 2 | width: 100%; 3 | height: 100%; 4 | background-repeat: no-repeat; 5 | } -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Toolbar/Toolbar.css: -------------------------------------------------------------------------------- 1 | .toolbar { 2 | width: 100%; 3 | height: 3.5rem; 4 | background: #3b0062; 5 | } -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/middleware/is-auth.js: -------------------------------------------------------------------------------- 1 | module.exports = (req, res, next) => { 2 | if (!req.session.isLoggedIn) { 3 | return res.redirect('/login'); 4 | } 5 | next(); 6 | } -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/middleware/is-auth.js: -------------------------------------------------------------------------------- 1 | module.exports = (req, res, next) => { 2 | if (!req.session.isLoggedIn) { 3 | return res.redirect('/login'); 4 | } 5 | next(); 6 | } -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/middleware/is-auth.js: -------------------------------------------------------------------------------- 1 | module.exports = (req, res, next) => { 2 | if (!req.session.isLoggedIn) { 3 | return res.redirect('/login'); 4 | } 5 | next(); 6 | } -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"}] -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/middleware/is-auth.js: -------------------------------------------------------------------------------- 1 | module.exports = (req, res, next) => { 2 | if (!req.session.isLoggedIn) { 3 | return res.redirect('/login'); 4 | } 5 | next(); 6 | } -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/views/shop/cart.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /17 - Error Handling/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/README.md: -------------------------------------------------------------------------------- 1 | # Module Summary 2 | 3 | ## Useful Resources & Links 4 | 5 | - [Async-await - More Details](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Image/Avatar.css: -------------------------------------------------------------------------------- 1 | .avatar { 2 | width: 10rem; 3 | height: 10rem; 4 | margin: 0.5rem auto; 5 | border-radius: 50%; 6 | overflow: hidden; 7 | } -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Logo/Logo.css: -------------------------------------------------------------------------------- 1 | .logo { 2 | font-size: 1rem; 3 | font-weight: bold; 4 | border: 1px solid white; 5 | padding: 0.5rem; 6 | color: white; 7 | } -------------------------------------------------------------------------------- /01 - Understanding the Basics/section-code/app.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | 3 | const routes = require('./routes') 4 | 5 | console.log(routes.someText) 6 | 7 | const server = http.createServer(routes.handler) 8 | 9 | server.listen(3000) -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/assignment/routes/main.js: -------------------------------------------------------------------------------- 1 | const router = require('express').Router() 2 | 3 | router.get('/', (req, res, next) => { 4 | res.render('index') 5 | }) 6 | 7 | module.exports = router 8 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/views/includes/add-to-cart.ejs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
-------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/views/includes/add-to-cart.ejs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
-------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiodietrich-zz/nodejs-the-complete-guide/HEAD/24 - Understanding Async Await in Node.js/assignment-code/frontend/public/favicon.ico -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/views/includes/add-to-cart.ejs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
-------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Image/Avatar.css: -------------------------------------------------------------------------------- 1 | .avatar { 2 | width: 10rem; 3 | height: 10rem; 4 | margin: 0.5rem auto; 5 | border-radius: 50%; 6 | overflow: hidden; 7 | } -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Logo/Logo.css: -------------------------------------------------------------------------------- 1 | .logo { 2 | font-size: 1rem; 3 | font-weight: bold; 4 | border: 1px solid white; 5 | padding: 0.5rem; 6 | color: white; 7 | } -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Logo/Logo.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Logo.css'; 4 | 5 | const logo = props =>

MessageNode

; 6 | 7 | export default logo; 8 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { 3 | pageTitle: 'Page Not Found', 4 | path: '/404', 5 | isAuthenticated: req.session.isLoggedIn 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { 3 | pageTitle: 'Page Not Found', 4 | path: '/404', 5 | isAuthenticated: req.session.isLoggedIn 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/views/includes/add-to-cart.ejs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
-------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { 3 | pageTitle: 'Page Not Found', 4 | path: '/404', 5 | isAuthenticated: req.session.isLoggedIn 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { 3 | pageTitle: 'Page Not Found', 4 | path: '/404', 5 | isAuthenticated: req.session.isLoggedIn 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { 3 | pageTitle: 'Page Not Found', 4 | path: '/404', 5 | isAuthenticated: req.session.isLoggedIn 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { 3 | pageTitle: 'Page Not Found', 4 | path: '/404', 5 | isAuthenticated: req.session.isLoggedIn 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Logo/Logo.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Logo.css'; 4 | 5 | const logo = props =>

MessageNode

; 6 | 7 | export default logo; 8 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/pages/Auth/Auth.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Auth.css'; 4 | 5 | const auth = props =>
{props.children}
; 6 | 7 | export default auth; 8 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/README.md: -------------------------------------------------------------------------------- 1 | # Module Summary 2 | 3 | ## Useful Resources & Links 4 | * [Pug Docs](https://pugjs.org/api/getting-started.html) 5 | * [Handlebars Docs](https://handlebarsjs.com/) 6 | * [EJS Docs](http://ejs.co/#docs) -------------------------------------------------------------------------------- /16 - Understanding Validation/README.md: -------------------------------------------------------------------------------- 1 | # Module Summary 2 | 3 | ## Useful Resources & Links 4 | 5 | - [Express-Validator Docs](https://express-validator.github.io/docs/) 6 | - [Validator.js (which is used behind the scenes) Docs](https://github.com/chriso/validator.js) 7 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiodietrich-zz/nodejs-the-complete-guide/HEAD/23 - Working with REST APIs - The Practical Application/assignment-code/frontend/public/favicon.ico -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/404.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Page Not Found!

7 | 8 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NodeJS - The Complete Guide (incl. MVC, REST APIs, GraphQL) 2 | 3 | This repository contains the algorithms, resources and documents used during the course: [NodeJS - The Complete Guide (incl. MVC, REST APIs, GraphQL)](https://www.udemy.com/nodejs-the-complete-guide/) -------------------------------------------------------------------------------- /02 - Improved Development Workflow and Debugging/section-code/app.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | 3 | const routes = require('./routes'); 4 | 5 | console.log(routes.someText); 6 | 7 | const server = http.createServer(routes.handler); 8 | 9 | server.listen(3000); 10 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/pages/Auth/Auth.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Auth.css'; 4 | 5 | const auth = props =>
{props.children}
; 6 | 7 | export default auth; 8 | -------------------------------------------------------------------------------- /03 - Working with Express.js/2 - assignment/routes/main.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | const router = require('express').Router() 4 | 5 | router.get('/', (req, res, next) => { 6 | res.sendFile(path.join(__dirname, '..', 'views', 'index.html')) 7 | }) 8 | 9 | module.exports = router -------------------------------------------------------------------------------- /03 - Working with Express.js/2 - assignment/routes/users.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | const router = require('express').Router() 4 | 5 | router.get('/users', (req, res, next) => { 6 | res.sendFile(path.join(__dirname, '..', 'views', 'users.html')) 7 | }) 8 | 9 | module.exports = router -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/views/shop/orders.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

Nothing there!

8 |
9 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /17 - Error Handling/section-code/views/500.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('includes/navigation.ejs') %> 6 |

Some error occurred!

7 |

We're working on fixing this, sorry for the inconvenience!

8 | 9 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /17 - Error Handling/section-code/views/includes/add-to-cart.ejs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
-------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/views/includes/add-to-cart.ejs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
-------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Toolbar/Toolbar.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Toolbar.css'; 4 | 5 | const toolbar = props => ( 6 |
7 | {props.children} 8 |
9 | ); 10 | 11 | export default toolbar; -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/views/includes/add-to-cart.ejs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
-------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/views/includes/add-to-cart.ejs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
-------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/views/includes/add-to-cart.ejs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
-------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/data/products.json: -------------------------------------------------------------------------------- 1 | [{"id":"123245","title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"},{"id":"0.41607315815753076","title":"fasfd","imageUrl":"fdasfs","description":"fadsfads","price":"12"}] -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"id":"123245","title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"},{"id":"0.41607315815753076","title":"fasfd","imageUrl":"fdasfs","description":"fadsfads","price":"12"}] -------------------------------------------------------------------------------- /17 - Error Handling/section-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"id":"123245","title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"},{"id":"0.41607315815753076","title":"fasfd","imageUrl":"fdasfs","description":"fadsfads","price":"12"}] -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Toolbar/Toolbar.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Toolbar.css'; 4 | 5 | const toolbar = props => ( 6 |
7 | {props.children} 8 |
9 | ); 10 | 11 | export default toolbar; -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/assignment/README.md: -------------------------------------------------------------------------------- 1 | # Assignment 2 | 1. Create a npm project and install Express.js (Nodemon if you want) and EJS. 3 | 4 | 2. Add two routes: 5 | * '/' => Holds a form that allows uers to input their name 6 | * '/users' => Outputs an ul with the user names (or some error text) -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/assignment/routes/users.js: -------------------------------------------------------------------------------- 1 | const router = require('express').Router() 2 | 3 | const users = ['a', 'b'] 4 | 5 | router.post('/users', (req, res, next) => { 6 | users.push(req.body.name) 7 | res.render('users', { users }) 8 | }) 9 | 10 | module.exports = router 11 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"id":"123245","title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"},{"id":"0.41607315815753076","title":"fasfd","imageUrl":"fdasfs","description":"fadsfads","price":"12"}] -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"id":"123245","title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"},{"id":"0.41607315815753076","title":"fasfd","imageUrl":"fdasfs","description":"fadsfads","price":"12"}] -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"id":"123245","title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"},{"id":"0.41607315815753076","title":"fasfd","imageUrl":"fdasfs","description":"fadsfads","price":"12"}] -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"id":"123245","title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"},{"id":"0.41607315815753076","title":"fasfd","imageUrl":"fdasfs","description":"fadsfads","price":"12"}] -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"id":"123245","title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"},{"id":"0.41607315815753076","title":"fasfd","imageUrl":"fdasfs","description":"fadsfads","price":"12"}] -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Backdrop/Backdrop.css: -------------------------------------------------------------------------------- 1 | .backdrop { 2 | width: 100%; 3 | height: 100vh; 4 | background: rgba(0, 0, 0, 0.75); 5 | z-index: 100; 6 | position: fixed; 7 | left: 0; 8 | top: 0; 9 | transition: opacity 0.3s ease-out; 10 | opacity: 1; 11 | } 12 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/routes/auth.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const authController = require('../controllers/auth'); 4 | 5 | const router = express.Router(); 6 | 7 | router.get('/login', authController.getLogin); 8 | 9 | router.post('/login', authController.postLogin); 10 | 11 | module.exports = router; -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/data/products.json: -------------------------------------------------------------------------------- 1 | [{"id":"123245","title":"A Book","imageUrl":"https://www.publicdomainpictures.net/pictures/10000/velka/1-1210009435EGmE.jpg","description":"This is an awesome book!","price":"19"},{"id":"0.41607315815753076","title":"fasfd","imageUrl":"fdasfs","description":"fadsfads","price":"12"}] -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Loader/Loader.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Loader.css'; 4 | 5 | const loader = props => ( 6 |
7 |
8 |
9 |
10 |
11 |
12 | ); 13 | 14 | export default loader; 15 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const productsController = require('../controllers/products'); 6 | 7 | const router = express.Router(); 8 | 9 | router.get('/', productsController.getProducts); 10 | 11 | module.exports = router; 12 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Backdrop/Backdrop.css: -------------------------------------------------------------------------------- 1 | .backdrop { 2 | width: 100%; 3 | height: 100vh; 4 | background: rgba(0, 0, 0, 0.75); 5 | z-index: 100; 6 | position: fixed; 7 | left: 0; 8 | top: 0; 9 | transition: opacity 0.3s ease-out; 10 | opacity: 1; 11 | } 12 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/pages/Auth/Auth.css: -------------------------------------------------------------------------------- 1 | .auth-form { 2 | width: 90%; 3 | margin: auto; 4 | padding: 1rem; 5 | border: 1px solid #3b0062; 6 | border-radius: 5px; 7 | } 8 | 9 | @media (min-width: 768px) { 10 | .auth-form { 11 | width: 40rem; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Loader/Loader.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Loader.css'; 4 | 5 | const loader = props => ( 6 |
7 |
8 |
9 |
10 |
11 |
12 | ); 13 | 14 | export default loader; 15 | -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/pages/Auth/Auth.css: -------------------------------------------------------------------------------- 1 | .auth-form { 2 | width: 90%; 3 | margin: auto; 4 | padding: 1rem; 5 | border: 1px solid #3b0062; 6 | border-radius: 5px; 7 | } 8 | 9 | @media (min-width: 768px) { 10 | .auth-form { 11 | width: 40rem; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /03 - Working with Express.js/2 - assignment/README.md: -------------------------------------------------------------------------------- 1 | # Assignment 2 | 1. Create a npm project and install Express.js (Nodemon if you want). 3 | 4 | 2. Create an Express.js app which servers two HTML files (of your choice / with your content) for '/' and '/users'. 5 | 6 | 3. Add sine static (.js or .css) files to your project that should be required by at least one of your HTML files. -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /03 - Working with Express.js/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const rootDir = require('../util/path'); 6 | 7 | const router = express.Router(); 8 | 9 | router.get('/', (req, res, next) => { 10 | res.sendFile(path.join(rootDir, 'views', 'shop.html')); 11 | }); 12 | 13 | module.exports = router; 14 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/routes/auth.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const authController = require('../controllers/auth'); 4 | 5 | const router = express.Router(); 6 | 7 | router.get('/login', authController.getLogin); 8 | 9 | router.post('/login', authController.postLogin); 10 | 11 | router.post('/logout', authController.postLogout); 12 | 13 | module.exports = router; -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Layout/Layout.css: -------------------------------------------------------------------------------- 1 | .main-header { 2 | width: 100%; 3 | position: fixed; 4 | left: 0; 5 | top: 0; 6 | } 7 | 8 | .content { 9 | margin-top: 3.5rem; 10 | padding: 1rem; 11 | } 12 | 13 | @media (min-width: 768px) { 14 | .content { 15 | margin-top: 3.5rem; 16 | padding: 1rem 2rem; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /03 - Working with Express.js/2 - assignment/app.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | const express = require('express') 4 | 5 | const mainRouter = require('./routes/main') 6 | const usersRouter = require('./routes/users') 7 | 8 | const app = express() 9 | 10 | app.use(express.static(path.join(__dirname, 'public'))) 11 | 12 | app.use(mainRouter) 13 | app.use(usersRouter) 14 | 15 | app.listen(3000) -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/includes/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= pageTitle %> 9 | -------------------------------------------------------------------------------- /22 - Working with REST APIs - The Basics/section-code/routes/feed.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const feedController = require('../controllers/feed'); 4 | 5 | const router = express.Router(); 6 | 7 | // GET /feed/posts 8 | router.get('/posts', feedController.getPosts); 9 | 10 | // POST /feed/post 11 | router.post('/post', feedController.createPost); 12 | 13 | module.exports = router; -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Layout/Layout.css: -------------------------------------------------------------------------------- 1 | .main-header { 2 | width: 100%; 3 | position: fixed; 4 | left: 0; 5 | top: 0; 6 | } 7 | 8 | .content { 9 | margin-top: 3.5rem; 10 | padding: 1rem; 11 | } 12 | 13 | @media (min-width: 768px) { 14 | .content { 15 | margin-top: 3.5rem; 16 | padding: 1rem 2rem; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/util/image.js: -------------------------------------------------------------------------------- 1 | export const generateBase64FromImage = imageFile => { 2 | const reader = new FileReader(); 3 | const promise = new Promise((resolve, reject) => { 4 | reader.onload = e => resolve(e.target.result); 5 | reader.onerror = err => reject(err); 6 | }); 7 | 8 | reader.readAsDataURL(imageFile); 9 | return promise; 10 | }; 11 | -------------------------------------------------------------------------------- /03 - Working with Express.js/2 - assignment/views/users.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 |

Users

12 | 13 | -------------------------------------------------------------------------------- /03 - Working with Express.js/2 - assignment/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Index 8 | 9 | 10 | 11 |

Hello from Express!

12 | 13 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/util/image.js: -------------------------------------------------------------------------------- 1 | export const generateBase64FromImage = imageFile => { 2 | const reader = new FileReader(); 3 | const promise = new Promise((resolve, reject) => { 4 | reader.onload = e => resolve(e.target.result); 5 | reader.onerror = err => reject(err); 6 | }); 7 | 8 | reader.readAsDataURL(imageFile); 9 | return promise; 10 | }; 11 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Layout/Layout.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment } from 'react'; 2 | 3 | import './Layout.css'; 4 | 5 | const layout = props => ( 6 | 7 |
{props.header}
8 | {props.mobileNav} 9 |
{props.children}
10 |
11 | ); 12 | 13 | export default layout; 14 | -------------------------------------------------------------------------------- /03 - Working with Express.js/1 - assignment/README.md: -------------------------------------------------------------------------------- 1 | # Assignment 2 | 1. Create a npm project and install Express.js (Nodemon if you want). 3 | 4 | 2. Create an Express.js app which funnels the request through 2 middleware functions that log something to the console and return one response. 5 | 6 | 3. Handle requests to '/' and '/users' such that each request only has one handlers / middleware that does something eith it (e.g. send dummy response) 7 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/add-product.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 | 6 |
7 | 8 | 9 |
10 |
-------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Image/Avatar.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Image from './Image'; 4 | import './Avatar.css'; 5 | 6 | const avatar = props => ( 7 |
11 | 12 |
13 | ); 14 | 15 | export default avatar; 16 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Layout/Layout.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment } from 'react'; 2 | 3 | import './Layout.css'; 4 | 5 | const layout = props => ( 6 | 7 |
{props.header}
8 | {props.mobileNav} 9 |
{props.children}
10 |
11 | ); 12 | 13 | export default layout; 14 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Image/Avatar.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Image from './Image'; 4 | import './Avatar.css'; 5 | 6 | const avatar = props => ( 7 |
11 | 12 |
13 | ); 14 | 15 | export default avatar; 16 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /03 - Working with Express.js/1 - assignment/app.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | 3 | const app = express() 4 | 5 | app.use((req, res, next) =>{ 6 | console.log('first middleware') 7 | next() 8 | }) 9 | 10 | app.use('/users', (req, res, next) => { 11 | res.send('

Users

') 12 | }) 13 | 14 | app.use((req, res, next) =>{ 15 | console.log('second middleware') 16 | res.send('

Hello from Express.js

') 17 | }) 18 | 19 | app.listen(3000) -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input { 7 | display: block; 8 | width: 100%; 9 | margin-bottom: 0.25rem; 10 | } 11 | 12 | .form-control input { 13 | border: 1px solid #a1a1a1; 14 | font: inherit; 15 | border-radius: 2px; 16 | } 17 | 18 | .form-control input:focus { 19 | outline-color: #00695c; 20 | } 21 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/controllers/error.js: -------------------------------------------------------------------------------- 1 | exports.get404 = (req, res, next) => { 2 | res.status(404).render('404', { 3 | pageTitle: 'Page Not Found', 4 | path: '/404', 5 | isAuthenticated: req.session.isLoggedIn 6 | }); 7 | }; 8 | 9 | exports.get500 = (req, res, next) => { 10 | res.status(500).render('500', { 11 | pageTitle: 'Error!', 12 | path: '/500', 13 | isAuthenticated: req.session.isLoggedIn 14 | }); 15 | }; 16 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /01 - Understanding the Basics/assignment/README.md: -------------------------------------------------------------------------------- 1 | # Assignment 2 | ## 1. Spin up a Node.js server (on port 3000) 3 | 4 | ## 2. Handle two Routes: “/” and “/users” 5 | * Return some greeting text on “/” 6 | * Return a list of dummy users on "/users" 7 | 8 | ## 3. Add a form with a “username” input to the “/” page and submit a POST request to “/create-user” upon a button click 9 | 10 | ## 4. Add the “/create-user” route and parse the incoming data and simply log it to the console 11 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Image/Image.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Image.css'; 4 | 5 | const image = props => ( 6 |
14 | ); 15 | 16 | export default image; 17 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input { 7 | display: block; 8 | width: 100%; 9 | margin-bottom: 0.25rem; 10 | } 11 | 12 | .form-control input { 13 | border: 1px solid #a1a1a1; 14 | font: inherit; 15 | border-radius: 2px; 16 | } 17 | 18 | .form-control input:focus { 19 | outline-color: #00695c; 20 | } 21 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Backdrop/Backdrop.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | 4 | import './Backdrop.css'; 5 | 6 | const backdrop = props => 7 | ReactDOM.createPortal( 8 |
, 12 | document.getElementById('backdrop-root') 13 | ); 14 | 15 | export default backdrop; 16 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/views/includes/navigation.ejs: -------------------------------------------------------------------------------- 1 |
2 | 8 |
-------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Image/Image.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Image.css'; 4 | 5 | const image = props => ( 6 |
14 | ); 15 | 16 | export default image; 17 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Navigation/MobileToggle/MobileToggle.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './MobileToggle.css'; 4 | 5 | const mobileToggle = props => ( 6 | 11 | ); 12 | 13 | export default mobileToggle; 14 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/assignment/app.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const bodyParser = require('body-parser') 3 | 4 | const app = express() 5 | 6 | const mainRoutes = require('./routes/main') 7 | const userRoutes = require('./routes/users') 8 | 9 | app.set('view engine', 'ejs') 10 | app.set('views', './views') 11 | 12 | app.use(bodyParser.urlencoded({ extended: false })) 13 | 14 | app.use(mainRoutes) 15 | app.use(userRoutes) 16 | 17 | app.listen(3000) -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const productsController = require('../controllers/products'); 6 | 7 | const router = express.Router(); 8 | 9 | // /admin/add-product => GET 10 | router.get('/add-product', productsController.getAddProduct); 11 | 12 | // /admin/add-product => POST 13 | router.post('/add-product', productsController.postAddProduct); 14 | 15 | module.exports = router; 16 | -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | } 6 | 7 | .product-item { 8 | width: 20rem; 9 | max-width: 95%; 10 | } 11 | 12 | .product__title { 13 | font-size: 1.2rem; 14 | text-align: center; 15 | } 16 | 17 | .product__price { 18 | text-align: center; 19 | color: #4d4d4d; 20 | margin-bottom: 0.5rem; 21 | } 22 | 23 | .product__description { 24 | text-align: center; 25 | } -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Backdrop/Backdrop.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | 4 | import './Backdrop.css'; 5 | 6 | const backdrop = props => 7 | ReactDOM.createPortal( 8 |
, 12 | document.getElementById('backdrop-root') 13 | ); 14 | 15 | export default backdrop; 16 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Navigation/MainNavigation/MainNavigation.css: -------------------------------------------------------------------------------- 1 | .main-nav { 2 | height: 100%; 3 | padding: 0 1rem; 4 | display: flex; 5 | align-items: center; 6 | } 7 | 8 | .spacer { 9 | flex: 1; 10 | } 11 | 12 | .main-nav__items { 13 | list-style: none; 14 | padding: 0; 15 | margin: 0 1.5rem; 16 | display: none; 17 | } 18 | 19 | @media (min-width: 768px) { 20 | .main-nav__items { 21 | display: flex; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Navigation/MobileToggle/MobileToggle.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './MobileToggle.css'; 4 | 5 | const mobileToggle = props => ( 6 | 11 | ); 12 | 13 | export default mobileToggle; 14 | -------------------------------------------------------------------------------- /02 - Improved Development Workflow and Debugging/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "Complete Node.js Guide", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js", 9 | "start-server": "node app.js" 10 | }, 11 | "author": "Maximilian Schwarzmüller", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "nodemon": "^1.18.3" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | } 6 | 7 | .product-item { 8 | width: 20rem; 9 | max-width: 95%; 10 | } 11 | 12 | .product__title { 13 | font-size: 1.2rem; 14 | text-align: center; 15 | } 16 | 17 | .product__price { 18 | text-align: center; 19 | color: #4d4d4d; 20 | margin-bottom: 0.5rem; 21 | } 22 | 23 | .product__description { 24 | text-align: center; 25 | } -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/routes/auth.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const authController = require('../controllers/auth'); 4 | 5 | const router = express.Router(); 6 | 7 | router.get('/login', authController.getLogin); 8 | 9 | router.get('/signup', authController.getSignup); 10 | 11 | router.post('/login', authController.postLogin); 12 | 13 | router.post('/signup', authController.postSignup); 14 | 15 | router.post('/logout', authController.postLogout); 16 | 17 | module.exports = router; -------------------------------------------------------------------------------- /15 - Advanced Authentication/README.md: -------------------------------------------------------------------------------- 1 | # Module Summary 2 | 3 | ## Password Resetting 4 | 5 | - Password reseting has to be implemented in a way that prevents users from resetting random users accounts 6 | - Reset tokens have to be a random, unguessable and unique 7 | 8 | ## Authorization 9 | 10 | - Authorization is an important part of pretty much every app 11 | - Not every authenticated user should be able to do everything 12 | - Istead, you want to lock down access by restricting the permissions of your users 13 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Navigation/MainNavigation/MainNavigation.css: -------------------------------------------------------------------------------- 1 | .main-nav { 2 | height: 100%; 3 | padding: 0 1rem; 4 | display: flex; 5 | align-items: center; 6 | } 7 | 8 | .spacer { 9 | flex: 1; 10 | } 11 | 12 | .main-nav__items { 13 | list-style: none; 14 | padding: 0; 15 | margin: 0 1.5rem; 16 | display: none; 17 | } 18 | 19 | @media (min-width: 768px) { 20 | .main-nav__items { 21 | display: flex; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/includes/navigation.ejs: -------------------------------------------------------------------------------- 1 |
2 | 8 |
-------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | -------------------------------------------------------------------------------- /03 - Working with Express.js/1 - assignment/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "assignment", 3 | "version": "1.0.0", 4 | "description": "1. Create a npm project and install Express.js (Nodemon if you want).", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon app.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.16.4" 14 | }, 15 | "devDependencies": { 16 | "nodemon": "^1.18.9" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /03 - Working with Express.js/2 - assignment/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "assignment", 3 | "version": "1.0.0", 4 | "description": "1. Create a npm project and install Express.js (Nodemon if you want).", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon app.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.16.4" 14 | }, 15 | "devDependencies": { 16 | "nodemon": "^1.18.9" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/assignment/views/users.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | <% if (users.length) {%> 11 |
    12 | <% users.forEach(user => { %> 13 |
  • <%= user %>
  • 14 | <% }) %> 15 |
16 | <% } %> 17 | 18 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | } 6 | 7 | .product-item { 8 | width: 20rem; 9 | max-width: 95%; 10 | } 11 | 12 | .product__title { 13 | font-size: 1.2rem; 14 | text-align: center; 15 | } 16 | 17 | .product__price { 18 | text-align: center; 19 | color: #4d4d4d; 20 | margin-bottom: 0.5rem; 21 | } 22 | 23 | .product__description { 24 | text-align: center; 25 | } -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/public/css/cart.css: -------------------------------------------------------------------------------- 1 | .cart__item-list { 2 | list-style: none; 3 | margin: 0; 4 | padding: 0; 5 | margin: auto; 6 | width: 40rem; 7 | max-width: 90%; 8 | } 9 | 10 | .cart__item { 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | padding: 1rem; 15 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 16 | margin-bottom: 1rem; 17 | } 18 | 19 | .cart__item h1, 20 | .cart__item h2 { 21 | margin-right: 1rem; 22 | font-size: 1.2rem; 23 | margin: 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | 8 | .product-item { 9 | width: 20rem; 10 | max-width: 95%; 11 | margin: 1rem; 12 | } 13 | 14 | .product__title { 15 | font-size: 1.2rem; 16 | text-align: center; 17 | } 18 | 19 | .product__price { 20 | text-align: center; 21 | color: #4d4d4d; 22 | margin-bottom: 0.5rem; 23 | } 24 | 25 | .product__description { 26 | text-align: center; 27 | } -------------------------------------------------------------------------------- /17 - Error Handling/section-code/public/css/cart.css: -------------------------------------------------------------------------------- 1 | .cart__item-list { 2 | list-style: none; 3 | margin: 0; 4 | padding: 0; 5 | margin: auto; 6 | width: 40rem; 7 | max-width: 90%; 8 | } 9 | 10 | .cart__item { 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | padding: 1rem; 15 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 16 | margin-bottom: 1rem; 17 | } 18 | 19 | .cart__item h1, 20 | .cart__item h2 { 21 | margin-right: 1rem; 22 | font-size: 1.2rem; 23 | margin: 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | 8 | .product-item { 9 | width: 20rem; 10 | max-width: 95%; 11 | margin: 1rem; 12 | } 13 | 14 | .product__title { 15 | font-size: 1.2rem; 16 | text-align: center; 17 | } 18 | 19 | .product__price { 20 | text-align: center; 21 | color: #4d4d4d; 22 | margin-bottom: 0.5rem; 23 | } 24 | 25 | .product__description { 26 | text-align: center; 27 | } -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/add-product.pug: -------------------------------------------------------------------------------- 1 | extends layouts/main-layout.pug 2 | 3 | block styles 4 | link(rel="stylesheet", href="/css/forms.css") 5 | link(rel="stylesheet", href="/css/product.css") 6 | 7 | block content 8 | main 9 | form.product-form(action="/admin/add-product", method="POST") 10 | .form-control 11 | label(for="title") Title 12 | input(type="text", name="title")#title 13 | button.btn(type="submit") Add Product -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/public/css/cart.css: -------------------------------------------------------------------------------- 1 | .cart__item-list { 2 | list-style: none; 3 | margin: 0; 4 | padding: 0; 5 | margin: auto; 6 | width: 40rem; 7 | max-width: 90%; 8 | } 9 | 10 | .cart__item { 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | padding: 1rem; 15 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 16 | margin-bottom: 1rem; 17 | } 18 | 19 | .cart__item h1, 20 | .cart__item h2 { 21 | margin-right: 1rem; 22 | font-size: 1.2rem; 23 | margin: 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | 8 | .product-item { 9 | width: 20rem; 10 | max-width: 95%; 11 | margin: 1rem; 12 | } 13 | 14 | .product__title { 15 | font-size: 1.2rem; 16 | text-align: center; 17 | } 18 | 19 | .product__price { 20 | text-align: center; 21 | color: #4d4d4d; 22 | margin-bottom: 0.5rem; 23 | } 24 | 25 | .product__description { 26 | text-align: center; 27 | } -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/public/css/cart.css: -------------------------------------------------------------------------------- 1 | .cart__item-list { 2 | list-style: none; 3 | margin: 0; 4 | padding: 0; 5 | margin: auto; 6 | width: 40rem; 7 | max-width: 90%; 8 | } 9 | 10 | .cart__item { 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | padding: 1rem; 15 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 16 | margin-bottom: 1rem; 17 | } 18 | 19 | .cart__item h1, 20 | .cart__item h2 { 21 | margin-right: 1rem; 22 | font-size: 1.2rem; 23 | margin: 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | 8 | .product-item { 9 | width: 20rem; 10 | max-width: 95%; 11 | margin: 1rem; 12 | } 13 | 14 | .product__title { 15 | font-size: 1.2rem; 16 | text-align: center; 17 | } 18 | 19 | .product__price { 20 | text-align: center; 21 | color: #4d4d4d; 22 | margin-bottom: 0.5rem; 23 | } 24 | 25 | .product__description { 26 | text-align: center; 27 | } -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/public/css/cart.css: -------------------------------------------------------------------------------- 1 | .cart__item-list { 2 | list-style: none; 3 | margin: 0; 4 | padding: 0; 5 | margin: auto; 6 | width: 40rem; 7 | max-width: 90%; 8 | } 9 | 10 | .cart__item { 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | padding: 1rem; 15 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 16 | margin-bottom: 1rem; 17 | } 18 | 19 | .cart__item h1, 20 | .cart__item h2 { 21 | margin-right: 1rem; 22 | font-size: 1.2rem; 23 | margin: 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | 8 | .product-item { 9 | width: 20rem; 10 | max-width: 95%; 11 | margin: 1rem; 12 | } 13 | 14 | .product__title { 15 | font-size: 1.2rem; 16 | text-align: center; 17 | } 18 | 19 | .product__price { 20 | text-align: center; 21 | color: #4d4d4d; 22 | margin-bottom: 0.5rem; 23 | } 24 | 25 | .product__description { 26 | text-align: center; 27 | } -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/pages/Feed/Feed.css: -------------------------------------------------------------------------------- 1 | .feed__status { 2 | width: 90%; 3 | margin: 1rem auto; 4 | } 5 | 6 | .feed__status form { 7 | display: flex; 8 | align-items: center; 9 | } 10 | 11 | .feed__status form * { 12 | margin: 0 0.5rem; 13 | } 14 | 15 | .feed__control { 16 | text-align: center; 17 | } 18 | 19 | .new-post__preview-image { 20 | width: 15rem; 21 | height: 7rem; 22 | } 23 | 24 | @media (min-width: 768px) { 25 | .feed__status { 26 | width: 30rem; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | 7 | const router = express.Router(); 8 | 9 | router.get('/', shopController.getIndex); 10 | 11 | router.get('/products', shopController.getProducts); 12 | 13 | router.get('/cart', shopController.getCart); 14 | 15 | router.get('/orders', shopController.getOrders); 16 | 17 | router.get('/checkout', shopController.getCheckout); 18 | 19 | module.exports = router; 20 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/public/css/cart.css: -------------------------------------------------------------------------------- 1 | .cart__item-list { 2 | list-style: none; 3 | margin: 0; 4 | padding: 0; 5 | margin: auto; 6 | width: 40rem; 7 | max-width: 90%; 8 | } 9 | 10 | .cart__item { 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | padding: 1rem; 15 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 16 | margin-bottom: 1rem; 17 | } 18 | 19 | .cart__item h1, 20 | .cart__item h2 { 21 | margin-right: 1rem; 22 | font-size: 1.2rem; 23 | margin: 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | 8 | .product-item { 9 | width: 20rem; 10 | max-width: 95%; 11 | margin: 1rem; 12 | } 13 | 14 | .product__title { 15 | font-size: 1.2rem; 16 | text-align: center; 17 | } 18 | 19 | .product__price { 20 | text-align: center; 21 | color: #4d4d4d; 22 | margin-bottom: 0.5rem; 23 | } 24 | 25 | .product__description { 26 | text-align: center; 27 | } -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/public/css/cart.css: -------------------------------------------------------------------------------- 1 | .cart__item-list { 2 | list-style: none; 3 | margin: 0; 4 | padding: 0; 5 | margin: auto; 6 | width: 40rem; 7 | max-width: 90%; 8 | } 9 | 10 | .cart__item { 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | padding: 1rem; 15 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 16 | margin-bottom: 1rem; 17 | } 18 | 19 | .cart__item h1, 20 | .cart__item h2 { 21 | margin-right: 1rem; 22 | font-size: 1.2rem; 23 | margin: 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | 8 | .product-item { 9 | width: 20rem; 10 | max-width: 95%; 11 | margin: 1rem; 12 | } 13 | 14 | .product__title { 15 | font-size: 1.2rem; 16 | text-align: center; 17 | } 18 | 19 | .product__price { 20 | text-align: center; 21 | color: #4d4d4d; 22 | margin-bottom: 0.5rem; 23 | } 24 | 25 | .product__description { 26 | text-align: center; 27 | } -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/public/css/cart.css: -------------------------------------------------------------------------------- 1 | .cart__item-list { 2 | list-style: none; 3 | margin: 0; 4 | padding: 0; 5 | margin: auto; 6 | width: 40rem; 7 | max-width: 90%; 8 | } 9 | 10 | .cart__item { 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | padding: 1rem; 15 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 16 | margin-bottom: 1rem; 17 | } 18 | 19 | .cart__item h1, 20 | .cart__item h2 { 21 | margin-right: 1rem; 22 | font-size: 1.2rem; 23 | margin: 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | 8 | .product-item { 9 | width: 20rem; 10 | max-width: 95%; 11 | margin: 1rem; 12 | } 13 | 14 | .product__title { 15 | font-size: 1.2rem; 16 | text-align: center; 17 | } 18 | 19 | .product__price { 20 | text-align: center; 21 | color: #4d4d4d; 22 | margin-bottom: 0.5rem; 23 | } 24 | 25 | .product__description { 26 | text-align: center; 27 | } -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/pages/Feed/Feed.css: -------------------------------------------------------------------------------- 1 | .feed__status { 2 | width: 90%; 3 | margin: 1rem auto; 4 | } 5 | 6 | .feed__status form { 7 | display: flex; 8 | align-items: center; 9 | } 10 | 11 | .feed__status form * { 12 | margin: 0 0.5rem; 13 | } 14 | 15 | .feed__control { 16 | text-align: center; 17 | } 18 | 19 | .new-post__preview-image { 20 | width: 15rem; 21 | height: 7rem; 22 | } 23 | 24 | @media (min-width: 768px) { 25 | .feed__status { 26 | width: 30rem; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/public/css/cart.css: -------------------------------------------------------------------------------- 1 | .cart__item-list { 2 | list-style: none; 3 | margin: 0; 4 | padding: 0; 5 | margin: auto; 6 | width: 40rem; 7 | max-width: 90%; 8 | } 9 | 10 | .cart__item { 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | padding: 1rem; 15 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 16 | margin-bottom: 1rem; 17 | } 18 | 19 | .cart__item h1, 20 | .cart__item h2 { 21 | margin-right: 1rem; 22 | font-size: 1.2rem; 23 | margin: 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | display: block; 6 | } 7 | 8 | .product-item { 9 | width: 20rem; 10 | max-width: 95%; 11 | margin: 1rem; 12 | } 13 | 14 | .product__title { 15 | font-size: 1.2rem; 16 | text-align: center; 17 | } 18 | 19 | .product__price { 20 | text-align: center; 21 | color: #4d4d4d; 22 | margin-bottom: 0.5rem; 23 | } 24 | 25 | .product__description { 26 | text-align: center; 27 | } -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/controllers/auth.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/user'); 2 | 3 | exports.getLogin = (req, res, next) => { 4 | res.render('auth/login', { 5 | path: '/login', 6 | pageTitle: 'Login', 7 | isAuthenticated: false 8 | }); 9 | }; 10 | 11 | exports.postLogin = (req, res, next) => { 12 | User.findById('5bab316ce0a7c75f783cb8a8') 13 | .then(user => { 14 | req.session.isLoggedIn = true; 15 | req.session.user = user; 16 | res.redirect('/'); 17 | }) 18 | .catch(err => console.log(err)); 19 | }; 20 | -------------------------------------------------------------------------------- /22 - Working with REST APIs - The Basics/section-code/controllers/feed.js: -------------------------------------------------------------------------------- 1 | exports.getPosts = (req, res, next) => { 2 | res.status(200).json({ 3 | posts: [{ title: 'First Post', content: 'This is the first post!' }] 4 | }); 5 | }; 6 | 7 | exports.createPost = (req, res, next) => { 8 | const title = req.body.title; 9 | const content = req.body.content; 10 | // Create post in db 11 | res.status(201).json({ 12 | message: 'Post created successfully!', 13 | post: { id: new Date().toISOString(), title: title, content: content } 14 | }); 15 | }; 16 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/pages/Feed/SinglePost/SinglePost.css: -------------------------------------------------------------------------------- 1 | .single-post { 2 | width: 90%; 3 | margin: auto; 4 | text-align: center; 5 | color: #3b0062; 6 | } 7 | 8 | .single-post h2 { 9 | font-size: 1rem; 10 | color: #464646; 11 | padding-bottom: 1rem; 12 | border-bottom: 2px solid #464646; 13 | } 14 | 15 | .single-post__image { 16 | height: 20rem; 17 | width: 20rem; 18 | margin: 1rem auto; 19 | } 20 | 21 | @media (min-width: 768px) { 22 | .single-post { 23 | width: 40rem; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const adminController = require('../controllers/admin'); 6 | 7 | const router = express.Router(); 8 | 9 | // /admin/add-product => GET 10 | router.get('/add-product', adminController.getAddProduct); 11 | 12 | // /admin/products => GET 13 | router.get('/products', adminController.getProducts); 14 | 15 | // /admin/add-product => POST 16 | router.post('/add-product', adminController.postAddProduct); 17 | 18 | module.exports = router; 19 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/assignment/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 12 | 13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/pages/Feed/SinglePost/SinglePost.css: -------------------------------------------------------------------------------- 1 | .single-post { 2 | width: 90%; 3 | margin: auto; 4 | text-align: center; 5 | color: #3b0062; 6 | } 7 | 8 | .single-post h2 { 9 | font-size: 1rem; 10 | color: #464646; 11 | padding-bottom: 1rem; 12 | border-bottom: 2px solid #464646; 13 | } 14 | 15 | .single-post__image { 16 | height: 20rem; 17 | width: 20rem; 18 | margin: 1rem auto; 19 | } 20 | 21 | @media (min-width: 768px) { 22 | .single-post { 23 | width: 40rem; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /03 - Working with Express.js/section-code/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const rootDir = require('../util/path'); 6 | 7 | const router = express.Router(); 8 | 9 | // /admin/add-product => GET 10 | router.get('/add-product', (req, res, next) => { 11 | res.sendFile(path.join(rootDir, 'views', 'add-product.html')); 12 | }); 13 | 14 | // /admin/add-product => POST 15 | router.post('/add-product', (req, res, next) => { 16 | console.log(req.body); 17 | res.redirect('/'); 18 | }); 19 | 20 | module.exports = router; 21 | -------------------------------------------------------------------------------- /03 - Working with Express.js/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "Complete Node.js Guide", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js", 9 | "start-server": "node app.js" 10 | }, 11 | "author": "Maximilian Schwarzmüller", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "nodemon": "^1.18.3" 15 | }, 16 | "dependencies": { 17 | "body-parser": "^1.18.3", 18 | "express": "^4.16.3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/public/css/orders.css: -------------------------------------------------------------------------------- 1 | .orders { 2 | list-style: none; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | .orders__item h1 { 8 | margin: 0; 9 | font-size: 1rem; 10 | } 11 | 12 | .orders__item { 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | padding: 1rem; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .orders__products { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | .orders__products-item { 25 | margin: 0.5rem 0; 26 | padding: 0.5rem; 27 | border: 1px solid #00695c; 28 | color: #00695c; 29 | } 30 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/public/css/orders.css: -------------------------------------------------------------------------------- 1 | .orders { 2 | list-style: none; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | .orders__item h1 { 8 | margin: 0; 9 | font-size: 1rem; 10 | } 11 | 12 | .orders__item { 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | padding: 1rem; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .orders__products { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | .orders__products-item { 25 | margin: 0.5rem 0; 26 | padding: 0.5rem; 27 | border: 1px solid #00695c; 28 | color: #00695c; 29 | } 30 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/public/css/orders.css: -------------------------------------------------------------------------------- 1 | .orders { 2 | list-style: none; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | .orders__item h1 { 8 | margin: 0; 9 | font-size: 1rem; 10 | } 11 | 12 | .orders__item { 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | padding: 1rem; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .orders__products { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | .orders__products-item { 25 | margin: 0.5rem 0; 26 | padding: 0.5rem; 27 | border: 1px solid #00695c; 28 | color: #00695c; 29 | } 30 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Navigation/MobileToggle/MobileToggle.css: -------------------------------------------------------------------------------- 1 | .mobile-toggle { 2 | background: transparent; 3 | border: none; 4 | display: flex; 5 | width: 2.5rem; 6 | height: 80%; 7 | flex-direction: column; 8 | justify-content: space-evenly; 9 | cursor: pointer; 10 | padding: 0; 11 | margin-right: 1rem; 12 | } 13 | 14 | .mobile-toggle__bar { 15 | width: 2.5rem; 16 | height: 4px; 17 | background: white; 18 | } 19 | 20 | @media (min-width: 768px) { 21 | .mobile-toggle { 22 | display: none; 23 | } 24 | } -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/public/css/orders.css: -------------------------------------------------------------------------------- 1 | .orders { 2 | list-style: none; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | .orders__item h1 { 8 | margin: 0; 9 | font-size: 1rem; 10 | } 11 | 12 | .orders__item { 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | padding: 1rem; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .orders__products { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | .orders__products-item { 25 | margin: 0.5rem 0; 26 | padding: 0.5rem; 27 | border: 1px solid #00695c; 28 | color: #00695c; 29 | } 30 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/public/css/orders.css: -------------------------------------------------------------------------------- 1 | .orders { 2 | list-style: none; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | .orders__item h1 { 8 | margin: 0; 9 | font-size: 1rem; 10 | } 11 | 12 | .orders__item { 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | padding: 1rem; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .orders__products { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | .orders__products-item { 25 | margin: 0.5rem 0; 26 | padding: 0.5rem; 27 | border: 1px solid #00695c; 28 | color: #00695c; 29 | } 30 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/public/css/orders.css: -------------------------------------------------------------------------------- 1 | .orders { 2 | list-style: none; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | .orders__item h1 { 8 | margin: 0; 9 | font-size: 1rem; 10 | } 11 | 12 | .orders__item { 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | padding: 1rem; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .orders__products { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | .orders__products-item { 25 | margin: 0.5rem 0; 26 | padding: 0.5rem; 27 | border: 1px solid #00695c; 28 | color: #00695c; 29 | } 30 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/public/css/orders.css: -------------------------------------------------------------------------------- 1 | .orders { 2 | list-style: none; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | .orders__item h1 { 8 | margin: 0; 9 | font-size: 1rem; 10 | } 11 | 12 | .orders__item { 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | padding: 1rem; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .orders__products { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | .orders__products-item { 25 | margin: 0.5rem 0; 26 | padding: 0.5rem; 27 | border: 1px solid #00695c; 28 | color: #00695c; 29 | } 30 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/public/css/orders.css: -------------------------------------------------------------------------------- 1 | .orders { 2 | list-style: none; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | .orders__item h1 { 8 | margin: 0; 9 | font-size: 1rem; 10 | } 11 | 12 | .orders__item { 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | padding: 1rem; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .orders__products { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | .orders__products-item { 25 | margin: 0.5rem 0; 26 | padding: 0.5rem; 27 | border: 1px solid #00695c; 28 | color: #00695c; 29 | } 30 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/models/order.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const Schema = mongoose.Schema; 4 | 5 | const orderSchema = new Schema({ 6 | products: [ 7 | { 8 | product: { type: Object, required: true }, 9 | quantity: { type: Number, required: true } 10 | } 11 | ], 12 | user: { 13 | email: { 14 | type: String, 15 | required: true 16 | }, 17 | userId: { 18 | type: Schema.Types.ObjectId, 19 | required: true, 20 | ref: 'User' 21 | } 22 | } 23 | }); 24 | 25 | module.exports = mongoose.model('Order', orderSchema); 26 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Navigation/MobileToggle/MobileToggle.css: -------------------------------------------------------------------------------- 1 | .mobile-toggle { 2 | background: transparent; 3 | border: none; 4 | display: flex; 5 | width: 2.5rem; 6 | height: 80%; 7 | flex-direction: column; 8 | justify-content: space-evenly; 9 | cursor: pointer; 10 | padding: 0; 11 | margin-right: 1rem; 12 | } 13 | 14 | .mobile-toggle__bar { 15 | width: 2.5rem; 16 | height: 4px; 17 | background: white; 18 | } 19 | 20 | @media (min-width: 768px) { 21 | .mobile-toggle { 22 | display: none; 23 | } 24 | } -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { BrowserRouter } from 'react-router-dom'; 4 | 5 | import './index.css'; 6 | import App from './App'; 7 | 8 | ReactDOM.render( 9 | 10 | 11 | , 12 | document.getElementById('root') 13 | ); 14 | 15 | // If you want your app to work offline and load faster, you can change 16 | // unregister() to register() below. Note this comes with some pitfalls. 17 | // Learn more about service workers: http://bit.ly/CRA-PWA 18 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/public/css/orders.css: -------------------------------------------------------------------------------- 1 | .orders { 2 | list-style: none; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | .orders__item h1 { 8 | margin: 0; 9 | font-size: 1rem; 10 | } 11 | 12 | .orders__item { 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | padding: 1rem; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .orders__products { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | .orders__products-item { 25 | margin: 0.5rem 0; 26 | padding: 0.5rem; 27 | border: 1px solid #00695c; 28 | color: #00695c; 29 | } 30 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/models/order.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const Schema = mongoose.Schema; 4 | 5 | const orderSchema = new Schema({ 6 | products: [ 7 | { 8 | product: { type: Object, required: true }, 9 | quantity: { type: Number, required: true } 10 | } 11 | ], 12 | user: { 13 | name: { 14 | type: String, 15 | required: true 16 | }, 17 | userId: { 18 | type: Schema.Types.ObjectId, 19 | required: true, 20 | ref: 'User' 21 | } 22 | } 23 | }); 24 | 25 | module.exports = mongoose.model('Order', orderSchema); 26 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/models/order.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const Schema = mongoose.Schema; 4 | 5 | const orderSchema = new Schema({ 6 | products: [ 7 | { 8 | product: { type: Object, required: true }, 9 | quantity: { type: Number, required: true } 10 | } 11 | ], 12 | user: { 13 | name: { 14 | type: String, 15 | required: true 16 | }, 17 | userId: { 18 | type: Schema.Types.ObjectId, 19 | required: true, 20 | ref: 'User' 21 | } 22 | } 23 | }); 24 | 25 | module.exports = mongoose.model('Order', orderSchema); 26 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | 25 | .form-control input.invalid, 26 | .form-control textarea.invalid { 27 | border-color: red; 28 | } -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/models/order.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const Schema = mongoose.Schema; 4 | 5 | const orderSchema = new Schema({ 6 | products: [ 7 | { 8 | product: { type: Object, required: true }, 9 | quantity: { type: Number, required: true } 10 | } 11 | ], 12 | user: { 13 | name: { 14 | type: String, 15 | required: true 16 | }, 17 | userId: { 18 | type: Schema.Types.ObjectId, 19 | required: true, 20 | ref: 'User' 21 | } 22 | } 23 | }); 24 | 25 | module.exports = mongoose.model('Order', orderSchema); 26 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/models/order.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const Schema = mongoose.Schema; 4 | 5 | const orderSchema = new Schema({ 6 | products: [ 7 | { 8 | product: { type: Object, required: true }, 9 | quantity: { type: Number, required: true } 10 | } 11 | ], 12 | user: { 13 | email: { 14 | type: String, 15 | required: true 16 | }, 17 | userId: { 18 | type: Schema.Types.ObjectId, 19 | required: true, 20 | ref: 'User' 21 | } 22 | } 23 | }); 24 | 25 | module.exports = mongoose.model('Order', orderSchema); 26 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/models/order.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const Schema = mongoose.Schema; 4 | 5 | const orderSchema = new Schema({ 6 | products: [ 7 | { 8 | product: { type: Object, required: true }, 9 | quantity: { type: Number, required: true } 10 | } 11 | ], 12 | user: { 13 | email: { 14 | type: String, 15 | required: true 16 | }, 17 | userId: { 18 | type: Schema.Types.ObjectId, 19 | required: true, 20 | ref: 'User' 21 | } 22 | } 23 | }); 24 | 25 | module.exports = mongoose.model('Order', orderSchema); 26 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/models/order.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const Schema = mongoose.Schema; 4 | 5 | const orderSchema = new Schema({ 6 | products: [ 7 | { 8 | product: { type: Object, required: true }, 9 | quantity: { type: Number, required: true } 10 | } 11 | ], 12 | user: { 13 | email: { 14 | type: String, 15 | required: true 16 | }, 17 | userId: { 18 | type: Schema.Types.ObjectId, 19 | required: true, 20 | ref: 'User' 21 | } 22 | } 23 | }); 24 | 25 | module.exports = mongoose.model('Order', orderSchema); 26 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { BrowserRouter } from 'react-router-dom'; 4 | 5 | import './index.css'; 6 | import App from './App'; 7 | 8 | ReactDOM.render( 9 | 10 | 11 | , 12 | document.getElementById('root') 13 | ); 14 | 15 | // If you want your app to work offline and load faster, you can change 16 | // unregister() to register() below. Note this comes with some pitfalls. 17 | // Learn more about service workers: http://bit.ly/CRA-PWA 18 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/public/js/main.js: -------------------------------------------------------------------------------- 1 | const backdrop = document.querySelector('.backdrop'); 2 | const sideDrawer = document.querySelector('.mobile-nav'); 3 | const menuToggle = document.querySelector('#side-menu-toggle'); 4 | 5 | function backdropClickHandler() { 6 | backdrop.style.display = 'none'; 7 | sideDrawer.classList.remove('open'); 8 | } 9 | 10 | function menuToggleClickHandler() { 11 | backdrop.style.display = 'block'; 12 | sideDrawer.classList.add('open'); 13 | } 14 | 15 | backdrop.addEventListener('click', backdropClickHandler); 16 | menuToggle.addEventListener('click', menuToggleClickHandler); 17 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/models/order.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const Schema = mongoose.Schema; 4 | 5 | const orderSchema = new Schema({ 6 | products: [ 7 | { 8 | product: { type: Object, required: true }, 9 | quantity: { type: Number, required: true } 10 | } 11 | ], 12 | user: { 13 | email: { 14 | type: String, 15 | required: true 16 | }, 17 | userId: { 18 | type: Schema.Types.ObjectId, 19 | required: true, 20 | ref: 'User' 21 | } 22 | } 23 | }); 24 | 25 | module.exports = mongoose.model('Order', orderSchema); 26 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/public/css/forms.css: -------------------------------------------------------------------------------- 1 | .form-control { 2 | margin: 1rem 0; 3 | } 4 | 5 | .form-control label, 6 | .form-control input, 7 | .form-control textarea { 8 | display: block; 9 | width: 100%; 10 | margin-bottom: 0.25rem; 11 | } 12 | 13 | .form-control input, 14 | .form-control textarea { 15 | border: 1px solid #a1a1a1; 16 | font: inherit; 17 | border-radius: 2px; 18 | } 19 | 20 | .form-control input:focus, 21 | .form-control textarea:focus { 22 | outline-color: #00695c; 23 | } 24 | 25 | .form-control input.invalid, 26 | .form-control textarea.invalid { 27 | border-color: red; 28 | } -------------------------------------------------------------------------------- /17 - Error Handling/section-code/public/js/main.js: -------------------------------------------------------------------------------- 1 | const backdrop = document.querySelector('.backdrop'); 2 | const sideDrawer = document.querySelector('.mobile-nav'); 3 | const menuToggle = document.querySelector('#side-menu-toggle'); 4 | 5 | function backdropClickHandler() { 6 | backdrop.style.display = 'none'; 7 | sideDrawer.classList.remove('open'); 8 | } 9 | 10 | function menuToggleClickHandler() { 11 | backdrop.style.display = 'block'; 12 | sideDrawer.classList.add('open'); 13 | } 14 | 15 | backdrop.addEventListener('click', backdropClickHandler); 16 | menuToggle.addEventListener('click', menuToggleClickHandler); 17 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/assignment/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "assignment", 3 | "version": "1.0.0", 4 | "description": "1. Create a npm project and install Express.js (Nodemon if you want) and EJS.", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon app.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "body-parser": "^1.18.3", 14 | "ejs": "^2.6.1", 15 | "express": "^4.16.4" 16 | }, 17 | "devDependencies": { 18 | "nodemon": "^1.18.9" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/public/js/main.js: -------------------------------------------------------------------------------- 1 | const backdrop = document.querySelector('.backdrop'); 2 | const sideDrawer = document.querySelector('.mobile-nav'); 3 | const menuToggle = document.querySelector('#side-menu-toggle'); 4 | 5 | function backdropClickHandler() { 6 | backdrop.style.display = 'none'; 7 | sideDrawer.classList.remove('open'); 8 | } 9 | 10 | function menuToggleClickHandler() { 11 | backdrop.style.display = 'block'; 12 | sideDrawer.classList.add('open'); 13 | } 14 | 15 | backdrop.addEventListener('click', backdropClickHandler); 16 | menuToggle.addEventListener('click', menuToggleClickHandler); 17 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/public/js/main.js: -------------------------------------------------------------------------------- 1 | const backdrop = document.querySelector('.backdrop'); 2 | const sideDrawer = document.querySelector('.mobile-nav'); 3 | const menuToggle = document.querySelector('#side-menu-toggle'); 4 | 5 | function backdropClickHandler() { 6 | backdrop.style.display = 'none'; 7 | sideDrawer.classList.remove('open'); 8 | } 9 | 10 | function menuToggleClickHandler() { 11 | backdrop.style.display = 'block'; 12 | sideDrawer.classList.add('open'); 13 | } 14 | 15 | backdrop.addEventListener('click', backdropClickHandler); 16 | menuToggle.addEventListener('click', menuToggleClickHandler); 17 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/public/js/main.js: -------------------------------------------------------------------------------- 1 | const backdrop = document.querySelector('.backdrop'); 2 | const sideDrawer = document.querySelector('.mobile-nav'); 3 | const menuToggle = document.querySelector('#side-menu-toggle'); 4 | 5 | function backdropClickHandler() { 6 | backdrop.style.display = 'none'; 7 | sideDrawer.classList.remove('open'); 8 | } 9 | 10 | function menuToggleClickHandler() { 11 | backdrop.style.display = 'block'; 12 | sideDrawer.classList.add('open'); 13 | } 14 | 15 | backdrop.addEventListener('click', backdropClickHandler); 16 | menuToggle.addEventListener('click', menuToggleClickHandler); 17 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const rootDir = require('../util/path'); 6 | const adminData = require('./admin'); 7 | 8 | const router = express.Router(); 9 | 10 | router.get('/', (req, res, next) => { 11 | const products = adminData.products; 12 | res.render('shop', { 13 | prods: products, 14 | pageTitle: 'Shop', 15 | path: '/', 16 | hasProducts: products.length > 0, 17 | activeShop: true, 18 | productCSS: true 19 | }); 20 | }); 21 | 22 | module.exports = router; 23 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/public/js/main.js: -------------------------------------------------------------------------------- 1 | const backdrop = document.querySelector('.backdrop'); 2 | const sideDrawer = document.querySelector('.mobile-nav'); 3 | const menuToggle = document.querySelector('#side-menu-toggle'); 4 | 5 | function backdropClickHandler() { 6 | backdrop.style.display = 'none'; 7 | sideDrawer.classList.remove('open'); 8 | } 9 | 10 | function menuToggleClickHandler() { 11 | backdrop.style.display = 'block'; 12 | sideDrawer.classList.add('open'); 13 | } 14 | 15 | backdrop.addEventListener('click', backdropClickHandler); 16 | menuToggle.addEventListener('click', menuToggleClickHandler); 17 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/public/js/main.js: -------------------------------------------------------------------------------- 1 | const backdrop = document.querySelector('.backdrop'); 2 | const sideDrawer = document.querySelector('.mobile-nav'); 3 | const menuToggle = document.querySelector('#side-menu-toggle'); 4 | 5 | function backdropClickHandler() { 6 | backdrop.style.display = 'none'; 7 | sideDrawer.classList.remove('open'); 8 | } 9 | 10 | function menuToggleClickHandler() { 11 | backdrop.style.display = 'block'; 12 | sideDrawer.classList.add('open'); 13 | } 14 | 15 | backdrop.addEventListener('click', backdropClickHandler); 16 | menuToggle.addEventListener('click', menuToggleClickHandler); 17 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/public/js/main.js: -------------------------------------------------------------------------------- 1 | const backdrop = document.querySelector('.backdrop'); 2 | const sideDrawer = document.querySelector('.mobile-nav'); 3 | const menuToggle = document.querySelector('#side-menu-toggle'); 4 | 5 | function backdropClickHandler() { 6 | backdrop.style.display = 'none'; 7 | sideDrawer.classList.remove('open'); 8 | } 9 | 10 | function menuToggleClickHandler() { 11 | backdrop.style.display = 'block'; 12 | sideDrawer.classList.add('open'); 13 | } 14 | 15 | backdrop.addEventListener('click', backdropClickHandler); 16 | menuToggle.addEventListener('click', menuToggleClickHandler); 17 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Paginator/Paginator.css: -------------------------------------------------------------------------------- 1 | .paginator__controls { 2 | display: flex; 3 | justify-content: center; 4 | } 5 | 6 | .paginator__control { 7 | width: 5rem; 8 | padding: 0.25rem 0; 9 | margin: 0 1rem; 10 | border: 1px solid #3b0062; 11 | background: transparent; 12 | font: inherit; 13 | cursor: pointer; 14 | font-size: 1rem; 15 | color: #3b0062; 16 | } 17 | 18 | .paginator__control:hover, 19 | .paginator__control:active { 20 | color: #fab83f; 21 | border-color: #fab83f; 22 | } 23 | 24 | .paginator__control:focus { 25 | outline: none; 26 | } 27 | -------------------------------------------------------------------------------- /03 - Working with Express.js/section-code/app.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | const bodyParser = require('body-parser'); 5 | 6 | const app = express(); 7 | 8 | const adminRoutes = require('./routes/admin'); 9 | const shopRoutes = require('./routes/shop'); 10 | 11 | app.use(bodyParser.urlencoded({extended: false})); 12 | app.use(express.static(path.join(__dirname, 'public'))); 13 | 14 | app.use('/admin', adminRoutes); 15 | app.use(shopRoutes); 16 | 17 | app.use((req, res, next) => { 18 | res.status(404).sendFile(path.join(__dirname, 'views', '404.html')); 19 | }); 20 | 21 | app.listen(3000); 22 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/public/js/main.js: -------------------------------------------------------------------------------- 1 | const backdrop = document.querySelector('.backdrop'); 2 | const sideDrawer = document.querySelector('.mobile-nav'); 3 | const menuToggle = document.querySelector('#side-menu-toggle'); 4 | 5 | function backdropClickHandler() { 6 | backdrop.style.display = 'none'; 7 | sideDrawer.classList.remove('open'); 8 | } 9 | 10 | function menuToggleClickHandler() { 11 | backdrop.style.display = 'block'; 12 | sideDrawer.classList.add('open'); 13 | } 14 | 15 | backdrop.addEventListener('click', backdropClickHandler); 16 | menuToggle.addEventListener('click', menuToggleClickHandler); 17 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Paginator/Paginator.css: -------------------------------------------------------------------------------- 1 | .paginator__controls { 2 | display: flex; 3 | justify-content: center; 4 | } 5 | 6 | .paginator__control { 7 | width: 5rem; 8 | padding: 0.25rem 0; 9 | margin: 0 1rem; 10 | border: 1px solid #3b0062; 11 | background: transparent; 12 | font: inherit; 13 | cursor: pointer; 14 | font-size: 1rem; 15 | color: #3b0062; 16 | } 17 | 18 | .paginator__control:hover, 19 | .paginator__control:active { 20 | color: #fab83f; 21 | border-color: #fab83f; 22 | } 23 | 24 | .paginator__control:focus { 25 | outline: none; 26 | } 27 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/util/validators.js: -------------------------------------------------------------------------------- 1 | export const required = value => value.trim() !== ''; 2 | 3 | export const length = config => value => { 4 | let isValid = true; 5 | if (config.min) { 6 | isValid = isValid && value.trim().length >= config.min; 7 | } 8 | if (config.max) { 9 | isValid = isValid && value.trim().length <= config.max; 10 | } 11 | return isValid; 12 | }; 13 | 14 | export const email = value => 15 | /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/.test( 16 | value 17 | ); 18 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/section-code/models/user.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const userSchema = new Schema({ 5 | email: { 6 | type: String, 7 | required: true 8 | }, 9 | password: { 10 | type: String, 11 | required: true 12 | }, 13 | name: { 14 | type: String, 15 | required: true 16 | }, 17 | status: { 18 | type: String, 19 | default: 'I am new!' 20 | }, 21 | posts: [ 22 | { 23 | type: Schema.Types.ObjectId, 24 | ref: 'Post' 25 | } 26 | ] 27 | }); 28 | 29 | module.exports = mongoose.model('User', userSchema); 30 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/section-code/models/post.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const postSchema = new Schema( 5 | { 6 | title: { 7 | type: String, 8 | required: true 9 | }, 10 | imageUrl: { 11 | type: String, 12 | required: true 13 | }, 14 | content: { 15 | type: String, 16 | required: true 17 | }, 18 | creator: { 19 | type: Schema.Types.ObjectId, 20 | ref: 'User', 21 | required: true 22 | } 23 | }, 24 | { timestamps: true } 25 | ); 26 | 27 | module.exports = mongoose.model('Post', postSchema); 28 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

<%= product.title %>

8 |
9 |
10 | <%= product.title %> 11 |
12 |

<%= product.price %>

13 |

<%= product.description %>

14 | <%- include('../includes/add-to-cart.ejs') %> 15 |
16 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/util/validators.js: -------------------------------------------------------------------------------- 1 | export const required = value => value.trim() !== ''; 2 | 3 | export const length = config => value => { 4 | let isValid = true; 5 | if (config.min) { 6 | isValid = isValid && value.trim().length >= config.min; 7 | } 8 | if (config.max) { 9 | isValid = isValid && value.trim().length <= config.max; 10 | } 11 | return isValid; 12 | }; 13 | 14 | export const email = value => 15 | /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/.test( 16 | value 17 | ); 18 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/backend/models/user.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const userSchema = new Schema({ 5 | email: { 6 | type: String, 7 | required: true 8 | }, 9 | password: { 10 | type: String, 11 | required: true 12 | }, 13 | name: { 14 | type: String, 15 | required: true 16 | }, 17 | status: { 18 | type: String, 19 | default: 'I am new!' 20 | }, 21 | posts: [ 22 | { 23 | type: Schema.Types.ObjectId, 24 | ref: 'Post' 25 | } 26 | ] 27 | }); 28 | 29 | module.exports = mongoose.model('User', userSchema); 30 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

<%= product.title %>

8 |
9 |
10 | <%= product.title %> 11 |
12 |

<%= product.price %>

13 |

<%= product.description %>

14 | <%- include('../includes/add-to-cart.ejs') %> 15 |
16 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/section-code/models/user.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const userSchema = new Schema({ 5 | email: { 6 | type: String, 7 | required: true 8 | }, 9 | password: { 10 | type: String, 11 | required: true 12 | }, 13 | name: { 14 | type: String, 15 | required: true 16 | }, 17 | status: { 18 | type: String, 19 | default: 'I am new!' 20 | }, 21 | posts: [ 22 | { 23 | type: Schema.Types.ObjectId, 24 | ref: 'Post' 25 | } 26 | ] 27 | }); 28 | 29 | module.exports = mongoose.model('User', userSchema); 30 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/backend/models/post.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const postSchema = new Schema( 5 | { 6 | title: { 7 | type: String, 8 | required: true 9 | }, 10 | imageUrl: { 11 | type: String, 12 | required: true 13 | }, 14 | content: { 15 | type: String, 16 | required: true 17 | }, 18 | creator: { 19 | type: Schema.Types.ObjectId, 20 | ref: 'User', 21 | required: true 22 | } 23 | }, 24 | { timestamps: true } 25 | ); 26 | 27 | module.exports = mongoose.model('Post', postSchema); 28 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/section-code/models/post.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const postSchema = new Schema( 5 | { 6 | title: { 7 | type: String, 8 | required: true 9 | }, 10 | imageUrl: { 11 | type: String, 12 | required: true 13 | }, 14 | content: { 15 | type: String, 16 | required: true 17 | }, 18 | creator: { 19 | type: Schema.Types.ObjectId, 20 | ref: 'User', 21 | required: true 22 | } 23 | }, 24 | { timestamps: true } 25 | ); 26 | 27 | module.exports = mongoose.model('Post', postSchema); 28 | -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "Complete Node.js Guide", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js", 9 | "start-server": "node app.js" 10 | }, 11 | "author": "Maximilian Schwarzmüller", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "nodemon": "^1.18.3" 15 | }, 16 | "dependencies": { 17 | "body-parser": "^1.18.3", 18 | "ejs": "^2.6.1", 19 | "express": "^4.16.3", 20 | "express-handlebars": "^3.0.0", 21 | "pug": "^2.0.3" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

<%= product.title %>

8 |
9 |
10 | <%= product.title %> 11 |
12 |

<%= product.price %>

13 |

<%= product.description %>

14 | <%- include('../includes/add-to-cart.ejs') %> 15 |
16 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /22 - Working with REST APIs - The Basics/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/udemy-course-nodejs-complete" 13 | }, 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "body-parser": "^1.18.3", 18 | "express": "^4.16.3" 19 | }, 20 | "devDependencies": { 21 | "nodemon": "^1.18.4" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/backend/models/user.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const userSchema = new Schema({ 5 | email: { 6 | type: String, 7 | required: true 8 | }, 9 | password: { 10 | type: String, 11 | required: true 12 | }, 13 | name: { 14 | type: String, 15 | required: true 16 | }, 17 | status: { 18 | type: String, 19 | default: 'I am new!' 20 | }, 21 | posts: [ 22 | { 23 | type: Schema.Types.ObjectId, 24 | ref: 'Post' 25 | } 26 | ] 27 | }); 28 | 29 | module.exports = mongoose.model('User', userSchema); 30 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/backend/models/post.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const postSchema = new Schema( 5 | { 6 | title: { 7 | type: String, 8 | required: true 9 | }, 10 | imageUrl: { 11 | type: String, 12 | required: true 13 | }, 14 | content: { 15 | type: String, 16 | required: true 17 | }, 18 | creator: { 19 | type: Schema.Types.ObjectId, 20 | ref: 'User', 21 | required: true 22 | } 23 | }, 24 | { timestamps: true } 25 | ); 26 | 27 | module.exports = mongoose.model('Post', postSchema); 28 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Form/Input/FilePicker.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Input.css'; 4 | 5 | const filePicker = props => ( 6 |
7 | 8 | props.onChange(props.id, e.target.value, e.target.files)} 16 | onBlur={props.onBlur} 17 | /> 18 |
19 | ); 20 | 21 | export default filePicker; 22 | -------------------------------------------------------------------------------- /02 - Improved Development Workflow and Debugging/section-code/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "type": "node", 10 | "request": "launch", 11 | "name": "Launch Program", 12 | "program": "${workspaceFolder}/app.js", 13 | "restart": true, 14 | "runtimeExecutable": "nodemon", 15 | "console": "integratedTerminal" 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "Complete Node.js Guide", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js", 9 | "start-server": "node app.js" 10 | }, 11 | "author": "Maximilian Schwarzmüller", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "nodemon": "^1.18.3" 15 | }, 16 | "dependencies": { 17 | "body-parser": "^1.18.3", 18 | "ejs": "^2.6.1", 19 | "express": "^4.16.3", 20 | "express-handlebars": "^3.0.0", 21 | "pug": "^2.0.3" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Form/Input/FilePicker.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Input.css'; 4 | 5 | const filePicker = props => ( 6 |
7 | 8 | props.onChange(props.id, e.target.value, e.target.files)} 16 | onBlur={props.onBlur} 17 | /> 18 |
19 | ); 20 | 21 | export default filePicker; 22 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/README.md: -------------------------------------------------------------------------------- 1 | # Module Summary 2 | 3 | ## Model 4 | * Responsible for representing your data 5 | 6 | * Responsible for managing your data (saving, fetching...) 7 | 8 | * Doesn't matter if you manage data in memory, files, databases 9 | 10 | * Contains data-related logic 11 | 12 | ## View 13 | * What the user sees 14 | 15 | * Shouldn't contain too much logic 16 | 17 | ## Controller 18 | * Connects Model and View 19 | 20 | * Should only make sure that the two can communicate (in both directions) 21 | 22 | ## Useful Resources & Links 23 | * [More on MVC](https://developer.mozilla.org/en-US/docs/Web/Apps/Fundamentals/Modern_web_app_architecture/MVC_architecture) 24 | -------------------------------------------------------------------------------- /06 - Enhancing the App/section-code/app.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | const bodyParser = require('body-parser'); 5 | 6 | const errorController = require('./controllers/error'); 7 | 8 | const app = express(); 9 | 10 | app.set('view engine', 'ejs'); 11 | app.set('views', 'views'); 12 | 13 | const adminRoutes = require('./routes/admin'); 14 | const shopRoutes = require('./routes/shop'); 15 | 16 | app.use(bodyParser.urlencoded({ extended: false })); 17 | app.use(express.static(path.join(__dirname, 'public'))); 18 | 19 | app.use('/admin', adminRoutes); 20 | app.use(shopRoutes); 21 | 22 | app.use(errorController.get404); 23 | 24 | app.listen(3000); 25 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/ErrorHandler/ErrorHandler.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment } from 'react'; 2 | 3 | import Backdrop from '../Backdrop/Backdrop'; 4 | import Modal from '../Modal/Modal'; 5 | 6 | const errorHandler = props => ( 7 | 8 | {props.error && } 9 | {props.error && ( 10 | 16 |

{props.error.message}

17 |
18 | )} 19 |
20 | ); 21 | 22 | export default errorHandler; 23 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/app.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | const bodyParser = require('body-parser'); 5 | 6 | const errorController = require('./controllers/error'); 7 | 8 | const app = express(); 9 | 10 | app.set('view engine', 'ejs'); 11 | app.set('views', 'views'); 12 | 13 | const adminRoutes = require('./routes/admin'); 14 | const shopRoutes = require('./routes/shop'); 15 | 16 | app.use(bodyParser.urlencoded({ extended: false })); 17 | app.use(express.static(path.join(__dirname, 'public'))); 18 | 19 | app.use('/admin', adminRoutes); 20 | app.use(shopRoutes); 21 | 22 | app.use(errorController.get404); 23 | 24 | app.listen(3000); 25 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "Complete Node.js Guide", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js", 9 | "start-server": "node app.js" 10 | }, 11 | "author": "Maximilian Schwarzmüller", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "nodemon": "^1.18.3" 15 | }, 16 | "dependencies": { 17 | "body-parser": "^1.18.3", 18 | "ejs": "^2.6.1", 19 | "express": "^4.16.3", 20 | "express-handlebars": "^3.0.0", 21 | "pug": "^2.0.3" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Feed/Post/Post.css: -------------------------------------------------------------------------------- 1 | .post { 2 | margin: 1rem 0; 3 | border: 1px solid #3b0062; 4 | border-radius: 5px; 5 | padding: 0.5rem; 6 | } 7 | 8 | .post__meta { 9 | font-size: 1rem; 10 | color: #707070; 11 | margin: 0; 12 | } 13 | 14 | .post__title { 15 | font-size: 1.5rem; 16 | margin: 1rem 0; 17 | color: #3b0062; 18 | } 19 | 20 | .post__image { 21 | height: 15rem; 22 | width: 100%; 23 | } 24 | 25 | .post__actions { 26 | text-align: right; 27 | } 28 | 29 | @media (min-width: 768px) { 30 | .post { 31 | padding: 1rem; 32 | width: 40rem; 33 | margin-left: auto; 34 | margin-right: auto; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Form/Input/Input.css: -------------------------------------------------------------------------------- 1 | .input { 2 | margin: 1rem 0; 3 | width: 100%; 4 | } 5 | 6 | .input label { 7 | display: block; 8 | text-transform: uppercase; 9 | margin-bottom: 0.25rem; 10 | } 11 | 12 | .input input, 13 | .input textarea { 14 | display: block; 15 | font: inherit; 16 | padding: 0.25rem 0.5rem; 17 | width: 100%; 18 | border-radius: 3px; 19 | border: 1px solid #ccc; 20 | } 21 | 22 | .input .touched.invalid { 23 | border-color: red; 24 | background: #ffc2c2; 25 | } 26 | 27 | .input input:focus, 28 | .input textarea:focus { 29 | outline: none; 30 | border-color: #3b0062; 31 | color: #3b0062; 32 | } 33 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/views/add-product.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | 6 | 7 | <%- include('includes/navigation.ejs') %> 8 | 9 |
10 |
11 |
12 | 13 | 14 |
15 | 16 | 17 |
18 |
19 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/ErrorHandler/ErrorHandler.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment } from 'react'; 2 | 3 | import Backdrop from '../Backdrop/Backdrop'; 4 | import Modal from '../Modal/Modal'; 5 | 6 | const errorHandler = props => ( 7 | 8 | {props.error && } 9 | {props.error && ( 10 | 16 |

{props.error.message}

17 |
18 | )} 19 |
20 | ); 21 | 22 | export default errorHandler; 23 | -------------------------------------------------------------------------------- /22 - Working with REST APIs - The Basics/section-code/app.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const bodyParser = require('body-parser'); 3 | 4 | const feedRoutes = require('./routes/feed'); 5 | 6 | const app = express(); 7 | 8 | // app.use(bodyParser.urlencoded()); // x-www-form-urlencoded
9 | app.use(bodyParser.json()); // application/json 10 | 11 | app.use((req, res, next) => { 12 | res.setHeader('Access-Control-Allow-Origin', '*'); 13 | res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, POST, PUT, PATCH, DELETE'); 14 | res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); 15 | next(); 16 | }); 17 | 18 | app.use('/feed', feedRoutes); 19 | 20 | app.listen(8080); -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-complete-social-network-prep", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "react": "^16.5.2", 7 | "react-dom": "^16.5.2", 8 | "react-router-dom": "^4.3.1", 9 | "react-scripts": "2.0.4" 10 | }, 11 | "scripts": { 12 | "start": "react-scripts start", 13 | "build": "react-scripts build", 14 | "test": "react-scripts test", 15 | "eject": "react-scripts eject" 16 | }, 17 | "eslintConfig": { 18 | "extends": "react-app" 19 | }, 20 | "browserslist": [ 21 | ">0.2%", 22 | "not dead", 23 | "not ie <= 11", 24 | "not op_mini all" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Feed/Post/Post.css: -------------------------------------------------------------------------------- 1 | .post { 2 | margin: 1rem 0; 3 | border: 1px solid #3b0062; 4 | border-radius: 5px; 5 | padding: 0.5rem; 6 | } 7 | 8 | .post__meta { 9 | font-size: 1rem; 10 | color: #707070; 11 | margin: 0; 12 | } 13 | 14 | .post__title { 15 | font-size: 1.5rem; 16 | margin: 1rem 0; 17 | color: #3b0062; 18 | } 19 | 20 | .post__image { 21 | height: 15rem; 22 | width: 100%; 23 | } 24 | 25 | .post__actions { 26 | text-align: right; 27 | } 28 | 29 | @media (min-width: 768px) { 30 | .post { 31 | padding: 1rem; 32 | width: 40rem; 33 | margin-left: auto; 34 | margin-right: auto; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Form/Input/Input.css: -------------------------------------------------------------------------------- 1 | .input { 2 | margin: 1rem 0; 3 | width: 100%; 4 | } 5 | 6 | .input label { 7 | display: block; 8 | text-transform: uppercase; 9 | margin-bottom: 0.25rem; 10 | } 11 | 12 | .input input, 13 | .input textarea { 14 | display: block; 15 | font: inherit; 16 | padding: 0.25rem 0.5rem; 17 | width: 100%; 18 | border-radius: 3px; 19 | border: 1px solid #ccc; 20 | } 21 | 22 | .input .touched.invalid { 23 | border-color: red; 24 | background: #ffc2c2; 25 | } 26 | 27 | .input input:focus, 28 | .input textarea:focus { 29 | outline: none; 30 | border-color: #3b0062; 31 | color: #3b0062; 32 | } 33 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Navigation/MobileNavigation/MobileNavigation.css: -------------------------------------------------------------------------------- 1 | .mobile-nav { 2 | position: fixed; 3 | top: 0; 4 | left: 0; 5 | height: 100vh; 6 | width: 30rem; 7 | max-width: 90%; 8 | background: white; 9 | box-shadow: 1px 0 8px rbga(0, 0, 0, 0.26); 10 | transition: transform 0.3s ease-out; 11 | transform: translateX(-100%); 12 | z-index: 200; 13 | padding: 3rem 2rem; 14 | } 15 | 16 | .mobile-nav.open { 17 | transform: translateX(0); 18 | } 19 | 20 | .mobile-nav__items { 21 | display: flex; 22 | list-style: none; 23 | padding: 0; 24 | margin: 0; 25 | } 26 | 27 | .mobile-nav__items.mobile { 28 | flex-direction: column; 29 | } 30 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Paginator/Paginator.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Paginator.css'; 4 | 5 | const paginator = props => ( 6 |
7 | {props.children} 8 |
9 | {props.currentPage > 1 && ( 10 | 13 | )} 14 | {props.currentPage < props.lastPage && ( 15 | 18 | )} 19 |
20 |
21 | ); 22 | 23 | export default paginator; 24 | -------------------------------------------------------------------------------- /03 - Working with Express.js/section-code/public/css/product.css: -------------------------------------------------------------------------------- 1 | .product-form { 2 | width: 20rem; 3 | max-width: 90%; 4 | margin: auto; 5 | } 6 | 7 | .form-control { 8 | margin: 1rem 0; 9 | } 10 | 11 | .form-control label, 12 | .form-control input { 13 | display: block; 14 | width: 100%; 15 | } 16 | 17 | .form-control input { 18 | border: 1px solid #dbc441; 19 | font: inherit; 20 | border-radius: 2px; 21 | } 22 | 23 | button { 24 | font: inherit; 25 | border: 1px solid #3e00a1; 26 | color: #3e00a1; 27 | background: white; 28 | border-radius: 3px; 29 | cursor: pointer; 30 | } 31 | 32 | button:hover, 33 | button:active { 34 | background-color: #3e00a1; 35 | color: white; 36 | } -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-complete-social-network-prep", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "react": "^16.5.2", 7 | "react-dom": "^16.5.2", 8 | "react-router-dom": "^4.3.1", 9 | "react-scripts": "2.0.4" 10 | }, 11 | "scripts": { 12 | "start": "react-scripts start", 13 | "build": "react-scripts build", 14 | "test": "react-scripts test", 15 | "eject": "react-scripts eject" 16 | }, 17 | "eslintConfig": { 18 | "extends": "react-app" 19 | }, 20 | "browserslist": [ 21 | ">0.2%", 22 | "not dead", 23 | "not ie <= 11", 24 | "not op_mini all" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Navigation/MobileNavigation/MobileNavigation.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import NavigationItems from '../NavigationItems/NavigationItems'; 4 | import './MobileNavigation.css'; 5 | 6 | const mobileNavigation = props => ( 7 | 19 | ); 20 | 21 | export default mobileNavigation; 22 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/app.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | const bodyParser = require('body-parser'); 5 | 6 | const app = express(); 7 | 8 | app.set('view engine', 'ejs'); 9 | app.set('views', 'views'); 10 | 11 | const adminData = require('./routes/admin'); 12 | const shopRoutes = require('./routes/shop'); 13 | 14 | app.use(bodyParser.urlencoded({ extended: false })); 15 | app.use(express.static(path.join(__dirname, 'public'))); 16 | 17 | app.use('/admin', adminData.routes); 18 | app.use(shopRoutes); 19 | 20 | app.use((req, res, next) => { 21 | res.status(404).render('404', { pageTitle: 'Page Not Found' }); 22 | }); 23 | 24 | app.listen(3000); 25 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/add-product.ejs: -------------------------------------------------------------------------------- 1 | <%- include('includes/head.ejs') %> 2 | 3 | 4 | 5 | 6 | 7 | <%- include('includes/navigation.ejs') %> 8 | 9 |
10 | 11 |
12 | 13 | 14 |
15 | 16 | 17 | 18 |
19 | <%- include('includes/end.ejs') %> -------------------------------------------------------------------------------- /17 - Error Handling/section-code/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

<%= product.title %>

8 |
9 |
10 | <%= product.title %> 11 |
12 |

<%= product.price %>

13 |

<%= product.description %>

14 | <% if (isAuthenticated) { %> 15 | <%- include('../includes/add-to-cart.ejs', {product: product}) %> 16 | <% } %> 17 |
18 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Navigation/MobileNavigation/MobileNavigation.css: -------------------------------------------------------------------------------- 1 | .mobile-nav { 2 | position: fixed; 3 | top: 0; 4 | left: 0; 5 | height: 100vh; 6 | width: 30rem; 7 | max-width: 90%; 8 | background: white; 9 | box-shadow: 1px 0 8px rbga(0, 0, 0, 0.26); 10 | transition: transform 0.3s ease-out; 11 | transform: translateX(-100%); 12 | z-index: 200; 13 | padding: 3rem 2rem; 14 | } 15 | 16 | .mobile-nav.open { 17 | transform: translateX(0); 18 | } 19 | 20 | .mobile-nav__items { 21 | display: flex; 22 | list-style: none; 23 | padding: 0; 24 | margin: 0; 25 | } 26 | 27 | .mobile-nav__items.mobile { 28 | flex-direction: column; 29 | } 30 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Paginator/Paginator.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './Paginator.css'; 4 | 5 | const paginator = props => ( 6 |
7 | {props.children} 8 |
9 | {props.currentPage > 1 && ( 10 | 13 | )} 14 | {props.currentPage < props.lastPage && ( 15 | 18 | )} 19 |
20 |
21 | ); 22 | 23 | export default paginator; 24 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

<%= product.title %>

8 |
9 |
10 | <%= product.title %> 11 |
12 |

<%= product.price %>

13 |

<%= product.description %>

14 | <% if (isAuthenticated) { %> 15 | <%- include('../includes/add-to-cart.ejs', {product: product}) %> 16 | <% } %> 17 |
18 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Navigation/MobileNavigation/MobileNavigation.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import NavigationItems from '../NavigationItems/NavigationItems'; 4 | import './MobileNavigation.css'; 5 | 6 | const mobileNavigation = props => ( 7 | 19 | ); 20 | 21 | export default mobileNavigation; 22 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

<%= product.title %>

8 |
9 |
10 | <%= product.title %> 11 |
12 |

<%= product.price %>

13 |

<%= product.description %>

14 | <% if (isAuthenticated) { %> 15 | <%- include('../includes/add-to-cart.ejs', {product: product}) %> 16 | <% } %> 17 |
18 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

<%= product.title %>

8 |
9 |
10 | <%= product.title %> 11 |
12 |

<%= product.price %>

13 |

<%= product.description %>

14 | <% if (isAuthenticated) { %> 15 | <%- include('../includes/add-to-cart.ejs', {product: product}) %> 16 | <% } %> 17 |
18 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

<%= product.title %>

8 |
9 |
10 | <%= product.title %> 11 |
12 |

<%= product.price %>

13 |

<%= product.description %>

14 | <% if (isAuthenticated) { %> 15 | <%- include('../includes/add-to-cart.ejs', {product: product}) %> 16 | <% } %> 17 |
18 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/README.md: -------------------------------------------------------------------------------- 1 | # Module Summary 2 | 3 | ## From "Classic" to REST API 4 | 5 | - Most of the server-side code does not change, only request + response data is affected 6 | - More HTTP methods are available 7 | - The REST API server does not care about the client, request are handled in isolation => No sessions 8 | 9 | ## Authentication 10 | - Due to no session being used, authentication works differently 11 | - Each request needs to be able to send some data that proves tha the request is authenticated 12 | - JSON Web Tokens (JWT) are a common way of storing authentication information on the client and proving authentication status 13 | - JWTs are singned by the server and can only be validated by the server 14 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/util/database.js: -------------------------------------------------------------------------------- 1 | const mongodb = require('mongodb'); 2 | const MongoClient = mongodb.MongoClient; 3 | 4 | let _db; 5 | 6 | const mongoConnect = callback => { 7 | MongoClient.connect( 8 | 'mongodb+srv://maximilian:9u4biljMQc4jjqbe@cluster0-ntrwp.mongodb.net/shop?retryWrites=true' 9 | ) 10 | .then(client => { 11 | console.log('Connected!'); 12 | _db = client.db(); 13 | callback(); 14 | }) 15 | .catch(err => { 16 | console.log(err); 17 | throw err; 18 | }); 19 | }; 20 | 21 | const getDb = () => { 22 | if (_db) { 23 | return _db; 24 | } 25 | throw 'No database found!'; 26 | }; 27 | 28 | exports.mongoConnect = mongoConnect; 29 | exports.getDb = getDb; 30 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | 7 | const router = express.Router(); 8 | 9 | router.get('/', shopController.getIndex); 10 | 11 | router.get('/products', shopController.getProducts); 12 | 13 | router.get('/products/:productId', shopController.getProduct); 14 | 15 | router.get('/cart', shopController.getCart); 16 | 17 | router.post('/cart', shopController.postCart); 18 | 19 | router.post('/cart-delete-item', shopController.postCartDeleteProduct); 20 | 21 | router.post('/create-order', shopController.postOrder); 22 | 23 | router.get('/orders', shopController.getOrders); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/views/shop/product-detail.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | <%- include('../includes/navigation.ejs') %> 6 |
7 |

<%= product.title %>

8 |
9 |
10 | <%= product.title %> 11 |
12 |

<%= product.price %>

13 |

<%= product.description %>

14 | <% if (isAuthenticated) { %> 15 | <%- include('../includes/add-to-cart.ejs', {product: product}) %> 16 | <% } %> 17 |
18 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | 7 | const router = express.Router(); 8 | 9 | router.get('/', shopController.getIndex); 10 | 11 | router.get('/products', shopController.getProducts); 12 | 13 | router.get('/products/:productId', shopController.getProduct); 14 | 15 | router.get('/cart', shopController.getCart); 16 | 17 | router.post('/cart', shopController.postCart); 18 | 19 | router.post('/cart-delete-item', shopController.postCartDeleteProduct); 20 | 21 | router.post('/create-order', shopController.postOrder); 22 | 23 | router.get('/orders', shopController.getOrders); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | 7 | const router = express.Router(); 8 | 9 | router.get('/', shopController.getIndex); 10 | 11 | router.get('/products', shopController.getProducts); 12 | 13 | router.get('/products/:productId', shopController.getProduct); 14 | 15 | router.get('/cart', shopController.getCart); 16 | 17 | router.post('/cart', shopController.postCart); 18 | 19 | router.post('/cart-delete-item', shopController.postCartDeleteProduct); 20 | 21 | router.post('/create-order', shopController.postOrder); 22 | 23 | router.get('/orders', shopController.getOrders); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/routes/auth.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const authController = require('../controllers/auth'); 4 | 5 | const router = express.Router(); 6 | 7 | router.get('/login', authController.getLogin); 8 | 9 | router.get('/signup', authController.getSignup); 10 | 11 | router.post('/login', authController.postLogin); 12 | 13 | router.post('/signup', authController.postSignup); 14 | 15 | router.post('/logout', authController.postLogout); 16 | 17 | router.get('/reset', authController.getReset); 18 | 19 | router.post('/reset', authController.postReset); 20 | 21 | router.get('/reset/:token', authController.getNewPassword); 22 | 23 | router.post('/new-password', authController.postNewPassword); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | 7 | const router = express.Router(); 8 | 9 | router.get('/', shopController.getIndex); 10 | 11 | router.get('/products', shopController.getProducts); 12 | 13 | router.get('/products/:productId', shopController.getProduct); 14 | 15 | router.get('/cart', shopController.getCart); 16 | 17 | router.post('/cart', shopController.postCart); 18 | 19 | router.post('/cart-delete-item', shopController.postCartDeleteProduct); 20 | 21 | router.post('/create-order', shopController.postOrder); 22 | 23 | router.get('/orders', shopController.getOrders); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "Complete Node.js Guide", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js", 9 | "start-server": "node app.js" 10 | }, 11 | "author": "Maximilian Schwarzmüller", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "nodemon": "^1.18.3" 15 | }, 16 | "dependencies": { 17 | "body-parser": "^1.18.3", 18 | "ejs": "^2.6.1", 19 | "express": "^4.16.3", 20 | "express-handlebars": "^3.0.0", 21 | "mongodb": "^3.1.6", 22 | "mysql2": "^1.6.1", 23 | "pug": "^2.0.3", 24 | "sequelize": "^5.0.0-beta.11" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/section-code/middleware/is-auth.js: -------------------------------------------------------------------------------- 1 | const jwt = require('jsonwebtoken'); 2 | 3 | module.exports = (req, res, next) => { 4 | const authHeader = req.get('Authorization'); 5 | if (!authHeader) { 6 | const error = new Error('Not authenticated.'); 7 | error.statusCode = 401; 8 | throw error; 9 | } 10 | const token = authHeader.split(' ')[1]; 11 | let decodedToken; 12 | try { 13 | decodedToken = jwt.verify(token, 'somesupersecretsecret'); 14 | } catch (err) { 15 | err.statusCode = 500; 16 | throw err; 17 | } 18 | if (!decodedToken) { 19 | const error = new Error('Not authenticated.'); 20 | error.statusCode = 401; 21 | throw error; 22 | } 23 | req.userId = decodedToken.userId; 24 | next(); 25 | }; 26 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const adminController = require('../controllers/admin'); 6 | 7 | const router = express.Router(); 8 | 9 | // /admin/add-product => GET 10 | router.get('/add-product', adminController.getAddProduct); 11 | 12 | // /admin/products => GET 13 | router.get('/products', adminController.getProducts); 14 | 15 | // /admin/add-product => POST 16 | router.post('/add-product', adminController.postAddProduct); 17 | 18 | router.get('/edit-product/:productId', adminController.getEditProduct); 19 | 20 | router.post('/edit-product', adminController.postEditProduct); 21 | 22 | router.post('/delete-product', adminController.postDeleteProduct); 23 | 24 | module.exports = router; 25 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const adminController = require('../controllers/admin'); 6 | 7 | const router = express.Router(); 8 | 9 | // /admin/add-product => GET 10 | router.get('/add-product', adminController.getAddProduct); 11 | 12 | // /admin/products => GET 13 | router.get('/products', adminController.getProducts); 14 | 15 | // /admin/add-product => POST 16 | router.post('/add-product', adminController.postAddProduct); 17 | 18 | router.get('/edit-product/:productId', adminController.getEditProduct); 19 | 20 | router.post('/edit-product', adminController.postEditProduct); 21 | 22 | router.post('/delete-product', adminController.postDeleteProduct); 23 | 24 | module.exports = router; 25 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const adminController = require('../controllers/admin'); 6 | 7 | const router = express.Router(); 8 | 9 | // /admin/add-product => GET 10 | router.get('/add-product', adminController.getAddProduct); 11 | 12 | // /admin/products => GET 13 | router.get('/products', adminController.getProducts); 14 | 15 | // /admin/add-product => POST 16 | router.post('/add-product', adminController.postAddProduct); 17 | 18 | router.get('/edit-product/:productId', adminController.getEditProduct); 19 | 20 | router.post('/edit-product', adminController.postEditProduct); 21 | 22 | router.post('/delete-product', adminController.postDeleteProduct); 23 | 24 | module.exports = router; 25 | -------------------------------------------------------------------------------- /22 - Working with REST APIs - The Basics/README.md: -------------------------------------------------------------------------------- 1 | # Module Summary 2 | 3 | ## REST Concepts & Ideas 4 | 5 | - REST APIs are all about data, no UI logic is exchanged 6 | - REST APIs are normal Node servers which expose different endpoints (HTTP method + path) for clients to send requests to 7 | - JSON is the common data format that is used both for requests and responses 8 | - REST APIs are decoupled from the clients that use them 9 | 10 | ## Requests & Responses 11 | - Attach data in JSON format and let the other end know by setting the "Content-Type" header 12 | - CORS errors occur when using an API that does not set CORS headers 13 | 14 | ## Useful Resources & Links 15 | 16 | - [Example: Build a Complete RESTful API from Scratch](https://academind.com/learn/node-js/building-a-restful-api-with/) 17 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/backend/middleware/is-auth.js: -------------------------------------------------------------------------------- 1 | const jwt = require('jsonwebtoken'); 2 | 3 | module.exports = (req, res, next) => { 4 | const authHeader = req.get('Authorization'); 5 | if (!authHeader) { 6 | const error = new Error('Not authenticated.'); 7 | error.statusCode = 401; 8 | throw error; 9 | } 10 | const token = authHeader.split(' ')[1]; 11 | let decodedToken; 12 | try { 13 | decodedToken = jwt.verify(token, 'somesupersecretsecret'); 14 | } catch (err) { 15 | err.statusCode = 500; 16 | throw err; 17 | } 18 | if (!decodedToken) { 19 | const error = new Error('Not authenticated.'); 20 | error.statusCode = 401; 21 | throw error; 22 | } 23 | req.userId = decodedToken.userId; 24 | next(); 25 | }; 26 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/section-code/middleware/is-auth.js: -------------------------------------------------------------------------------- 1 | const jwt = require('jsonwebtoken'); 2 | 3 | module.exports = (req, res, next) => { 4 | const authHeader = req.get('Authorization'); 5 | if (!authHeader) { 6 | const error = new Error('Not authenticated.'); 7 | error.statusCode = 401; 8 | throw error; 9 | } 10 | const token = authHeader.split(' ')[1]; 11 | let decodedToken; 12 | try { 13 | decodedToken = jwt.verify(token, 'somesupersecretsecret'); 14 | } catch (err) { 15 | err.statusCode = 500; 16 | throw err; 17 | } 18 | if (!decodedToken) { 19 | const error = new Error('Not authenticated.'); 20 | error.statusCode = 401; 21 | throw error; 22 | } 23 | req.userId = decodedToken.userId; 24 | next(); 25 | }; 26 | -------------------------------------------------------------------------------- /11 - Working with Mongoose/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "Complete Node.js Guide", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js", 9 | "start-server": "node app.js" 10 | }, 11 | "author": "Maximilian Schwarzmüller", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "nodemon": "^1.18.3" 15 | }, 16 | "dependencies": { 17 | "body-parser": "^1.18.3", 18 | "ejs": "^2.6.1", 19 | "express": "^4.16.3", 20 | "express-handlebars": "^3.0.0", 21 | "mongodb": "^3.1.6", 22 | "mongoose": "^5.2.17", 23 | "mysql2": "^1.6.1", 24 | "pug": "^2.0.3", 25 | "sequelize": "^5.0.0-beta.11" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /10 - Working with NoSQL & Using MongoDB/section-code/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const adminController = require('../controllers/admin'); 6 | 7 | const router = express.Router(); 8 | 9 | // /admin/add-product => GET 10 | router.get('/add-product', adminController.getAddProduct); 11 | 12 | // /admin/products => GET 13 | router.get('/products', adminController.getProducts); 14 | 15 | // /admin/add-product => POST 16 | router.post('/add-product', adminController.postAddProduct); 17 | 18 | router.get('/edit-product/:productId', adminController.getEditProduct); 19 | 20 | router.post('/edit-product', adminController.postEditProduct); 21 | 22 | router.post('/delete-product', adminController.postDeleteProduct); 23 | 24 | module.exports = router; 25 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/controllers/auth.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/user'); 2 | 3 | exports.getLogin = (req, res, next) => { 4 | res.render('auth/login', { 5 | path: '/login', 6 | pageTitle: 'Login', 7 | isAuthenticated: false 8 | }); 9 | }; 10 | 11 | exports.postLogin = (req, res, next) => { 12 | User.findById('5bab316ce0a7c75f783cb8a8') 13 | .then(user => { 14 | req.session.isLoggedIn = true; 15 | req.session.user = user; 16 | req.session.save(err => { 17 | console.log(err); 18 | res.redirect('/'); 19 | }); 20 | }) 21 | .catch(err => console.log(err)); 22 | }; 23 | 24 | exports.postLogout = (req, res, next) => { 25 | req.session.destroy(err => { 26 | console.log(err); 27 | res.redirect('/'); 28 | }); 29 | }; 30 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/backend/middleware/is-auth.js: -------------------------------------------------------------------------------- 1 | const jwt = require('jsonwebtoken'); 2 | 3 | module.exports = (req, res, next) => { 4 | const authHeader = req.get('Authorization'); 5 | if (!authHeader) { 6 | const error = new Error('Not authenticated.'); 7 | error.statusCode = 401; 8 | throw error; 9 | } 10 | const token = authHeader.split(' ')[1]; 11 | let decodedToken; 12 | try { 13 | decodedToken = jwt.verify(token, 'somesupersecretsecret'); 14 | } catch (err) { 15 | err.statusCode = 500; 16 | throw err; 17 | } 18 | if (!decodedToken) { 19 | const error = new Error('Not authenticated.'); 20 | error.statusCode = 401; 21 | throw error; 22 | } 23 | req.userId = decodedToken.userId; 24 | next(); 25 | }; 26 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Modal/Modal.css: -------------------------------------------------------------------------------- 1 | .modal { 2 | position: fixed; 3 | width: 90%; 4 | left: 5%; 5 | top: 20vh; 6 | background: white; 7 | border-radius: 5px; 8 | z-index: 200; 9 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 10 | } 11 | 12 | .modal__header { 13 | border-bottom: 2px solid #3b0062; 14 | } 15 | 16 | .modal__header h1 { 17 | font-size: 1.5rem; 18 | color: #3b0062; 19 | margin: 1rem; 20 | } 21 | 22 | .modal__content { 23 | padding: 1rem; 24 | } 25 | 26 | .modal__actions { 27 | padding: 1rem; 28 | text-align: right; 29 | } 30 | 31 | .modal__actions button { 32 | margin: 0 0.5rem; 33 | } 34 | 35 | @media (min-width: 768px) { 36 | .modal { 37 | width: 40rem; 38 | left: calc((100% - 40rem) / 2); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const rootDir = require('../util/path'); 6 | 7 | const router = express.Router(); 8 | 9 | const products = []; 10 | 11 | // /admin/add-product => GET 12 | router.get('/add-product', (req, res, next) => { 13 | res.render('add-product', { 14 | pageTitle: 'Add Product', 15 | path: '/admin/add-product', 16 | formsCSS: true, 17 | productCSS: true, 18 | activeAddProduct: true 19 | }); 20 | }); 21 | 22 | // /admin/add-product => POST 23 | router.post('/add-product', (req, res, next) => { 24 | products.push({ title: req.body.title }); 25 | res.redirect('/'); 26 | }); 27 | 28 | exports.routes = router; 29 | exports.products = products; 30 | -------------------------------------------------------------------------------- /03 - Working with Express.js/section-code/views/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page Not Found 9 | 10 | 11 | 12 | 13 |
14 | 20 |
21 |

Page Not Found!

22 | 23 | 24 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/frontend/src/components/Modal/Modal.css: -------------------------------------------------------------------------------- 1 | .modal { 2 | position: fixed; 3 | width: 90%; 4 | left: 5%; 5 | top: 20vh; 6 | background: white; 7 | border-radius: 5px; 8 | z-index: 200; 9 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 10 | } 11 | 12 | .modal__header { 13 | border-bottom: 2px solid #3b0062; 14 | } 15 | 16 | .modal__header h1 { 17 | font-size: 1.5rem; 18 | color: #3b0062; 19 | margin: 1rem; 20 | } 21 | 22 | .modal__content { 23 | padding: 1rem; 24 | } 25 | 26 | .modal__actions { 27 | padding: 1rem; 28 | text-align: right; 29 | } 30 | 31 | .modal__actions button { 32 | margin: 0 0.5rem; 33 | } 34 | 35 | @media (min-width: 768px) { 36 | .modal { 37 | width: 40rem; 38 | left: calc((100% - 40rem) / 2); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/udemy-course-nodejs-complete" 13 | }, 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "bcryptjs": "^2.4.3", 18 | "body-parser": "^1.18.3", 19 | "express": "^4.16.3", 20 | "express-validator": "^5.3.0", 21 | "jsonwebtoken": "^8.3.0", 22 | "mongoose": "^5.3.2", 23 | "multer": "^1.4.0" 24 | }, 25 | "devDependencies": { 26 | "nodemon": "^1.18.4" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/udemy-course-nodejs-complete" 13 | }, 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "bcryptjs": "^2.4.3", 18 | "body-parser": "^1.18.3", 19 | "express": "^4.16.3", 20 | "express-validator": "^5.3.0", 21 | "jsonwebtoken": "^8.3.0", 22 | "mongoose": "^5.3.2", 23 | "multer": "^1.4.0" 24 | }, 25 | "devDependencies": { 26 | "nodemon": "^1.18.4" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/404.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ pageTitle }} 9 | 10 | 11 | 12 | 13 |
14 | 20 |
21 |

Page Not Found!

22 | 23 | 24 | -------------------------------------------------------------------------------- /17 - Error Handling/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | const isAuth = require('../middleware/is-auth'); 7 | 8 | const router = express.Router(); 9 | 10 | router.get('/', shopController.getIndex); 11 | 12 | router.get('/products', shopController.getProducts); 13 | 14 | router.get('/products/:productId', shopController.getProduct); 15 | 16 | router.get('/cart', isAuth, shopController.getCart); 17 | 18 | router.post('/cart', isAuth, shopController.postCart); 19 | 20 | router.post('/cart-delete-item', isAuth, shopController.postCartDeleteProduct); 21 | 22 | router.post('/create-order', isAuth, shopController.postOrder); 23 | 24 | router.get('/orders', isAuth, shopController.getOrders); 25 | 26 | module.exports = router; 27 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/udemy-course-nodejs-complete" 13 | }, 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "bcryptjs": "^2.4.3", 18 | "body-parser": "^1.18.3", 19 | "express": "^4.16.3", 20 | "express-validator": "^5.3.0", 21 | "jsonwebtoken": "^8.3.0", 22 | "mongoose": "^5.3.2", 23 | "multer": "^1.4.0" 24 | }, 25 | "devDependencies": { 26 | "nodemon": "^1.18.4" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | const isAuth = require('../middleware/is-auth'); 7 | 8 | const router = express.Router(); 9 | 10 | router.get('/', shopController.getIndex); 11 | 12 | router.get('/products', shopController.getProducts); 13 | 14 | router.get('/products/:productId', shopController.getProduct); 15 | 16 | router.get('/cart', isAuth, shopController.getCart); 17 | 18 | router.post('/cart', isAuth, shopController.postCart); 19 | 20 | router.post('/cart-delete-item', isAuth, shopController.postCartDeleteProduct); 21 | 22 | router.post('/create-order', isAuth, shopController.postOrder); 23 | 24 | router.get('/orders', isAuth, shopController.getOrders); 25 | 26 | module.exports = router; 27 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/controllers/products.js: -------------------------------------------------------------------------------- 1 | const Product = require('../models/product'); 2 | 3 | exports.getAddProduct = (req, res, next) => { 4 | res.render('add-product', { 5 | pageTitle: 'Add Product', 6 | path: '/admin/add-product', 7 | formsCSS: true, 8 | productCSS: true, 9 | activeAddProduct: true 10 | }); 11 | }; 12 | 13 | exports.postAddProduct = (req, res, next) => { 14 | const product = new Product(req.body.title); 15 | product.save(); 16 | res.redirect('/'); 17 | }; 18 | 19 | exports.getProducts = (req, res, next) => { 20 | Product.fetchAll(products => { 21 | res.render('shop', { 22 | prods: products, 23 | pageTitle: 'Shop', 24 | path: '/', 25 | hasProducts: products.length > 0, 26 | activeShop: true, 27 | productCSS: true 28 | }); 29 | }); 30 | }; 31 | -------------------------------------------------------------------------------- /05 - The Model View Controller (MVC)/section-code/models/product.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | 4 | const p = path.join( 5 | path.dirname(process.mainModule.filename), 6 | 'data', 7 | 'products.json' 8 | ); 9 | 10 | const getProductsFromFile = cb => { 11 | fs.readFile(p, (err, fileContent) => { 12 | if (err) { 13 | cb([]); 14 | } else { 15 | cb(JSON.parse(fileContent)); 16 | } 17 | }); 18 | }; 19 | 20 | module.exports = class Product { 21 | constructor(t) { 22 | this.title = t; 23 | } 24 | 25 | save() { 26 | getProductsFromFile(products => { 27 | products.push(this); 28 | fs.writeFile(p, JSON.stringify(products), err => { 29 | console.log(err); 30 | }); 31 | }); 32 | } 33 | 34 | static fetchAll(cb) { 35 | getProductsFromFile(cb); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | const isAuth = require('../middleware/is-auth'); 7 | 8 | const router = express.Router(); 9 | 10 | router.get('/', shopController.getIndex); 11 | 12 | router.get('/products', shopController.getProducts); 13 | 14 | router.get('/products/:productId', shopController.getProduct); 15 | 16 | router.get('/cart', isAuth, shopController.getCart); 17 | 18 | router.post('/cart', isAuth, shopController.postCart); 19 | 20 | router.post('/cart-delete-item', isAuth, shopController.postCartDeleteProduct); 21 | 22 | router.post('/create-order', isAuth, shopController.postOrder); 23 | 24 | router.get('/orders', isAuth, shopController.getOrders); 25 | 26 | module.exports = router; 27 | -------------------------------------------------------------------------------- /16 - Understanding Validation/assignment-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | const isAuth = require('../middleware/is-auth'); 7 | 8 | const router = express.Router(); 9 | 10 | router.get('/', shopController.getIndex); 11 | 12 | router.get('/products', shopController.getProducts); 13 | 14 | router.get('/products/:productId', shopController.getProduct); 15 | 16 | router.get('/cart', isAuth, shopController.getCart); 17 | 18 | router.post('/cart', isAuth, shopController.postCart); 19 | 20 | router.post('/cart-delete-item', isAuth, shopController.postCartDeleteProduct); 21 | 22 | router.post('/create-order', isAuth, shopController.postOrder); 23 | 24 | router.get('/orders', isAuth, shopController.getOrders); 25 | 26 | module.exports = router; 27 | -------------------------------------------------------------------------------- /16 - Understanding Validation/section-code/routes/shop.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const shopController = require('../controllers/shop'); 6 | const isAuth = require('../middleware/is-auth'); 7 | 8 | const router = express.Router(); 9 | 10 | router.get('/', shopController.getIndex); 11 | 12 | router.get('/products', shopController.getProducts); 13 | 14 | router.get('/products/:productId', shopController.getProduct); 15 | 16 | router.get('/cart', isAuth, shopController.getCart); 17 | 18 | router.post('/cart', isAuth, shopController.postCart); 19 | 20 | router.post('/cart-delete-item', isAuth, shopController.postCartDeleteProduct); 21 | 22 | router.post('/create-order', isAuth, shopController.postOrder); 23 | 24 | router.get('/orders', isAuth, shopController.getOrders); 25 | 26 | module.exports = router; 27 | -------------------------------------------------------------------------------- /23 - Working with REST APIs - The Practical Application/assignment-code/backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/udemy-course-nodejs-complete" 13 | }, 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "bcryptjs": "^2.4.3", 18 | "body-parser": "^1.18.3", 19 | "express": "^4.16.3", 20 | "express-validator": "^5.3.0", 21 | "jsonwebtoken": "^8.3.0", 22 | "mongoose": "^5.3.2", 23 | "multer": "^1.4.0" 24 | }, 25 | "devDependencies": { 26 | "nodemon": "^1.18.4" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page Not Found 9 | 10 | 11 | 12 | 13 |
14 | 20 |
21 |

Page Not Found!

22 | 23 | 24 | -------------------------------------------------------------------------------- /03 - Working with Express.js/section-code/public/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 0; 3 | margin: 0; 4 | font-family: sans-serif; 5 | } 6 | 7 | main { 8 | padding: 1rem; 9 | } 10 | 11 | .main-header { 12 | width: 100%; 13 | height: 3.5rem; 14 | background-color: #dbc441; 15 | padding: 0 1.5rem; 16 | } 17 | 18 | .main-header__nav { 19 | height: 100%; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .main-header__item-list { 25 | list-style: none; 26 | margin: 0; 27 | padding: 0; 28 | display: flex; 29 | } 30 | 31 | .main-header__item { 32 | margin: 0 1rem; 33 | padding: 0; 34 | } 35 | 36 | .main-header__item a { 37 | text-decoration: none; 38 | color: black; 39 | } 40 | 41 | .main-header__item a:hover, 42 | .main-header__item a:active, 43 | .main-header__item a.active { 44 | color: #3e00a1; 45 | } -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "Complete Node.js Guide", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js", 9 | "start-server": "node app.js" 10 | }, 11 | "author": "Maximilian Schwarzmüller", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "nodemon": "^1.18.3" 15 | }, 16 | "dependencies": { 17 | "body-parser": "^1.18.3", 18 | "connect-mongodb-session": "^2.0.3", 19 | "ejs": "^2.6.1", 20 | "express": "^4.16.3", 21 | "express-handlebars": "^3.0.0", 22 | "express-session": "^1.15.6", 23 | "mongodb": "^3.1.6", 24 | "mongoose": "^5.2.17", 25 | "mysql2": "^1.6.1", 26 | "pug": "^2.0.3", 27 | "sequelize": "^5.0.0-beta.11" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/assignment/views/auth/login.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | 6 | 7 | <%- include('../includes/navigation.ejs') %> 8 | 9 |
10 | 21 |
22 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /04 - Working with Dynamic Content & Adding Templating Engines/section-code/views/layouts/main-layout.pug: -------------------------------------------------------------------------------- 1 | 2 | html(lang="en") 3 | head 4 | meta(charset="UTF-8") 5 | meta(name="viewport", content="width=device-width, initial-scale=1.0") 6 | meta(http-equiv="X-UA-Compatible", content="ie=edge") 7 | title #{pageTitle} 8 | link(rel="stylesheet", href="/css/main.css") 9 | block styles 10 | body 11 | header.main-header 12 | nav.main-header__nav 13 | ul.main-header__item-list 14 | li.main-header__item 15 | a(href="/", class=(path === '/' ? 'active' : '')) Shop 16 | li.main-header__item 17 | a(href="/admin/add-product", class=(path === '/admin/add-product' ? 'active' : '')) Add Product 18 | block content -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-complete-guide", 3 | "version": "1.0.0", 4 | "description": "Complete Node.js Guide", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon app.js", 9 | "start-server": "node app.js" 10 | }, 11 | "author": "Maximilian Schwarzmüller", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "nodemon": "^1.18.3" 15 | }, 16 | "dependencies": { 17 | "body-parser": "^1.18.3", 18 | "connect-mongodb-session": "^2.0.3", 19 | "ejs": "^2.6.1", 20 | "express": "^4.16.3", 21 | "express-handlebars": "^3.0.0", 22 | "express-session": "^1.15.6", 23 | "mongodb": "^3.1.6", 24 | "mongoose": "^5.2.17", 25 | "mysql2": "^1.6.1", 26 | "pug": "^2.0.3", 27 | "sequelize": "^5.0.0-beta.11" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /12 - Sessions & Cookies/section-code/views/auth/login.ejs: -------------------------------------------------------------------------------- 1 | <%- include('../includes/head.ejs') %> 2 | 3 | 4 | 5 | 6 | 7 | <%- include('../includes/navigation.ejs') %> 8 | 9 |
10 | 21 |
22 | <%- include('../includes/end.ejs') %> -------------------------------------------------------------------------------- /13 - Adding Authentication/README.md: -------------------------------------------------------------------------------- 1 | # Module Summary 2 | 3 | ## Authentication 4 | 5 | - Authentication means that not every visitor of the page can view and interact with everything 6 | - Authentication has to happen on the server-side and builds up on sessions 7 | - you can protect routes by checking the (session-controlled) login status right before you access a controller action 8 | 9 | ## Security & UX 10 | 11 | - Passwords should be stored in a hashed form 12 | - CSRF attacks are a real issue and you should therefore include CSRF protection in ANY application you build 13 | - For a better user experience, you can flash data / message into the session eich you then can display in your views 14 | 15 | ## Useful Resources & Links 16 | 17 | - [Bcrypt Official Docs](https://github.com/dcodeIO/bcrypt.js) 18 | - [More on CSRF Attacks](https://www.acunetix.com/websitesecurity/csrf-attacks/) 19 | -------------------------------------------------------------------------------- /13 - Adding Authentication/section-code/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const adminController = require('../controllers/admin'); 6 | const isAuth = require('../middleware/is-auth'); 7 | 8 | const router = express.Router(); 9 | 10 | // /admin/add-product => GET 11 | router.get('/add-product', isAuth, adminController.getAddProduct); 12 | 13 | // /admin/products => GET 14 | router.get('/products', isAuth, adminController.getProducts); 15 | 16 | // /admin/add-product => POST 17 | router.post('/add-product', isAuth, adminController.postAddProduct); 18 | 19 | router.get('/edit-product/:productId', isAuth, adminController.getEditProduct); 20 | 21 | router.post('/edit-product', isAuth, adminController.postEditProduct); 22 | 23 | router.post('/delete-product', isAuth, adminController.postDeleteProduct); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /15 - Advanced Authentication/section-code/routes/admin.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const express = require('express'); 4 | 5 | const adminController = require('../controllers/admin'); 6 | const isAuth = require('../middleware/is-auth'); 7 | 8 | const router = express.Router(); 9 | 10 | // /admin/add-product => GET 11 | router.get('/add-product', isAuth, adminController.getAddProduct); 12 | 13 | // /admin/products => GET 14 | router.get('/products', isAuth, adminController.getProducts); 15 | 16 | // /admin/add-product => POST 17 | router.post('/add-product', isAuth, adminController.postAddProduct); 18 | 19 | router.get('/edit-product/:productId', isAuth, adminController.getEditProduct); 20 | 21 | router.post('/edit-product', isAuth, adminController.postEditProduct); 22 | 23 | router.post('/delete-product', isAuth, adminController.postDeleteProduct); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /24 - Understanding Async Await in Node.js/assignment-code/frontend/src/components/Navigation/MainNavigation/MainNavigation.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { NavLink } from 'react-router-dom'; 3 | 4 | import MobileToggle from '../MobileToggle/MobileToggle'; 5 | import Logo from '../../Logo/Logo'; 6 | import NavigationItems from '../NavigationItems/NavigationItems'; 7 | 8 | import './MainNavigation.css'; 9 | 10 | const mainNavigation = props => ( 11 | 23 | ); 24 | 25 | export default mainNavigation; 26 | --------------------------------------------------------------------------------