├── 04-store-api ├── final │ ├── README.md │ ├── .gitignore │ ├── middleware │ │ ├── not-found.js │ │ └── error-handler.js │ ├── db │ │ └── connect.js │ ├── routes │ │ └── products.js │ ├── package.json │ ├── populate.js │ └── models │ │ └── product.js └── starter │ ├── README.md │ ├── populate.js │ ├── models │ └── product.js │ ├── routes │ └── products.js │ ├── controllers │ └── products.js │ ├── .gitignore │ ├── app.js │ ├── middleware │ ├── not-found.js │ └── error-handler.js │ ├── db │ └── connect.js │ └── package.json ├── 06-jobs-api ├── starter │ ├── models │ │ ├── Job.js │ │ └── User.js │ ├── routes │ │ ├── auth.js │ │ └── jobs.js │ ├── controllers │ │ ├── auth.js │ │ └── jobs.js │ ├── middleware │ │ ├── authentication.js │ │ ├── not-found.js │ │ └── error-handler.js │ ├── .gitignore │ ├── errors │ │ ├── custom-api.js │ │ ├── not-found.js │ │ ├── bad-request.js │ │ ├── index.js │ │ └── unauthenticated.js │ ├── db │ │ └── connect.js │ ├── app.js │ └── package.json └── final │ ├── Procfile │ ├── .gitignore │ ├── middleware │ ├── not-found.js │ └── authentication.js │ ├── errors │ ├── custom-api.js │ ├── not-found.js │ ├── bad-request.js │ ├── index.js │ └── unauthenticated.js │ ├── routes │ ├── auth.js │ └── jobs.js │ ├── db │ └── connect.js │ ├── README.MD │ └── models │ └── Job.js ├── 07-file-upload ├── final │ ├── README.MD │ ├── .gitignore │ ├── images │ │ ├── computer-1.jpeg │ │ ├── computer-2.jpeg │ │ ├── computer-3.jpeg │ │ ├── computer-4.jpeg │ │ ├── computer-5.jpeg │ │ └── computer-6.jpeg │ ├── middleware │ │ ├── not-found.js │ │ └── authentication.js │ ├── public │ │ └── uploads │ │ │ ├── computer-5.jpeg │ │ │ └── computer-6.jpeg │ ├── errors │ │ ├── custom-api.js │ │ ├── not-found.js │ │ ├── bad-request.js │ │ ├── index.js │ │ └── unauthenticated.js │ ├── db │ │ └── connect.js │ ├── models │ │ └── Product.js │ ├── routes │ │ └── productRoutes.js │ └── controllers │ │ └── productController.js └── starter │ ├── README.MD │ ├── models │ └── Product.js │ ├── routes │ └── productRoutes.js │ ├── .gitignore │ ├── controllers │ ├── productController.js │ └── uploadsController.js │ ├── images │ ├── computer-1.jpeg │ ├── computer-2.jpeg │ ├── computer-3.jpeg │ ├── computer-4.jpeg │ ├── computer-5.jpeg │ └── computer-6.jpeg │ ├── middleware │ ├── not-found.js │ └── authentication.js │ ├── errors │ ├── custom-api.js │ ├── not-found.js │ ├── bad-request.js │ ├── index.js │ └── unauthenticated.js │ └── db │ └── connect.js ├── 08-send-email ├── final │ ├── README.MD │ ├── .gitignore │ ├── middleware │ │ ├── not-found.js │ │ └── authentication.js │ ├── errors │ │ ├── custom-api.js │ │ ├── not-found.js │ │ ├── bad-request.js │ │ ├── index.js │ │ └── unauthenticated.js │ └── db │ │ └── connect.js └── starter │ ├── README.MD │ ├── controllers │ └── sendEmail.js │ ├── .gitignore │ ├── middleware │ ├── not-found.js │ └── authentication.js │ ├── errors │ ├── custom-api.js │ ├── not-found.js │ ├── bad-request.js │ ├── index.js │ └── unauthenticated.js │ ├── db │ └── connect.js │ └── app.js ├── 09-stripe-payment ├── final │ ├── README.MD │ ├── .gitignore │ ├── middleware │ │ ├── not-found.js │ │ └── authentication.js │ ├── errors │ │ ├── custom-api.js │ │ ├── not-found.js │ │ ├── bad-request.js │ │ ├── index.js │ │ └── unauthenticated.js │ ├── db │ │ └── connect.js │ └── controllers │ │ └── stripeController.js └── starter │ ├── README.MD │ ├── .gitignore │ ├── controllers │ └── stripeController.js │ ├── middleware │ ├── not-found.js │ └── authentication.js │ ├── errors │ ├── custom-api.js │ ├── not-found.js │ ├── bad-request.js │ ├── index.js │ └── unauthenticated.js │ ├── db │ └── connect.js │ └── app.js ├── 05-JWT-Basics ├── starter │ ├── routes │ │ └── main.js │ ├── controllers │ │ └── main.js │ ├── middleware │ │ ├── auth.js │ │ ├── not-found.js │ │ └── error-handler.js │ ├── .gitignore │ ├── errors │ │ └── custom-error.js │ ├── db │ │ └── connect.js │ ├── package.json │ └── app.js └── final │ ├── .gitignore │ ├── middleware │ ├── not-found.js │ ├── error-handler.js │ └── auth.js │ ├── errors │ ├── custom-error.js │ ├── index.js │ ├── bad-request.js │ └── unauthenticated.js │ ├── db │ └── connect.js │ ├── routes │ └── main.js │ ├── package.json │ └── app.js ├── 02-express-tutorial ├── .gitignore ├── app.js ├── navbar-app │ └── browser-app.js ├── final │ ├── 06-basic-json.js │ ├── 14-router-auth.js │ ├── 04-express-app.js │ ├── 12-router-app.js │ ├── 05-all-static.js │ ├── 08-middleware-basic.js │ ├── 03-express-basics.js │ ├── 09-middleware-use.js │ ├── 13-router-people.js │ ├── 01-http-basics.js │ └── 10-middleware-options.js └── package.json ├── 06.5-jobster-api ├── final │ ├── Procfile │ ├── .gitignore │ ├── client │ │ ├── build │ │ │ ├── _redirects │ │ │ ├── robots.txt │ │ │ ├── favicon.ico │ │ │ ├── logo192.png │ │ │ ├── logo512.png │ │ │ ├── manifest.json │ │ │ ├── index.html │ │ │ └── asset-manifest.json │ │ ├── public │ │ │ ├── _redirects │ │ │ ├── robots.txt │ │ │ ├── favicon.ico │ │ │ ├── logo192.png │ │ │ ├── logo512.png │ │ │ └── manifest.json │ │ ├── src │ │ │ ├── assets │ │ │ │ ├── images │ │ │ │ │ └── favicon.ico │ │ │ │ └── wrappers │ │ │ │ │ ├── StatsContainer.js │ │ │ │ │ ├── ChartsContainer.js │ │ │ │ │ ├── JobInfo.js │ │ │ │ │ ├── SharedLayout.js │ │ │ │ │ ├── JobsContainer.js │ │ │ │ │ ├── ErrorPage.js │ │ │ │ │ └── RegisterPage.js │ │ │ ├── components │ │ │ │ ├── Loading.js │ │ │ │ ├── Logo.js │ │ │ │ ├── JobInfo.js │ │ │ │ ├── StatItem.js │ │ │ │ ├── FormRow.js │ │ │ │ ├── BarChart.js │ │ │ │ ├── index.js │ │ │ │ ├── AreaChart.js │ │ │ │ ├── FormRowSelect.js │ │ │ │ ├── NavLinks.js │ │ │ │ ├── BigSidebar.js │ │ │ │ └── ChartsContainer.js │ │ │ ├── pages │ │ │ │ ├── index.js │ │ │ │ ├── dashboard │ │ │ │ │ ├── AllJobs.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── SharedLayout.js │ │ │ │ │ └── Stats.js │ │ │ │ ├── ProtectedRoute.js │ │ │ │ └── Error.js │ │ │ ├── utils │ │ │ │ ├── authHeader.js │ │ │ │ ├── localStorage.js │ │ │ │ ├── links.js │ │ │ │ └── axios.js │ │ │ ├── store.js │ │ │ └── index.js │ │ └── .gitignore │ ├── middleware │ │ ├── not-found.js │ │ └── testUser.js │ ├── errors │ │ ├── custom-api.js │ │ ├── not-found.js │ │ ├── bad-request.js │ │ ├── index.js │ │ └── unauthenticated.js │ ├── db │ │ └── connect.js │ ├── populate.js │ └── routes │ │ ├── jobs.js │ │ └── auth.js └── starter │ ├── Procfile │ ├── client │ ├── build │ │ ├── _redirects │ │ ├── robots.txt │ │ ├── favicon.ico │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ ├── index.html │ │ └── asset-manifest.json │ ├── public │ │ ├── _redirects │ │ ├── robots.txt │ │ ├── favicon.ico │ │ ├── logo192.png │ │ ├── logo512.png │ │ └── manifest.json │ ├── src │ │ ├── assets │ │ │ ├── images │ │ │ │ └── favicon.ico │ │ │ └── wrappers │ │ │ │ ├── StatsContainer.js │ │ │ │ ├── ChartsContainer.js │ │ │ │ ├── JobInfo.js │ │ │ │ ├── SharedLayout.js │ │ │ │ ├── JobsContainer.js │ │ │ │ ├── ErrorPage.js │ │ │ │ └── RegisterPage.js │ │ ├── components │ │ │ ├── Loading.js │ │ │ ├── Logo.js │ │ │ ├── JobInfo.js │ │ │ ├── StatItem.js │ │ │ ├── FormRow.js │ │ │ ├── BarChart.js │ │ │ ├── index.js │ │ │ ├── AreaChart.js │ │ │ ├── FormRowSelect.js │ │ │ ├── NavLinks.js │ │ │ ├── BigSidebar.js │ │ │ └── ChartsContainer.js │ │ ├── pages │ │ │ ├── index.js │ │ │ ├── dashboard │ │ │ │ ├── AllJobs.js │ │ │ │ ├── index.js │ │ │ │ ├── SharedLayout.js │ │ │ │ └── Stats.js │ │ │ ├── ProtectedRoute.js │ │ │ └── Error.js │ │ ├── utils │ │ │ ├── authHeader.js │ │ │ ├── localStorage.js │ │ │ ├── links.js │ │ │ └── axios.js │ │ ├── store.js │ │ └── index.js │ └── .gitignore │ ├── middleware │ ├── not-found.js │ └── authentication.js │ ├── errors │ ├── custom-api.js │ ├── not-found.js │ ├── bad-request.js │ ├── index.js │ └── unauthenticated.js │ ├── routes │ ├── auth.js │ └── jobs.js │ ├── db │ └── connect.js │ └── models │ └── Job.js ├── 10-e-commerce-api ├── final │ ├── Procfile │ ├── .gitignore │ ├── public │ │ └── uploads │ │ │ ├── couch.jpeg │ │ │ └── example.jpeg │ ├── middleware │ │ └── not-found.js │ ├── errors │ │ ├── custom-api.js │ │ ├── not-found.js │ │ ├── bad-request.js │ │ ├── unauthorized.js │ │ ├── unauthenticated.js │ │ └── index.js │ ├── db │ │ └── connect.js │ ├── utils │ │ ├── createTokenUser.js │ │ ├── index.js │ │ ├── checkPermissions.js │ │ └── jwt.js │ ├── routes │ │ ├── authRoutes.js │ │ ├── reviewRoutes.js │ │ ├── orderRoutes.js │ │ └── userRoutes.js │ └── models │ │ └── temp.js ├── starter │ ├── Procfile │ ├── .gitignore │ ├── middleware │ │ ├── authentication.js │ │ └── not-found.js │ ├── app.js │ ├── errors │ │ ├── custom-api.js │ │ ├── not-found.js │ │ ├── bad-request.js │ │ ├── index.js │ │ └── unauthenticated.js │ └── db │ │ └── connect.js └── final-front-end │ └── react-front-end │ ├── public │ ├── robots.txt │ ├── _redirects │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ └── manifest.json │ ├── src │ └── index.js │ └── .gitignore ├── 01-node-tutorial ├── content │ ├── subfolder │ │ └── test.txt │ ├── first.txt │ ├── second.txt │ ├── result-async.txt │ ├── result-mind-grenade.txt │ └── result-sync.txt ├── .gitignore ├── app.js ├── 05-utils.js ├── 04-names.js ├── 06-alternative-flavor.js ├── 07-mind-grenade.js ├── 15-create-big-file.js ├── 01-intro.js ├── 1-event-loop-examples │ ├── 3-setInterval.js │ ├── 2-setTimeout.js │ ├── 4-server.js │ └── 1-read-file.js ├── 03-modules.js ├── 09-path-module.js ├── package.json ├── 02-globals.js ├── 14-request-event.js ├── 08-os-module.js ├── 10-fs-sync.js ├── 17-http-stream.js ├── 16-streams.js ├── 2-async-patterns │ └── 1-block.js ├── 13-event-emitter.js └── 11-fs-async.js ├── 03-task-manager ├── final │ ├── .gitignore │ ├── public │ │ └── favicon.ico │ ├── middleware │ │ ├── not-found.js │ │ ├── async.js │ │ └── error-handler.js │ ├── README.MD │ ├── db │ │ └── connect.js │ ├── errors │ │ └── custom-error.js │ ├── routes │ │ └── tasks.js │ ├── models │ │ └── Task.js │ └── package.json └── starter │ ├── .gitignore │ ├── app.js │ ├── public │ └── favicon.ico │ └── package.json └── 11-auth-workflow ├── final ├── server │ ├── Procfile │ ├── .gitignore │ ├── middleware │ │ └── not-found.js │ ├── public │ │ └── uploads │ │ │ ├── couch.jpeg │ │ │ └── example.jpeg │ ├── errors │ │ ├── custom-api.js │ │ ├── not-found.js │ │ ├── bad-request.js │ │ ├── unauthorized.js │ │ ├── unauthenticated.js │ │ └── index.js │ ├── db │ │ └── connect.js │ ├── utils │ │ ├── createTokenUser.js │ │ ├── createHash.js │ │ ├── nodemailerConfig.js │ │ ├── checkPermissions.js │ │ ├── sendEmail.js │ │ ├── sendResetPasswordEmail.js │ │ ├── index.js │ │ └── sendVerficationEmail.js │ ├── models │ │ └── Token.js │ └── routes │ │ ├── reviewRoutes.js │ │ ├── authRoutes.js │ │ ├── orderRoutes.js │ │ └── userRoutes.js ├── .DS_Store └── front-end │ ├── src │ ├── utils │ │ ├── url.js │ │ └── localState.js │ ├── index.js │ ├── components │ │ └── FormRow.js │ └── pages │ │ ├── ProtectedRoute.js │ │ ├── index.js │ │ └── Error.js │ ├── public │ ├── robots.txt │ ├── _redirects │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ └── manifest.json │ └── .gitignore ├── starter ├── server │ ├── Procfile │ ├── .gitignore │ ├── middleware │ │ └── not-found.js │ ├── public │ │ └── uploads │ │ │ ├── couch.jpeg │ │ │ └── example.jpeg │ ├── errors │ │ ├── custom-api.js │ │ ├── not-found.js │ │ ├── bad-request.js │ │ ├── unauthorized.js │ │ ├── unauthenticated.js │ │ └── index.js │ ├── db │ │ └── connect.js │ ├── utils │ │ ├── createTokenUser.js │ │ ├── index.js │ │ ├── checkPermissions.js │ │ └── jwt.js │ ├── routes │ │ ├── authRoutes.js │ │ ├── reviewRoutes.js │ │ ├── orderRoutes.js │ │ └── userRoutes.js │ └── models │ │ └── temp.js ├── front-end │ ├── src │ │ ├── utils │ │ │ ├── url.js │ │ │ └── localState.js │ │ ├── index.js │ │ ├── components │ │ │ └── FormRow.js │ │ └── pages │ │ │ ├── ProtectedRoute.js │ │ │ ├── index.js │ │ │ └── Error.js │ ├── public │ │ ├── robots.txt │ │ ├── _redirects │ │ ├── favicon.ico │ │ ├── logo192.png │ │ ├── logo512.png │ │ └── manifest.json │ └── .gitignore └── .DS_Store └── .DS_Store /04-store-api/final/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /04-store-api/starter/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /04-store-api/starter/populate.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06-jobs-api/starter/models/Job.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /07-file-upload/final/README.MD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /07-file-upload/starter/README.MD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /08-send-email/final/README.MD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /08-send-email/starter/README.MD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /09-stripe-payment/final/README.MD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /04-store-api/starter/models/product.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /05-JWT-Basics/starter/routes/main.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06-jobs-api/starter/models/User.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06-jobs-api/starter/routes/auth.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06-jobs-api/starter/routes/jobs.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /09-stripe-payment/starter/README.MD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /02-express-tutorial/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules -------------------------------------------------------------------------------- /04-store-api/starter/routes/products.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /05-JWT-Basics/starter/controllers/main.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /05-JWT-Basics/starter/middleware/auth.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06-jobs-api/final/Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js -------------------------------------------------------------------------------- /06-jobs-api/starter/controllers/auth.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06-jobs-api/starter/controllers/jobs.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /07-file-upload/starter/models/Product.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /04-store-api/starter/controllers/products.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06-jobs-api/starter/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js -------------------------------------------------------------------------------- /07-file-upload/starter/routes/productRoutes.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /08-send-email/starter/controllers/sendEmail.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js -------------------------------------------------------------------------------- /01-node-tutorial/content/subfolder/test.txt: -------------------------------------------------------------------------------- 1 | test txt -------------------------------------------------------------------------------- /04-store-api/final/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /04-store-api/starter/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /05-JWT-Basics/final/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /06-jobs-api/final/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /06-jobs-api/starter/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /06.5-jobster-api/starter/Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js -------------------------------------------------------------------------------- /07-file-upload/final/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /08-send-email/final/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /10-e-commerce-api/starter/Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js -------------------------------------------------------------------------------- /03-task-manager/final/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /03-task-manager/starter/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /05-JWT-Basics/starter/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /06.5-jobster-api/final/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /07-file-upload/starter/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /07-file-upload/starter/controllers/productController.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /07-file-upload/starter/controllers/uploadsController.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /08-send-email/starter/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /09-stripe-payment/final/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /09-stripe-payment/starter/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /09-stripe-payment/starter/controllers/stripeController.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /10-e-commerce-api/starter/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /10-e-commerce-api/starter/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js -------------------------------------------------------------------------------- /01-node-tutorial/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /content/big.txt -------------------------------------------------------------------------------- /01-node-tutorial/content/first.txt: -------------------------------------------------------------------------------- 1 | Hello this is first text file -------------------------------------------------------------------------------- /02-express-tutorial/app.js: -------------------------------------------------------------------------------- 1 | console.log('Express Tutorial') 2 | -------------------------------------------------------------------------------- /04-store-api/starter/app.js: -------------------------------------------------------------------------------- 1 | console.log('04 Store API') 2 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /01-node-tutorial/app.js: -------------------------------------------------------------------------------- 1 | console.log('Welcome to Node Tutorial') 2 | -------------------------------------------------------------------------------- /01-node-tutorial/content/second.txt: -------------------------------------------------------------------------------- 1 | Hello this is second text file -------------------------------------------------------------------------------- /03-task-manager/starter/app.js: -------------------------------------------------------------------------------- 1 | console.log('Task Manager App') 2 | -------------------------------------------------------------------------------- /10-e-commerce-api/starter/app.js: -------------------------------------------------------------------------------- 1 | console.log('E-Commerce API'); 2 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | .env -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/build/_redirects: -------------------------------------------------------------------------------- 1 | /* /index.html 200 2 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/public/_redirects: -------------------------------------------------------------------------------- 1 | /* /index.html 200 2 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/build/_redirects: -------------------------------------------------------------------------------- 1 | /* /index.html 200 2 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/public/_redirects: -------------------------------------------------------------------------------- 1 | /* /index.html 200 2 | -------------------------------------------------------------------------------- /11-auth-workflow/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/.DS_Store -------------------------------------------------------------------------------- /01-node-tutorial/content/result-async.txt: -------------------------------------------------------------------------------- 1 | Here is the result : Hello this is first text file, Hello this is second text file -------------------------------------------------------------------------------- /11-auth-workflow/final/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/final/.DS_Store -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/src/utils/url.js: -------------------------------------------------------------------------------- 1 | const url = 'http://localhost:5000'; 2 | 3 | export default url; 4 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/src/utils/url.js: -------------------------------------------------------------------------------- 1 | const url = 'http://localhost:5000'; 2 | 3 | export default url; 4 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/build/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/build/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/starter/.DS_Store -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /03-task-manager/final/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/03-task-manager/final/public/favicon.ico -------------------------------------------------------------------------------- /03-task-manager/starter/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/03-task-manager/starter/public/favicon.ico -------------------------------------------------------------------------------- /07-file-upload/final/images/computer-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/final/images/computer-1.jpeg -------------------------------------------------------------------------------- /07-file-upload/final/images/computer-2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/final/images/computer-2.jpeg -------------------------------------------------------------------------------- /07-file-upload/final/images/computer-3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/final/images/computer-3.jpeg -------------------------------------------------------------------------------- /07-file-upload/final/images/computer-4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/final/images/computer-4.jpeg -------------------------------------------------------------------------------- /07-file-upload/final/images/computer-5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/final/images/computer-5.jpeg -------------------------------------------------------------------------------- /07-file-upload/final/images/computer-6.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/final/images/computer-6.jpeg -------------------------------------------------------------------------------- /10-e-commerce-api/final-front-end/react-front-end/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/public/_redirects: -------------------------------------------------------------------------------- 1 | /api/* https://user-workflow-11.herokuapp.com/api/:splat 200 2 | 3 | /* /index.html 200 4 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/public/_redirects: -------------------------------------------------------------------------------- 1 | /api/* https://user-workflow-11.herokuapp.com/api/:splat 200 2 | 3 | /* /index.html 200 4 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/build/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/final/client/build/favicon.ico -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/build/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/final/client/build/logo192.png -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/build/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/final/client/build/logo512.png -------------------------------------------------------------------------------- /07-file-upload/starter/images/computer-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/starter/images/computer-1.jpeg -------------------------------------------------------------------------------- /07-file-upload/starter/images/computer-2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/starter/images/computer-2.jpeg -------------------------------------------------------------------------------- /07-file-upload/starter/images/computer-3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/starter/images/computer-3.jpeg -------------------------------------------------------------------------------- /07-file-upload/starter/images/computer-4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/starter/images/computer-4.jpeg -------------------------------------------------------------------------------- /07-file-upload/starter/images/computer-5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/starter/images/computer-5.jpeg -------------------------------------------------------------------------------- /07-file-upload/starter/images/computer-6.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/starter/images/computer-6.jpeg -------------------------------------------------------------------------------- /01-node-tutorial/05-utils.js: -------------------------------------------------------------------------------- 1 | const sayHi = (name) => { 2 | console.log(`Hello there ${name}`) 3 | } 4 | // export default 5 | module.exports = sayHi 6 | -------------------------------------------------------------------------------- /04-store-api/final/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /06-jobs-api/final/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /06-jobs-api/starter/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/final/client/public/favicon.ico -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/final/client/public/logo192.png -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/final/client/public/logo512.png -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/build/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/starter/client/build/favicon.ico -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/build/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/starter/client/build/logo192.png -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/build/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/starter/client/build/logo512.png -------------------------------------------------------------------------------- /08-send-email/final/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /10-e-commerce-api/final-front-end/react-front-end/public/_redirects: -------------------------------------------------------------------------------- 1 | /api/* https://user-workflow-11.herokuapp.com/api/:splat 200 2 | 3 | /* /index.html 200 -------------------------------------------------------------------------------- /10-e-commerce-api/final/public/uploads/couch.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/10-e-commerce-api/final/public/uploads/couch.jpeg -------------------------------------------------------------------------------- /03-task-manager/final/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /04-store-api/starter/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /05-JWT-Basics/starter/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/starter/client/public/favicon.ico -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/starter/client/public/logo192.png -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/starter/client/public/logo512.png -------------------------------------------------------------------------------- /06.5-jobster-api/starter/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /07-file-upload/final/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /07-file-upload/final/public/uploads/computer-5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/final/public/uploads/computer-5.jpeg -------------------------------------------------------------------------------- /07-file-upload/final/public/uploads/computer-6.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/07-file-upload/final/public/uploads/computer-6.jpeg -------------------------------------------------------------------------------- /07-file-upload/starter/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /08-send-email/starter/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /09-stripe-payment/final/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/public/uploads/example.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/10-e-commerce-api/final/public/uploads/example.jpeg -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/final/front-end/public/favicon.ico -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/final/front-end/public/logo192.png -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/final/front-end/public/logo512.png -------------------------------------------------------------------------------- /09-stripe-payment/starter/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /10-e-commerce-api/starter/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/starter/front-end/public/favicon.ico -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/starter/front-end/public/logo192.png -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/starter/front-end/public/logo512.png -------------------------------------------------------------------------------- /11-auth-workflow/final/server/public/uploads/couch.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/final/server/public/uploads/couch.jpeg -------------------------------------------------------------------------------- /11-auth-workflow/final/server/public/uploads/example.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/final/server/public/uploads/example.jpeg -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/middleware/not-found.js: -------------------------------------------------------------------------------- 1 | const notFound = (req, res) => res.status(404).send('Route does not exist') 2 | 3 | module.exports = notFound 4 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/public/uploads/couch.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/starter/server/public/uploads/couch.jpeg -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/final/client/src/assets/images/favicon.ico -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/public/uploads/example.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/11-auth-workflow/starter/server/public/uploads/example.jpeg -------------------------------------------------------------------------------- /01-node-tutorial/04-names.js: -------------------------------------------------------------------------------- 1 | // local 2 | const secret = 'SUPER SECRET' 3 | // share 4 | const john = 'john' 5 | const peter = 'peter' 6 | 7 | module.exports = { john, peter } 8 | -------------------------------------------------------------------------------- /01-node-tutorial/06-alternative-flavor.js: -------------------------------------------------------------------------------- 1 | module.exports.items = ['item1', 'item2'] 2 | const person = { 3 | name: 'bob', 4 | } 5 | 6 | module.exports.singlePerson = person 7 | -------------------------------------------------------------------------------- /01-node-tutorial/07-mind-grenade.js: -------------------------------------------------------------------------------- 1 | const num1 = 5 2 | const num2 = 10 3 | 4 | function addValues() { 5 | console.log(`the sum is : ${num1 + num2}`) 6 | } 7 | 8 | addValues() 9 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/06.5-jobster-api/starter/client/src/assets/images/favicon.ico -------------------------------------------------------------------------------- /06-jobs-api/final/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /06-jobs-api/starter/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /08-send-email/final/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/errors/custom-error.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /07-file-upload/final/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /07-file-upload/starter/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /08-send-email/starter/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /09-stripe-payment/final/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url); 5 | }; 6 | 7 | module.exports = connectDB; 8 | -------------------------------------------------------------------------------- /09-stripe-payment/starter/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /10-e-commerce-api/final-front-end/react-front-end/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/10-e-commerce-api/final-front-end/react-front-end/public/favicon.ico -------------------------------------------------------------------------------- /10-e-commerce-api/final-front-end/react-front-end/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/10-e-commerce-api/final-front-end/react-front-end/public/logo192.png -------------------------------------------------------------------------------- /10-e-commerce-api/final-front-end/react-front-end/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snowMan128/node-express/HEAD/10-e-commerce-api/final-front-end/react-front-end/public/logo512.png -------------------------------------------------------------------------------- /10-e-commerce-api/final/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url); 5 | }; 6 | 7 | module.exports = connectDB; 8 | -------------------------------------------------------------------------------- /10-e-commerce-api/starter/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /10-e-commerce-api/starter/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url); 5 | }; 6 | 7 | module.exports = connectDB; 8 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url); 5 | }; 6 | 7 | module.exports = connectDB; 8 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/errors/custom-api.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message) { 3 | super(message) 4 | } 5 | } 6 | 7 | module.exports = CustomAPIError 8 | -------------------------------------------------------------------------------- /01-node-tutorial/15-create-big-file.js: -------------------------------------------------------------------------------- 1 | const { writeFileSync } = require('fs') 2 | for (let i = 0; i < 10000; i++) { 3 | writeFileSync('./content/big.txt', `hello world ${i}\n`, { flag: 'a' }) 4 | } 5 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/utils/createTokenUser.js: -------------------------------------------------------------------------------- 1 | const createTokenUser = (user) => { 2 | return { name: user.name, userId: user._id, role: user.role }; 3 | }; 4 | 5 | module.exports = createTokenUser; 6 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url); 5 | }; 6 | 7 | module.exports = connectDB; 8 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/Loading.js: -------------------------------------------------------------------------------- 1 | const Loading = ({ center }) => { 2 | return
; 3 | }; 4 | export default Loading; 5 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/utils/createTokenUser.js: -------------------------------------------------------------------------------- 1 | const createTokenUser = (user) => { 2 | return { name: user.name, userId: user._id, role: user.role }; 3 | }; 4 | 5 | module.exports = createTokenUser; 6 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/Loading.js: -------------------------------------------------------------------------------- 1 | const Loading = ({ center }) => { 2 | return
; 3 | }; 4 | export default Loading; 5 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/utils/createTokenUser.js: -------------------------------------------------------------------------------- 1 | const createTokenUser = (user) => { 2 | return { name: user.name, userId: user._id, role: user.role }; 3 | }; 4 | 5 | module.exports = createTokenUser; 6 | -------------------------------------------------------------------------------- /01-node-tutorial/01-intro.js: -------------------------------------------------------------------------------- 1 | const amount = 9 2 | 3 | if (amount < 10) { 4 | console.log('small number') 5 | } else { 6 | console.log('large number') 7 | } 8 | 9 | console.log(`hey it's my first node app!!!`) 10 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/utils/createHash.js: -------------------------------------------------------------------------------- 1 | const crypto = require('crypto'); 2 | 3 | const hashString = (string) => 4 | crypto.createHash('md5').update(string).digest('hex'); 5 | 6 | module.exports = hashString; 7 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/Logo.js: -------------------------------------------------------------------------------- 1 | import logo from '../assets/images/logo.svg'; 2 | 3 | const Logo = () => { 4 | return jobster logo; 5 | }; 6 | export default Logo; 7 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/Logo.js: -------------------------------------------------------------------------------- 1 | import logo from '../assets/images/logo.svg'; 2 | 3 | const Logo = () => { 4 | return jobster logo; 5 | }; 6 | export default Logo; 7 | -------------------------------------------------------------------------------- /03-task-manager/final/README.MD: -------------------------------------------------------------------------------- 1 | ## Project Setup 2 | 3 | In order to run the project, setup .env and set MONGO_URI variable equal to DB connection string. 4 | 5 | In order to avoid port collisions, in the source code port value is 5000 6 | -------------------------------------------------------------------------------- /05-JWT-Basics/starter/errors/custom-error.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message, statusCode) { 3 | super(message) 4 | this.statusCode = statusCode 5 | } 6 | } 7 | 8 | module.exports = CustomAPIError 9 | -------------------------------------------------------------------------------- /01-node-tutorial/1-event-loop-examples/3-setInterval.js: -------------------------------------------------------------------------------- 1 | setInterval(() => { 2 | console.log('hello world') 3 | }, 2000) 4 | console.log(`I will run first`) 5 | // process stays alive unless 6 | // Kill Process CONTROL + C 7 | // unexpected error 8 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/utils/nodemailerConfig.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | host: 'smtp.ethereal.email', 3 | port: 587, 4 | auth: { 5 | user: 'tommie.schamberger92@ethereal.email', 6 | pass: '3FzkhF7Ut17qFdx3Qx', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /01-node-tutorial/1-event-loop-examples/2-setTimeout.js: -------------------------------------------------------------------------------- 1 | // started operating system process 2 | console.log('first') 3 | setTimeout(() => { 4 | console.log('second') 5 | }, 0) 6 | console.log('third') 7 | // completed and exited operating system process 8 | -------------------------------------------------------------------------------- /02-express-tutorial/navbar-app/browser-app.js: -------------------------------------------------------------------------------- 1 | const navToggle = document.querySelector('.nav-toggle') 2 | const links = document.querySelector('.links') 3 | 4 | navToggle.addEventListener('click', function () { 5 | links.classList.toggle('show-links') 6 | }) 7 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import Error from './Error'; 2 | import Landing from './Landing'; 3 | import ProtectedRoute from './ProtectedRoute'; 4 | import Register from './Register'; 5 | 6 | export { Landing, Error, Register, ProtectedRoute }; 7 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/utils/authHeader.js: -------------------------------------------------------------------------------- 1 | const authHeader = (thunkAPI) => { 2 | return { 3 | headers: { 4 | authorization: `Bearer ${thunkAPI.getState().user.user.token}`, 5 | }, 6 | }; 7 | }; 8 | 9 | export default authHeader; 10 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import Error from './Error'; 2 | import Landing from './Landing'; 3 | import ProtectedRoute from './ProtectedRoute'; 4 | import Register from './Register'; 5 | 6 | export { Landing, Error, Register, ProtectedRoute }; 7 | -------------------------------------------------------------------------------- /04-store-api/final/middleware/error-handler.js: -------------------------------------------------------------------------------- 1 | const errorHandlerMiddleware = async (err, req, res, next) => { 2 | console.log(err) 3 | return res.status(500).json({ msg: 'Something went wrong, please try again' }) 4 | } 5 | 6 | module.exports = errorHandlerMiddleware 7 | -------------------------------------------------------------------------------- /06-jobs-api/final/routes/auth.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const router = express.Router() 3 | const { register, login } = require('../controllers/auth') 4 | router.post('/register', register) 5 | router.post('/login', login) 6 | 7 | module.exports = router 8 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/utils/authHeader.js: -------------------------------------------------------------------------------- 1 | const authHeader = (thunkAPI) => { 2 | return { 3 | headers: { 4 | authorization: `Bearer ${thunkAPI.getState().user.user.token}`, 5 | }, 6 | }; 7 | }; 8 | 9 | export default authHeader; 10 | -------------------------------------------------------------------------------- /01-node-tutorial/content/result-mind-grenade.txt: -------------------------------------------------------------------------------- 1 | THIS IS AWESOME : Hello this is first text file Hello this is second text fileTHIS IS AWESOME : Hello this is first text file Hello this is second text fileTHIS IS AWESOME : Hello this is first text file Hello this is second text file -------------------------------------------------------------------------------- /04-store-api/starter/middleware/error-handler.js: -------------------------------------------------------------------------------- 1 | const errorHandlerMiddleware = async (err, req, res, next) => { 2 | console.log(err) 3 | return res.status(500).json({ msg: 'Something went wrong, please try again' }) 4 | } 5 | 6 | module.exports = errorHandlerMiddleware 7 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/routes/auth.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const router = express.Router() 3 | const { register, login } = require('../controllers/auth') 4 | router.post('/register', register) 5 | router.post('/login', login) 6 | 7 | module.exports = router 8 | -------------------------------------------------------------------------------- /01-node-tutorial/content/result-sync.txt: -------------------------------------------------------------------------------- 1 | Here is the result : Hello this is first text file, Hello this is second text fileHere is the result : Hello this is first text file, Hello this is second text fileHere is the result : Hello this is first text file, Hello this is second text file -------------------------------------------------------------------------------- /03-task-manager/final/middleware/async.js: -------------------------------------------------------------------------------- 1 | const asyncWrapper = (fn) => { 2 | return async (req, res, next) => { 3 | try { 4 | await fn(req, res, next) 5 | } catch (error) { 6 | next(error) 7 | } 8 | } 9 | } 10 | 11 | module.exports = asyncWrapper 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/middleware/testUser.js: -------------------------------------------------------------------------------- 1 | const { BadRequestError } = require('../errors'); 2 | 3 | const testUser = (req, res, next) => { 4 | if (req.user.testUser) { 5 | throw new BadRequestError('Test User. Read Only'); 6 | } 7 | next(); 8 | }; 9 | 10 | module.exports = testUser; 11 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/pages/dashboard/AllJobs.js: -------------------------------------------------------------------------------- 1 | import { JobsContainer, SearchContainer } from '../../components'; 2 | 3 | const AllJobs = () => { 4 | return ( 5 | <> 6 | 7 | 8 | 9 | ); 10 | }; 11 | export default AllJobs; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/pages/dashboard/index.js: -------------------------------------------------------------------------------- 1 | import AddJob from './AddJob'; 2 | import AllJobs from './AllJobs'; 3 | import Profile from './Profile'; 4 | import SharedLayout from './SharedLayout'; 5 | import Stats from './Stats'; 6 | 7 | export { Profile, AddJob, AllJobs, Stats, SharedLayout }; 8 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/pages/dashboard/AllJobs.js: -------------------------------------------------------------------------------- 1 | import { JobsContainer, SearchContainer } from '../../components'; 2 | 3 | const AllJobs = () => { 4 | return ( 5 | <> 6 | 7 | 8 | 9 | ); 10 | }; 11 | export default AllJobs; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/pages/dashboard/index.js: -------------------------------------------------------------------------------- 1 | import AddJob from './AddJob'; 2 | import AllJobs from './AllJobs'; 3 | import Profile from './Profile'; 4 | import SharedLayout from './SharedLayout'; 5 | import Stats from './Stats'; 6 | 7 | export { Profile, AddJob, AllJobs, Stats, SharedLayout }; 8 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-error') 2 | const BadRequestError = require('./bad-request') 3 | const UnauthenticatedError = require('./unauthenticated') 4 | 5 | module.exports = { 6 | CustomAPIError, 7 | BadRequestError, 8 | UnauthenticatedError, 9 | } 10 | -------------------------------------------------------------------------------- /01-node-tutorial/1-event-loop-examples/4-server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | 3 | const server = http.createServer((req, res) => { 4 | console.log('request event') 5 | res.end('Hello World') 6 | }) 7 | 8 | server.listen(5000, () => { 9 | console.log('Server listening on port : 5000....') 10 | }) 11 | -------------------------------------------------------------------------------- /02-express-tutorial/final/06-basic-json.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const app = express() 3 | const { products } = require('./data') 4 | app.get('/', (req, res) => { 5 | res.json(products) 6 | }) 7 | 8 | app.listen(5000, () => { 9 | console.log('Server is listening on port 5000....') 10 | }) 11 | -------------------------------------------------------------------------------- /10-e-commerce-api/final-front-end/react-front-end/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | 6 | ReactDOM.render( 7 | 8 | 9 | , 10 | document.getElementById('root') 11 | ); 12 | -------------------------------------------------------------------------------- /03-task-manager/final/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /04-store-api/final/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /04-store-api/starter/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /05-JWT-Basics/starter/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /06-jobs-api/final/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /06-jobs-api/starter/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /07-file-upload/final/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /08-send-email/final/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /08-send-email/starter/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /07-file-upload/starter/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /09-stripe-payment/final/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /09-stripe-payment/starter/db/connect.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectDB = (url) => { 4 | return mongoose.connect(url, { 5 | useNewUrlParser: true, 6 | useCreateIndex: true, 7 | useFindAndModify: false, 8 | useUnifiedTopology: true, 9 | }) 10 | } 11 | 12 | module.exports = connectDB 13 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-error') 2 | const { StatusCodes } = require('http-status-codes') 3 | class BadRequest extends CustomAPIError { 4 | constructor(message) { 5 | super(message) 6 | this.statusCode = StatusCodes.BAD_REQUEST 7 | } 8 | } 9 | 10 | module.exports = BadRequest 11 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/JobInfo.js: -------------------------------------------------------------------------------- 1 | import Wrapper from '../assets/wrappers/JobInfo'; 2 | 3 | const JobInfo = ({ icon, text }) => { 4 | return ( 5 | 6 | {icon} 7 | {text} 8 | 9 | ); 10 | }; 11 | export default JobInfo; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/JobInfo.js: -------------------------------------------------------------------------------- 1 | import Wrapper from '../assets/wrappers/JobInfo'; 2 | 3 | const JobInfo = ({ icon, text }) => { 4 | return ( 5 | 6 | {icon} 7 | {text} 8 | 9 | ); 10 | }; 11 | export default JobInfo; 12 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/routes/authRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | 4 | const { register, login, logout } = require('../controllers/authController'); 5 | 6 | router.post('/register', register); 7 | router.post('/login', login); 8 | router.get('/logout', logout); 9 | 10 | module.exports = router; 11 | -------------------------------------------------------------------------------- /04-store-api/final/routes/products.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const router = express.Router() 3 | 4 | const { 5 | getAllProducts, 6 | getAllProductsStatic, 7 | } = require('../controllers/products') 8 | 9 | router.route('/').get(getAllProducts) 10 | router.route('/static').get(getAllProductsStatic) 11 | 12 | module.exports = router 13 | -------------------------------------------------------------------------------- /06-jobs-api/final/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /06-jobs-api/starter/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /07-file-upload/final/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /08-send-email/final/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /01-node-tutorial/03-modules.js: -------------------------------------------------------------------------------- 1 | // CommonJS, every file is module (by default) 2 | // Modules - Encapsulated Code (only share minimum) 3 | const names = require('./04-names') 4 | const sayHi = require('./05-utils') 5 | const data = require('./06-alternative-flavor') 6 | require('./07-mind-grenade') 7 | sayHi('susan') 8 | sayHi(names.john) 9 | sayHi(names.peter) 10 | -------------------------------------------------------------------------------- /06-jobs-api/final/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /07-file-upload/starter/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /08-send-email/starter/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /09-stripe-payment/final/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /09-stripe-payment/starter/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /10-e-commerce-api/starter/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/routes/authRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | 4 | const { register, login, logout } = require('../controllers/authController'); 5 | 6 | router.post('/register', register); 7 | router.post('/login', login); 8 | router.get('/logout', logout); 9 | 10 | module.exports = router; 11 | -------------------------------------------------------------------------------- /06-jobs-api/starter/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /07-file-upload/final/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /07-file-upload/starter/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /08-send-email/final/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /08-send-email/starter/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /06-jobs-api/final/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /09-stripe-payment/final/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /09-stripe-payment/starter/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/errors/unauthorized.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthorizedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.FORBIDDEN; 8 | } 9 | } 10 | 11 | module.exports = UnauthorizedError; 12 | -------------------------------------------------------------------------------- /10-e-commerce-api/starter/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/errors/not-found.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class NotFoundError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.NOT_FOUND; 8 | } 9 | } 10 | 11 | module.exports = NotFoundError; 12 | -------------------------------------------------------------------------------- /01-node-tutorial/09-path-module.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | console.log(path.sep) 4 | 5 | const filePath = path.join('/content/', 'subfolder', 'test.txt') 6 | console.log(filePath) 7 | 8 | const base = path.basename(filePath) 9 | console.log(base) 10 | 11 | const absolute = path.resolve(__dirname, 'content', 'subfolder', 'test.txt') 12 | console.log(absolute) 13 | -------------------------------------------------------------------------------- /02-express-tutorial/final/14-router-auth.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const router = express.Router() 3 | 4 | router.post('/', (req, res) => { 5 | const { name } = req.body 6 | if (name) { 7 | return res.status(200).send(`Welcome ${name}`) 8 | } 9 | 10 | res.status(401).send('Please Provide Credentials') 11 | }) 12 | 13 | module.exports = router 14 | -------------------------------------------------------------------------------- /03-task-manager/final/errors/custom-error.js: -------------------------------------------------------------------------------- 1 | class CustomAPIError extends Error { 2 | constructor(message, statusCode) { 3 | super(message) 4 | this.statusCode = statusCode 5 | } 6 | } 7 | 8 | const createCustomError = (msg, statusCode) => { 9 | return new CustomAPIError(msg, statusCode) 10 | } 11 | 12 | module.exports = { createCustomError, CustomAPIError } 13 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-error') 2 | const { StatusCodes } = require('http-status-codes') 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message) 7 | this.statusCode = StatusCodes.UNAUTHORIZED 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError 12 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/routes/main.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const router = express.Router() 3 | 4 | const { login, dashboard } = require('../controllers/main') 5 | 6 | const authMiddleware = require('../middleware/auth') 7 | 8 | router.route('/dashboard').get(authMiddleware, dashboard) 9 | router.route('/login').post(login) 10 | 11 | module.exports = router 12 | -------------------------------------------------------------------------------- /06-jobs-api/final/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /06-jobs-api/starter/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /07-file-upload/final/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /07-file-upload/starter/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /08-send-email/final/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /08-send-email/starter/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/errors/unauthorized.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthorizedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.FORBIDDEN; 8 | } 9 | } 10 | 11 | module.exports = UnauthorizedError; 12 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/errors/bad-request.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class BadRequestError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.BAD_REQUEST; 8 | } 9 | } 10 | 11 | module.exports = BadRequestError; 12 | -------------------------------------------------------------------------------- /06-jobs-api/starter/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /07-file-upload/final/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /07-file-upload/starter/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /08-send-email/final/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /08-send-email/starter/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /09-stripe-payment/final/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /09-stripe-payment/starter/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api') 2 | const UnauthenticatedError = require('./unauthenticated') 3 | const NotFoundError = require('./not-found') 4 | const BadRequestError = require('./bad-request') 5 | 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | } 12 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/utils/index.js: -------------------------------------------------------------------------------- 1 | const { createJWT, isTokenValid, attachCookiesToResponse } = require('./jwt'); 2 | const createTokenUser = require('./createTokenUser'); 3 | const checkPermissions = require('./checkPermissions'); 4 | module.exports = { 5 | createJWT, 6 | isTokenValid, 7 | attachCookiesToResponse, 8 | createTokenUser, 9 | checkPermissions, 10 | }; 11 | -------------------------------------------------------------------------------- /10-e-commerce-api/starter/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api'); 2 | const UnauthenticatedError = require('./unauthenticated'); 3 | const NotFoundError = require('./not-found'); 4 | const BadRequestError = require('./bad-request'); 5 | module.exports = { 6 | CustomAPIError, 7 | UnauthenticatedError, 8 | NotFoundError, 9 | BadRequestError, 10 | }; 11 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/errors/unauthorized.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthorizedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.FORBIDDEN; 8 | } 9 | } 10 | 11 | module.exports = UnauthorizedError; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /09-stripe-payment/final/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /09-stripe-payment/starter/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /10-e-commerce-api/starter/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/utils/index.js: -------------------------------------------------------------------------------- 1 | const { createJWT, isTokenValid, attachCookiesToResponse } = require('./jwt'); 2 | const createTokenUser = require('./createTokenUser'); 3 | const checkPermissions = require('./checkPermissions'); 4 | module.exports = { 5 | createJWT, 6 | isTokenValid, 7 | attachCookiesToResponse, 8 | createTokenUser, 9 | checkPermissions, 10 | }; 11 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/errors/unauthenticated.js: -------------------------------------------------------------------------------- 1 | const { StatusCodes } = require('http-status-codes'); 2 | const CustomAPIError = require('./custom-api'); 3 | 4 | class UnauthenticatedError extends CustomAPIError { 5 | constructor(message) { 6 | super(message); 7 | this.statusCode = StatusCodes.UNAUTHORIZED; 8 | } 9 | } 10 | 11 | module.exports = UnauthenticatedError; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/pages/ProtectedRoute.js: -------------------------------------------------------------------------------- 1 | import { Navigate } from 'react-router-dom'; 2 | import { useSelector } from 'react-redux'; 3 | 4 | const ProtectedRoute = ({ children }) => { 5 | const { user } = useSelector((store) => store.user); 6 | if (!user) { 7 | return ; 8 | } 9 | return children; 10 | }; 11 | export default ProtectedRoute; 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/pages/ProtectedRoute.js: -------------------------------------------------------------------------------- 1 | import { Navigate } from 'react-router-dom'; 2 | import { useSelector } from 'react-redux'; 3 | 4 | const ProtectedRoute = ({ children }) => { 5 | const { user } = useSelector((store) => store.user); 6 | if (!user) { 7 | return ; 8 | } 9 | return children; 10 | }; 11 | export default ProtectedRoute; 12 | -------------------------------------------------------------------------------- /01-node-tutorial/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tutorial", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "1-intro.js", 6 | "scripts": { 7 | "start": "nodemon app.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "lodash": "^4.17.20" 14 | }, 15 | "devDependencies": { 16 | "nodemon": "^2.0.7" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /02-express-tutorial/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "2-express-tutorial", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "nodemon app.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.17.1" 14 | }, 15 | "devDependencies": { 16 | "nodemon": "^2.0.7" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /01-node-tutorial/1-event-loop-examples/1-read-file.js: -------------------------------------------------------------------------------- 1 | const { readFile, writeFile } = require('fs') 2 | 3 | console.log('started a first task') 4 | // CHECK FILE PATH!!!! 5 | readFile('./content/first.txt', 'utf8', (err, result) => { 6 | if (err) { 7 | console.log(err) 8 | return 9 | } 10 | console.log(result) 11 | console.log('completed first task') 12 | }) 13 | console.log('starting next task') 14 | -------------------------------------------------------------------------------- /05-JWT-Basics/starter/middleware/error-handler.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('../errors/custom-error') 2 | const errorHandlerMiddleware = (err, req, res, next) => { 3 | if (err instanceof CustomAPIError) { 4 | return res.status(err.statusCode).json({ msg: err.message }) 5 | } 6 | return res.status(500).send('Something went wrong try again later') 7 | } 8 | 9 | module.exports = errorHandlerMiddleware 10 | -------------------------------------------------------------------------------- /06-jobs-api/final/routes/jobs.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | 3 | const router = express.Router() 4 | const { 5 | createJob, 6 | deleteJob, 7 | getAllJobs, 8 | updateJob, 9 | getJob, 10 | } = require('../controllers/jobs') 11 | 12 | router.route('/').post(createJob).get(getAllJobs) 13 | 14 | router.route('/:id').get(getJob).delete(deleteJob).patch(updateJob) 15 | 16 | module.exports = router 17 | -------------------------------------------------------------------------------- /01-node-tutorial/02-globals.js: -------------------------------------------------------------------------------- 1 | // GLOBALS - NO WINDOW !!!! 2 | 3 | // __dirname - path to current directory 4 | // __filename - file name 5 | // require - function to use modules (CommonJS) 6 | // module - info about current module (file) 7 | // process - info about env where the program is being executed 8 | 9 | console.log(__dirname) 10 | setInterval(() => { 11 | console.log('hello world') 12 | }, 1000) 13 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/store.js: -------------------------------------------------------------------------------- 1 | import { configureStore } from '@reduxjs/toolkit'; 2 | import jobSlice from './features/job/jobSlice'; 3 | import userSlice from './features/user/userSlice'; 4 | import allJobsSlice from './features/allJobs/allJobsSlice'; 5 | export const store = configureStore({ 6 | reducer: { 7 | user: userSlice, 8 | job: jobSlice, 9 | allJobs: allJobsSlice, 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/store.js: -------------------------------------------------------------------------------- 1 | import { configureStore } from '@reduxjs/toolkit'; 2 | import jobSlice from './features/job/jobSlice'; 3 | import userSlice from './features/user/userSlice'; 4 | import allJobsSlice from './features/allJobs/allJobsSlice'; 5 | export const store = configureStore({ 6 | reducer: { 7 | user: userSlice, 8 | job: jobSlice, 9 | allJobs: allJobsSlice, 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /07-file-upload/final/models/Product.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const ProductSchema = new mongoose.Schema({ 4 | name: { 5 | type: String, 6 | required: true, 7 | }, 8 | price: { 9 | type: Number, 10 | required: true, 11 | }, 12 | image: { 13 | type: String, 14 | required: true, 15 | }, 16 | }); 17 | 18 | module.exports = mongoose.model('Product', ProductSchema); 19 | -------------------------------------------------------------------------------- /01-node-tutorial/14-request-event.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | 3 | // const server = http.createServer((req, res) => { 4 | // res.end('Welcome') 5 | // }) 6 | 7 | // Using Event Emitter API 8 | const server = http.createServer() 9 | // emits request event 10 | // subcribe to it / listen for it / respond to it 11 | server.on('request', (req, res) => { 12 | res.end('Welcome') 13 | }) 14 | 15 | server.listen(5000) 16 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/routes/jobs.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | 3 | const router = express.Router() 4 | const { 5 | createJob, 6 | deleteJob, 7 | getAllJobs, 8 | updateJob, 9 | getJob, 10 | } = require('../controllers/jobs') 11 | 12 | router.route('/').post(createJob).get(getAllJobs) 13 | 14 | router.route('/:id').get(getJob).delete(deleteJob).patch(updateJob) 15 | 16 | module.exports = router 17 | -------------------------------------------------------------------------------- /03-task-manager/final/middleware/error-handler.js: -------------------------------------------------------------------------------- 1 | const { CustomAPIError } = require('../errors/custom-error') 2 | const errorHandlerMiddleware = (err, req, res, next) => { 3 | if (err instanceof CustomAPIError) { 4 | return res.status(err.statusCode).json({ msg: err.message }) 5 | } 6 | return res.status(500).json({ msg: 'Something went wrong, please try again' }) 7 | } 8 | 9 | module.exports = errorHandlerMiddleware 10 | -------------------------------------------------------------------------------- /01-node-tutorial/08-os-module.js: -------------------------------------------------------------------------------- 1 | const os = require('os') 2 | 3 | // info about current user 4 | const user = os.userInfo() 5 | console.log(user) 6 | 7 | // method returns the system uptime in seconds 8 | console.log(`The System Uptime is ${os.uptime()} seconds`) 9 | 10 | const currentOS = { 11 | name: os.type(), 12 | release: os.release(), 13 | totalMem: os.totalmem(), 14 | freeMem: os.freemem(), 15 | } 16 | console.log(currentOS) 17 | -------------------------------------------------------------------------------- /03-task-manager/final/routes/tasks.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const router = express.Router() 3 | 4 | const { 5 | getAllTasks, 6 | createTask, 7 | getTask, 8 | updateTask, 9 | deleteTask, 10 | editTask, 11 | } = require('../controllers/tasks') 12 | 13 | router.route('/').get(getAllTasks).post(createTask) 14 | router.route('/:id').get(getTask).patch(updateTask).delete(deleteTask) 15 | 16 | module.exports = router 17 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/assets/wrappers/StatsContainer.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | display: grid; 5 | row-gap: 2rem; 6 | @media (min-width: 768px) { 7 | grid-template-columns: 1fr 1fr; 8 | column-gap: 1rem; 9 | } 10 | @media (min-width: 1120px) { 11 | grid-template-columns: 1fr 1fr 1fr; 12 | column-gap: 1rem; 13 | } 14 | ` 15 | export default Wrapper 16 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /01-node-tutorial/10-fs-sync.js: -------------------------------------------------------------------------------- 1 | const { readFileSync, writeFileSync } = require('fs') 2 | console.log('start') 3 | const first = readFileSync('./content/first.txt', 'utf8') 4 | const second = readFileSync('./content/second.txt', 'utf8') 5 | 6 | writeFileSync( 7 | './content/result-sync.txt', 8 | `Here is the result : ${first}, ${second}`, 9 | { flag: 'a' } 10 | ) 11 | console.log('done with this task') 12 | console.log('starting the next one') 13 | -------------------------------------------------------------------------------- /03-task-manager/final/models/Task.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const TaskSchema = new mongoose.Schema({ 4 | name: { 5 | type: String, 6 | required: [true, 'must provide name'], 7 | trim: true, 8 | maxlength: [20, 'name can not be more than 20 characters'], 9 | }, 10 | completed: { 11 | type: Boolean, 12 | default: false, 13 | }, 14 | }) 15 | 16 | module.exports = mongoose.model('Task', TaskSchema) 17 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/assets/wrappers/StatsContainer.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | display: grid; 5 | row-gap: 2rem; 6 | @media (min-width: 768px) { 7 | grid-template-columns: 1fr 1fr; 8 | column-gap: 1rem; 9 | } 10 | @media (min-width: 1120px) { 11 | grid-template-columns: 1fr 1fr 1fr; 12 | column-gap: 1rem; 13 | } 14 | ` 15 | export default Wrapper 16 | -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import './index.css' 4 | import 'normalize.css' 5 | import App from './App' 6 | import { AppProvider } from './context' 7 | 8 | const root = ReactDOM.createRoot(document.getElementById('root')) 9 | root.render( 10 | 11 | 12 | 13 | 14 | 15 | ) 16 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import './index.css' 4 | import 'normalize.css' 5 | import App from './App' 6 | import { AppProvider } from './context' 7 | 8 | const root = ReactDOM.createRoot(document.getElementById('root')) 9 | root.render( 10 | 11 | 12 | 13 | 14 | 15 | ) 16 | -------------------------------------------------------------------------------- /03-task-manager/final/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jobs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "nodemon app.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "dotenv": "^8.2.0", 14 | "express": "^4.17.1", 15 | "mongoose": "^5.11.10" 16 | }, 17 | "devDependencies": { 18 | "nodemon": "^2.0.7" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /06-jobs-api/starter/middleware/error-handler.js: -------------------------------------------------------------------------------- 1 | const { CustomAPIError } = require('../errors') 2 | const { StatusCodes } = require('http-status-codes') 3 | const errorHandlerMiddleware = (err, req, res, next) => { 4 | if (err instanceof CustomAPIError) { 5 | return res.status(err.statusCode).json({ msg: err.message }) 6 | } 7 | return res.status(StatusCodes.INTERNAL_SERVER_ERROR).json({ err }) 8 | } 9 | 10 | module.exports = errorHandlerMiddleware 11 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api'); 2 | const UnauthenticatedError = require('./unauthenticated'); 3 | const NotFoundError = require('./not-found'); 4 | const BadRequestError = require('./bad-request'); 5 | const UnauthorizedError = require('./unauthorized'); 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | UnauthorizedError, 12 | }; 13 | -------------------------------------------------------------------------------- /03-task-manager/starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jobs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "nodemon app.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "dotenv": "^8.2.0", 14 | "express": "^4.17.1", 15 | "mongoose": "^5.11.10" 16 | }, 17 | "devDependencies": { 18 | "nodemon": "^2.0.7" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/utils/localStorage.js: -------------------------------------------------------------------------------- 1 | export const addUserToLocalStorage = (user) => { 2 | localStorage.setItem('user', JSON.stringify(user)); 3 | }; 4 | 5 | export const removeUserFromLocalStorage = () => { 6 | localStorage.removeItem('user'); 7 | }; 8 | 9 | export const getUserFromLocalStorage = () => { 10 | const result = localStorage.getItem('user'); 11 | const user = result ? JSON.parse(result) : null; 12 | return user; 13 | }; 14 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/utils/localStorage.js: -------------------------------------------------------------------------------- 1 | export const addUserToLocalStorage = (user) => { 2 | localStorage.setItem('user', JSON.stringify(user)); 3 | }; 4 | 5 | export const removeUserFromLocalStorage = () => { 6 | localStorage.removeItem('user'); 7 | }; 8 | 9 | export const getUserFromLocalStorage = () => { 10 | const result = localStorage.getItem('user'); 11 | const user = result ? JSON.parse(result) : null; 12 | return user; 13 | }; 14 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api'); 2 | const UnauthenticatedError = require('./unauthenticated'); 3 | const NotFoundError = require('./not-found'); 4 | const BadRequestError = require('./bad-request'); 5 | const UnauthorizedError = require('./unauthorized'); 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | UnauthorizedError, 12 | }; 13 | -------------------------------------------------------------------------------- /07-file-upload/final/routes/productRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | 4 | const { 5 | createProduct, 6 | getAllProducts, 7 | } = require('../controllers/productController'); 8 | const { uploadProductImage } = require('../controllers/uploadsController'); 9 | 10 | router.route('/').post(createProduct).get(getAllProducts); 11 | router.route('/uploads').post(uploadProductImage); 12 | 13 | module.exports = router; 14 | -------------------------------------------------------------------------------- /10-e-commerce-api/final-front-end/react-front-end/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/errors/index.js: -------------------------------------------------------------------------------- 1 | const CustomAPIError = require('./custom-api'); 2 | const UnauthenticatedError = require('./unauthenticated'); 3 | const NotFoundError = require('./not-found'); 4 | const BadRequestError = require('./bad-request'); 5 | const UnauthorizedError = require('./unauthorized'); 6 | module.exports = { 7 | CustomAPIError, 8 | UnauthenticatedError, 9 | NotFoundError, 10 | BadRequestError, 11 | UnauthorizedError, 12 | }; 13 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/StatItem.js: -------------------------------------------------------------------------------- 1 | import Wrapper from '../assets/wrappers/StatItem'; 2 | 3 | const StatItem = ({ count, title, icon, color, bcg }) => { 4 | return ( 5 | 6 |
7 | {count} 8 | {icon} 9 |
10 |
{title}
11 |
12 | ); 13 | }; 14 | export default StatItem; 15 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/StatItem.js: -------------------------------------------------------------------------------- 1 | import Wrapper from '../assets/wrappers/StatItem'; 2 | 3 | const StatItem = ({ count, title, icon, color, bcg }) => { 4 | return ( 5 | 6 |
7 | {count} 8 | {icon} 9 |
10 |
{title}
11 |
12 | ); 13 | }; 14 | export default StatItem; 15 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { createRoot } from 'react-dom/client'; 3 | import 'normalize.css'; 4 | import './index.css'; 5 | import App from './App'; 6 | import { store } from './store'; 7 | import { Provider } from 'react-redux'; 8 | 9 | const container = document.getElementById('root'); 10 | const root = createRoot(container); 11 | 12 | root.render( 13 | 14 | 15 | 16 | ); 17 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { createRoot } from 'react-dom/client'; 3 | import 'normalize.css'; 4 | import './index.css'; 5 | import App from './App'; 6 | import { store } from './store'; 7 | import { Provider } from 'react-redux'; 8 | 9 | const container = document.getElementById('root'); 10 | const root = createRoot(container); 11 | 12 | root.render( 13 | 14 | 15 | 16 | ); 17 | -------------------------------------------------------------------------------- /04-store-api/final/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jobs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "nodemon app.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "dotenv": "^8.2.0", 14 | "express": "^4.17.1", 15 | "express-async-errors": "^3.1.1", 16 | "mongoose": "^5.11.10" 17 | }, 18 | "devDependencies": { 19 | "nodemon": "^2.0.7" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /01-node-tutorial/17-http-stream.js: -------------------------------------------------------------------------------- 1 | var http = require('http') 2 | var fs = require('fs') 3 | 4 | http 5 | .createServer(function (req, res) { 6 | // const text = fs.readFileSync('./content/big.txt', 'utf8') 7 | // res.end(text) 8 | const fileStream = fs.createReadStream('./content/big.txt', 'utf8') 9 | fileStream.on('open', () => { 10 | fileStream.pipe(res) 11 | }) 12 | fileStream.on('error', (err) => { 13 | res.end(err) 14 | }) 15 | }) 16 | .listen(5000) 17 | -------------------------------------------------------------------------------- /04-store-api/starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jobs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "nodemon app.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "dotenv": "^8.2.0", 14 | "express": "^4.17.1", 15 | "express-async-errors": "^3.1.1", 16 | "mongoose": "^5.11.10" 17 | }, 18 | "devDependencies": { 19 | "nodemon": "^2.0.7" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/middleware/error-handler.js: -------------------------------------------------------------------------------- 1 | const { CustomAPIError } = require('../errors') 2 | const { StatusCodes } = require('http-status-codes') 3 | const errorHandlerMiddleware = (err, req, res, next) => { 4 | if (err instanceof CustomAPIError) { 5 | return res.status(err.statusCode).json({ msg: err.message }) 6 | } 7 | return res 8 | .status(StatusCodes.INTERNAL_SERVER_ERROR) 9 | .send('Something went wrong try again later') 10 | } 11 | 12 | module.exports = errorHandlerMiddleware 13 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/populate.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | const mockData = require('./mock-data.json'); 3 | const Job = require('./models/Job'); 4 | const connectDB = require('./db/connect'); 5 | 6 | const start = async () => { 7 | try { 8 | await connectDB(process.env.MONGO_URI); 9 | await Job.create(mockData); 10 | console.log('Success !!!'); 11 | process.exit(0); 12 | } catch (error) { 13 | console.log(error); 14 | process.exit(1); 15 | } 16 | }; 17 | 18 | start(); 19 | -------------------------------------------------------------------------------- /01-node-tutorial/16-streams.js: -------------------------------------------------------------------------------- 1 | const { createReadStream } = require('fs') 2 | 3 | // default 64kb 4 | // last buffer - remainder 5 | // highWaterMark - control size 6 | // const stream = createReadStream('./content/big.txt', { highWaterMark: 90000 }) 7 | // const stream = createReadStream('../content/big.txt', { encoding: 'utf8' }) 8 | const stream = createReadStream('./content/big.txt') 9 | 10 | stream.on('data', (result) => { 11 | console.log(result) 12 | }) 13 | stream.on('error', (err) => console.log(err)) 14 | -------------------------------------------------------------------------------- /06-jobs-api/final/README.MD: -------------------------------------------------------------------------------- 1 | #### Project Setup 2 | 3 | In order to spin up the project, in the root create .env with these two variables, with your own values. 4 | 5 | MONGO_URI 6 | JWT_SECRET 7 | 8 | After that run this command 9 | 10 | ```bash 11 | npm install && npm start 12 | ``` 13 | 14 | Swagger UI 15 | 16 | ```yaml 17 | /jobs/{id}: 18 | parameters: 19 | - in: path 20 | name: id 21 | schema: 22 | type: string 23 | required: true 24 | description: the job id 25 | ``` 26 | -------------------------------------------------------------------------------- /02-express-tutorial/final/04-express-app.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const path = require('path') 3 | 4 | const app = express() 5 | 6 | // setup static and middleware 7 | app.use(express.static('./public')) 8 | 9 | app.get('/', (req, res) => { 10 | res.sendFile(path.resolve(__dirname, './navbar-app/index.html')) 11 | }) 12 | 13 | app.all('*', (req, res) => { 14 | res.status(404).send('resource not found') 15 | }) 16 | 17 | app.listen(5000, () => { 18 | console.log('server is listening on port 5000....') 19 | }) 20 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/assets/wrappers/ChartsContainer.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | margin-top: 4rem; 5 | text-align: center; 6 | button { 7 | background: transparent; 8 | border-color: transparent; 9 | text-transform: capitalize; 10 | color: var(--primary-500); 11 | font-size: 1.25rem; 12 | cursor: pointer; 13 | } 14 | h4 { 15 | text-align: center; 16 | margin-bottom: 0.75rem; 17 | } 18 | ` 19 | 20 | export default Wrapper 21 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/assets/wrappers/ChartsContainer.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | margin-top: 4rem; 5 | text-align: center; 6 | button { 7 | background: transparent; 8 | border-color: transparent; 9 | text-transform: capitalize; 10 | color: var(--primary-500); 11 | font-size: 1.25rem; 12 | cursor: pointer; 13 | } 14 | h4 { 15 | text-align: center; 16 | margin-bottom: 0.75rem; 17 | } 18 | ` 19 | 20 | export default Wrapper 21 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/FormRow.js: -------------------------------------------------------------------------------- 1 | const FormRow = ({ type, name, value, handleChange, labelText }) => { 2 | return ( 3 |
4 | 7 | 15 |
16 | ); 17 | }; 18 | export default FormRow; 19 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/FormRow.js: -------------------------------------------------------------------------------- 1 | const FormRow = ({ type, name, value, handleChange, labelText }) => { 2 | return ( 3 |
4 | 7 | 15 |
16 | ); 17 | }; 18 | export default FormRow; 19 | -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/src/components/FormRow.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const FormRow = ({ type, name, value, handleChange }) => { 4 | return ( 5 |
6 | 9 | 16 |
17 | ); 18 | }; 19 | 20 | export default FormRow; 21 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/src/components/FormRow.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const FormRow = ({ type, name, value, handleChange }) => { 4 | return ( 5 |
6 | 9 | 16 |
17 | ); 18 | }; 19 | 20 | export default FormRow; 21 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/assets/wrappers/JobInfo.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.div` 4 | margin-top: 0.5rem; 5 | display: flex; 6 | align-items: center; 7 | 8 | .icon { 9 | font-size: 1rem; 10 | margin-right: 1rem; 11 | display: flex; 12 | align-items: center; 13 | svg { 14 | color: var(--grey-400); 15 | } 16 | } 17 | .text { 18 | text-transform: capitalize; 19 | letter-spacing: var(--letterSpacing); 20 | } 21 | ` 22 | export default Wrapper 23 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/assets/wrappers/SharedLayout.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | .dashboard { 5 | display: grid; 6 | grid-template-columns: 1fr; 7 | } 8 | .dashboard-page { 9 | width: 90vw; 10 | margin: 0 auto; 11 | padding: 2rem 0; 12 | } 13 | @media (min-width: 992px) { 14 | .dashboard { 15 | grid-template-columns: auto 1fr; 16 | } 17 | .dashboard-page { 18 | width: 90%; 19 | } 20 | } 21 | ` 22 | export default Wrapper 23 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/assets/wrappers/JobInfo.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.div` 4 | margin-top: 0.5rem; 5 | display: flex; 6 | align-items: center; 7 | 8 | .icon { 9 | font-size: 1rem; 10 | margin-right: 1rem; 11 | display: flex; 12 | align-items: center; 13 | svg { 14 | color: var(--grey-400); 15 | } 16 | } 17 | .text { 18 | text-transform: capitalize; 19 | letter-spacing: var(--letterSpacing); 20 | } 21 | ` 22 | export default Wrapper 23 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/utils/checkPermissions.js: -------------------------------------------------------------------------------- 1 | const CustomError = require('../errors'); 2 | 3 | const chechPermissions = (requestUser, resourceUserId) => { 4 | // console.log(requestUser); 5 | // console.log(resourceUserId); 6 | // console.log(typeof resourceUserId); 7 | if (requestUser.role === 'admin') return; 8 | if (requestUser.userId === resourceUserId.toString()) return; 9 | throw new CustomError.UnauthorizedError( 10 | 'Not authorized to access this route' 11 | ); 12 | }; 13 | 14 | module.exports = chechPermissions; 15 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/assets/wrappers/SharedLayout.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | .dashboard { 5 | display: grid; 6 | grid-template-columns: 1fr; 7 | } 8 | .dashboard-page { 9 | width: 90vw; 10 | margin: 0 auto; 11 | padding: 2rem 0; 12 | } 13 | @media (min-width: 992px) { 14 | .dashboard { 15 | grid-template-columns: auto 1fr; 16 | } 17 | .dashboard-page { 18 | width: 90%; 19 | } 20 | } 21 | ` 22 | export default Wrapper 23 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/utils/checkPermissions.js: -------------------------------------------------------------------------------- 1 | const CustomError = require('../errors'); 2 | 3 | const chechPermissions = (requestUser, resourceUserId) => { 4 | // console.log(requestUser); 5 | // console.log(resourceUserId); 6 | // console.log(typeof resourceUserId); 7 | if (requestUser.role === 'admin') return; 8 | if (requestUser.userId === resourceUserId.toString()) return; 9 | throw new CustomError.UnauthorizedError( 10 | 'Not authorized to access this route' 11 | ); 12 | }; 13 | 14 | module.exports = chechPermissions; 15 | -------------------------------------------------------------------------------- /04-store-api/final/populate.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config() 2 | 3 | const connectDB = require('./db/connect') 4 | const Product = require('./models/product') 5 | 6 | const jsonProducts = require('./products.json') 7 | 8 | const start = async () => { 9 | try { 10 | await connectDB(process.env.MONGO_URI) 11 | await Product.deleteMany() 12 | await Product.create(jsonProducts) 13 | console.log('Success!!!!') 14 | process.exit(0) 15 | } catch (error) { 16 | console.log(error) 17 | process.exit(1) 18 | } 19 | } 20 | 21 | start() 22 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/utils/checkPermissions.js: -------------------------------------------------------------------------------- 1 | const CustomError = require('../errors'); 2 | 3 | const chechPermissions = (requestUser, resourceUserId) => { 4 | // console.log(requestUser); 5 | // console.log(resourceUserId); 6 | // console.log(typeof resourceUserId); 7 | if (requestUser.role === 'admin') return; 8 | if (requestUser.userId === resourceUserId.toString()) return; 9 | throw new CustomError.UnauthorizedError( 10 | 'Not authorized to access this route' 11 | ); 12 | }; 13 | 14 | module.exports = chechPermissions; 15 | -------------------------------------------------------------------------------- /02-express-tutorial/final/12-router-app.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const app = express() 3 | 4 | const people = require('./routes/people') 5 | const auth = require('./routes/auth') 6 | 7 | // static assets 8 | app.use(express.static('./methods-public')) 9 | // parse form data 10 | app.use(express.urlencoded({ extended: false })) 11 | // parse json 12 | app.use(express.json()) 13 | 14 | app.use('/api/people', people) 15 | app.use('/login', auth) 16 | 17 | app.listen(5000, () => { 18 | console.log('Server is listening on port 5000....') 19 | }) 20 | -------------------------------------------------------------------------------- /07-file-upload/final/controllers/productController.js: -------------------------------------------------------------------------------- 1 | const Product = require('../models/Product'); 2 | const { StatusCodes } = require('http-status-codes'); 3 | 4 | const createProduct = async (req, res) => { 5 | const product = await Product.create(req.body); 6 | res.status(StatusCodes.CREATED).json({ product }); 7 | }; 8 | const getAllProducts = async (req, res) => { 9 | const products = await Product.find({}); 10 | res.status(StatusCodes.OK).json({ products }); 11 | }; 12 | 13 | module.exports = { 14 | createProduct, 15 | getAllProducts, 16 | }; 17 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/utils/sendEmail.js: -------------------------------------------------------------------------------- 1 | const nodemailer = require('nodemailer'); 2 | const nodemailerConfig = require('./nodemailerConfig'); 3 | 4 | const sendEmail = async ({ to, subject, html }) => { 5 | let testAccount = await nodemailer.createTestAccount(); 6 | 7 | const transporter = nodemailer.createTransport(nodemailerConfig); 8 | 9 | return transporter.sendMail({ 10 | from: '"Coding Addict" ', // sender address 11 | to, 12 | subject, 13 | html, 14 | }); 15 | }; 16 | 17 | module.exports = sendEmail; 18 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jobs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "nodemon app.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "dotenv": "^8.2.0", 14 | "express": "^4.17.1", 15 | "express-async-errors": "^3.1.1", 16 | "http-status-codes": "^2.1.4", 17 | "jsonwebtoken": "^8.5.1", 18 | "mongoose": "^5.11.10" 19 | }, 20 | "devDependencies": { 21 | "nodemon": "^2.0.7" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/assets/wrappers/JobsContainer.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | margin-top: 4rem; 5 | h2 { 6 | text-transform: none; 7 | } 8 | & > h5 { 9 | font-weight: 700; 10 | } 11 | .jobs { 12 | display: grid; 13 | grid-template-columns: 1fr; 14 | row-gap: 2rem; 15 | } 16 | @media (min-width: 992px) { 17 | .jobs { 18 | display: grid; 19 | grid-template-columns: 1fr 1fr; 20 | gap: 1rem; 21 | } 22 | } 23 | ` 24 | export default Wrapper 25 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/assets/wrappers/JobsContainer.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | margin-top: 4rem; 5 | h2 { 6 | text-transform: none; 7 | } 8 | & > h5 { 9 | font-weight: 700; 10 | } 11 | .jobs { 12 | display: grid; 13 | grid-template-columns: 1fr; 14 | row-gap: 2rem; 15 | } 16 | @media (min-width: 992px) { 17 | .jobs { 18 | display: grid; 19 | grid-template-columns: 1fr 1fr; 20 | gap: 1rem; 21 | } 22 | } 23 | ` 24 | export default Wrapper 25 | -------------------------------------------------------------------------------- /05-JWT-Basics/starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jobs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "nodemon app.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "dotenv": "^8.2.0", 14 | "express": "^4.17.1", 15 | "express-async-errors": "^3.1.1", 16 | "http-status-codes": "^2.1.4", 17 | "jsonwebtoken": "^8.5.1", 18 | "mongoose": "^5.11.10" 19 | }, 20 | "devDependencies": { 21 | "nodemon": "^2.0.7" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/models/Token.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | 3 | const TokenSchema = new mongoose.Schema( 4 | { 5 | refreshToken: { type: String, required: true }, 6 | ip: { type: String, required: true }, 7 | userAgent: { type: String, required: true }, 8 | isValid: { type: Boolean, default: true }, 9 | user: { 10 | type: mongoose.Types.ObjectId, 11 | ref: 'User', 12 | required: true, 13 | }, 14 | }, 15 | { timestamps: true } 16 | ); 17 | 18 | module.exports = mongoose.model('Token', TokenSchema); 19 | -------------------------------------------------------------------------------- /01-node-tutorial/2-async-patterns/1-block.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | 3 | const server = http.createServer((req, res) => { 4 | if (req.url === '/') { 5 | res.end('Home Page') 6 | } 7 | if (req.url === '/about') { 8 | // blocking code 9 | for (let i = 0; i < 1000; i++) { 10 | for (let j = 0; j < 1000; j++) { 11 | console.log(`${i} ${j}`) 12 | } 13 | } 14 | res.end('About Page') 15 | } 16 | res.end('Error Page') 17 | }) 18 | 19 | server.listen(5000, () => { 20 | console.log('Server listening on port : 5000....') 21 | }) 22 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/pages/Error.js: -------------------------------------------------------------------------------- 1 | import { Link } from 'react-router-dom'; 2 | import img from '../assets/images/not-found.svg'; 3 | import Wrapper from '../assets/wrappers/ErrorPage'; 4 | 5 | const Error = () => { 6 | return ( 7 | 8 |
9 | not found 10 |

Ohh! Page Not Found

11 |

We can't seem to find the page you're looking for

12 | back home 13 |
14 |
15 | ); 16 | }; 17 | export default Error; 18 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/pages/Error.js: -------------------------------------------------------------------------------- 1 | import { Link } from 'react-router-dom'; 2 | import img from '../assets/images/not-found.svg'; 3 | import Wrapper from '../assets/wrappers/ErrorPage'; 4 | 5 | const Error = () => { 6 | return ( 7 | 8 |
9 | not found 10 |

Ohh! Page Not Found

11 |

We can't seem to find the page you're looking for

12 | back home 13 |
14 |
15 | ); 16 | }; 17 | export default Error; 18 | -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/src/pages/ProtectedRoute.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Route, Redirect } from 'react-router-dom'; 3 | // import { useUserContext } from '../context/user_context' 4 | import { useGlobalContext } from '../context'; 5 | 6 | const PrivateRoute = ({ children, ...rest }) => { 7 | const { user } = useGlobalContext(); 8 | return ( 9 | { 12 | return user ? children : ; 13 | }} 14 | > 15 | ); 16 | }; 17 | export default PrivateRoute; 18 | -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import Home from './Home'; 2 | import Error from './Error'; 3 | import Register from './Register'; 4 | import Login from './Login'; 5 | import Verify from './Verify'; 6 | import Dashboard from './Dashboard'; 7 | import ProtectedRoute from './ProtectedRoute'; 8 | import ForgotPassword from './ForgotPassword'; 9 | import ResetPassword from './ResetPassword'; 10 | export { 11 | Home, 12 | Error, 13 | Register, 14 | Login, 15 | Verify, 16 | Dashboard, 17 | ProtectedRoute, 18 | ForgotPassword, 19 | ResetPassword, 20 | }; 21 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/src/pages/ProtectedRoute.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Route, Redirect } from 'react-router-dom'; 3 | // import { useUserContext } from '../context/user_context' 4 | import { useGlobalContext } from '../context'; 5 | 6 | const PrivateRoute = ({ children, ...rest }) => { 7 | const { user } = useGlobalContext(); 8 | return ( 9 | { 12 | return user ? children : ; 13 | }} 14 | > 15 | ); 16 | }; 17 | export default PrivateRoute; 18 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import Home from './Home'; 2 | import Error from './Error'; 3 | import Register from './Register'; 4 | import Login from './Login'; 5 | import Verify from './Verify'; 6 | import Dashboard from './Dashboard'; 7 | import ProtectedRoute from './ProtectedRoute'; 8 | import ForgotPassword from './ForgotPassword'; 9 | import ResetPassword from './ResetPassword'; 10 | export { 11 | Home, 12 | Error, 13 | Register, 14 | Login, 15 | Verify, 16 | Dashboard, 17 | ProtectedRoute, 18 | ForgotPassword, 19 | ResetPassword, 20 | }; 21 | -------------------------------------------------------------------------------- /02-express-tutorial/final/05-all-static.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const path = require('path') 3 | 4 | const app = express() 5 | 6 | // setup static and middleware 7 | app.use(express.static('./public')) 8 | 9 | // app.get('/', (req, res) => { 10 | // res.sendFile(path.resolve(__dirname, './navbar-app/index.html')) 11 | // adding to static assets 12 | // SSR 13 | // }) 14 | 15 | app.all('*', (req, res) => { 16 | res.status(404).send('resource not found') 17 | }) 18 | 19 | app.listen(5000, () => { 20 | console.log('server is listening on port 5000....') 21 | }) 22 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/utils/links.js: -------------------------------------------------------------------------------- 1 | import { IoBarChartSharp } from 'react-icons/io5'; 2 | import { MdQueryStats } from 'react-icons/md'; 3 | import { FaWpforms } from 'react-icons/fa'; 4 | import { ImProfile } from 'react-icons/im'; 5 | 6 | const links = [ 7 | { id: 1, text: 'stats', path: '/', icon: }, 8 | { id: 2, text: 'all jobs', path: 'all-jobs', icon: }, 9 | { id: 3, text: 'add job', path: 'add-job', icon: }, 10 | { id: 4, text: 'profile', path: 'profile', icon: }, 11 | ]; 12 | 13 | export default links; 14 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/utils/links.js: -------------------------------------------------------------------------------- 1 | import { IoBarChartSharp } from 'react-icons/io5'; 2 | import { MdQueryStats } from 'react-icons/md'; 3 | import { FaWpforms } from 'react-icons/fa'; 4 | import { ImProfile } from 'react-icons/im'; 5 | 6 | const links = [ 7 | { id: 1, text: 'stats', path: '/', icon: }, 8 | { id: 2, text: 'all jobs', path: 'all-jobs', icon: }, 9 | { id: 3, text: 'add job', path: 'add-job', icon: }, 10 | { id: 4, text: 'profile', path: 'profile', icon: }, 11 | ]; 12 | 13 | export default links; 14 | -------------------------------------------------------------------------------- /09-stripe-payment/final/controllers/stripeController.js: -------------------------------------------------------------------------------- 1 | const stripe = require('stripe')(process.env.STRIPE_KEY); 2 | 3 | const stripeController = async (req, res) => { 4 | const { purchase, total_amount, shipping_fee } = req.body; 5 | 6 | const calculateOrderAmount = () => { 7 | return total_amount + shipping_fee; 8 | }; 9 | 10 | const paymentIntent = await stripe.paymentIntents.create({ 11 | amount: calculateOrderAmount(), 12 | currency: 'usd', 13 | }); 14 | 15 | res.json({ clientSecret: paymentIntent.client_secret }); 16 | }; 17 | 18 | module.exports = stripeController; 19 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/routes/jobs.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const testUser = require('../middleware/testUser'); 3 | 4 | const router = express.Router(); 5 | const { 6 | createJob, 7 | deleteJob, 8 | getAllJobs, 9 | updateJob, 10 | getJob, 11 | showStats, 12 | } = require('../controllers/jobs'); 13 | 14 | router.route('/').post(testUser, createJob).get(getAllJobs); 15 | router.route('/stats').get(showStats); 16 | 17 | router 18 | .route('/:id') 19 | .get(getJob) 20 | .delete(testUser, deleteJob) 21 | .patch(testUser, updateJob); 22 | 23 | module.exports = router; 24 | -------------------------------------------------------------------------------- /02-express-tutorial/final/08-middleware-basic.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const app = express() 3 | 4 | // req => middleware => res 5 | 6 | const logger = (req, res, next) => { 7 | const method = req.method 8 | const url = req.url 9 | const time = new Date().getFullYear() 10 | console.log(method, url, time) 11 | next() 12 | } 13 | 14 | app.get('/', logger, (req, res) => { 15 | res.send('Home') 16 | }) 17 | app.get('/about', logger, (req, res) => { 18 | res.send('About') 19 | }) 20 | 21 | app.listen(5000, () => { 22 | console.log('Server is listening on port 5000....') 23 | }) 24 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/utils/sendResetPasswordEmail.js: -------------------------------------------------------------------------------- 1 | const sendEmail = require('./sendEmail'); 2 | 3 | const sendResetPassswordEmail = async ({ name, email, token, origin }) => { 4 | const resetURL = `${origin}/user/reset-password?token=${token}&email=${email}`; 5 | const message = `

Please reset password by clicking on the following link : 6 | Reset Password

`; 7 | 8 | return sendEmail({ 9 | to: email, 10 | subject: 'Reset Password', 11 | html: `

Hello, ${name}

12 | ${message} 13 | `, 14 | }); 15 | }; 16 | 17 | module.exports = sendResetPassswordEmail; 18 | -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/src/pages/Error.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styled from 'styled-components'; 3 | import { Link } from 'react-router-dom'; 4 | const Error = () => { 5 | return ( 6 | 7 |
8 |

404

9 |

page not found

10 | 11 | Back Home 12 | 13 |
14 |
15 | ); 16 | }; 17 | 18 | const Wrapper = styled.main` 19 | text-align: center; 20 | padding-top: 5rem; 21 | h1 { 22 | font-size: 9rem; 23 | } 24 | `; 25 | 26 | export default Error; 27 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/src/pages/Error.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styled from 'styled-components'; 3 | import { Link } from 'react-router-dom'; 4 | const Error = () => { 5 | return ( 6 | 7 |
8 |

404

9 |

page not found

10 | 11 | Back Home 12 | 13 |
14 |
15 | ); 16 | }; 17 | 18 | const Wrapper = styled.main` 19 | text-align: center; 20 | padding-top: 5rem; 21 | h1 { 22 | font-size: 9rem; 23 | } 24 | `; 25 | 26 | export default Error; 27 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/build/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 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/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 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/routes/reviewRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const { authenticateUser } = require('../middleware/authentication'); 4 | 5 | const { 6 | createReview, 7 | getAllReviews, 8 | getSingleReview, 9 | updateReview, 10 | deleteReview, 11 | } = require('../controllers/reviewController'); 12 | 13 | router.route('/').post(authenticateUser, createReview).get(getAllReviews); 14 | 15 | router 16 | .route('/:id') 17 | .get(getSingleReview) 18 | .patch(authenticateUser, updateReview) 19 | .delete(authenticateUser, deleteReview); 20 | 21 | module.exports = router; 22 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/pages/dashboard/SharedLayout.js: -------------------------------------------------------------------------------- 1 | import { Outlet } from 'react-router-dom'; 2 | import { BigSidebar, Navbar, SmallSidebar } from '../../components'; 3 | import Wrapper from '../../assets/wrappers/SharedLayout'; 4 | const SharedLayout = () => { 5 | return ( 6 | 7 |
8 | 9 | 10 |
11 | 12 |
13 | 14 |
15 |
16 |
17 |
18 | ); 19 | }; 20 | export default SharedLayout; 21 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/build/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 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/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 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/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 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/routes/reviewRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const { authenticateUser } = require('../middleware/authentication'); 4 | 5 | const { 6 | createReview, 7 | getAllReviews, 8 | getSingleReview, 9 | updateReview, 10 | deleteReview, 11 | } = require('../controllers/reviewController'); 12 | 13 | router.route('/').post(authenticateUser, createReview).get(getAllReviews); 14 | 15 | router 16 | .route('/:id') 17 | .get(getSingleReview) 18 | .patch(authenticateUser, updateReview) 19 | .delete(authenticateUser, deleteReview); 20 | 21 | module.exports = router; 22 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/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 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /02-express-tutorial/final/03-express-basics.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const app = express() 3 | 4 | app.get('/', (req, res) => { 5 | console.log('user hit the resource') 6 | res.status(200).send('Home Page') 7 | }) 8 | 9 | app.get('/about', (req, res) => { 10 | res.status(200).send('About Page') 11 | }) 12 | 13 | app.all('*', (req, res) => { 14 | res.status(404).send('

resource not found

') 15 | }) 16 | 17 | app.listen(5000, () => { 18 | console.log('server is listening on port 5000...') 19 | }) 20 | 21 | // app.get 22 | // app.post 23 | // app.put 24 | // app.delete 25 | // app.all 26 | // app.use 27 | // app.listen 28 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/pages/dashboard/SharedLayout.js: -------------------------------------------------------------------------------- 1 | import { Outlet } from 'react-router-dom'; 2 | import { BigSidebar, Navbar, SmallSidebar } from '../../components'; 3 | import Wrapper from '../../assets/wrappers/SharedLayout'; 4 | const SharedLayout = () => { 5 | return ( 6 | 7 |
8 | 9 | 10 |
11 | 12 |
13 | 14 |
15 |
16 |
17 |
18 | ); 19 | }; 20 | export default SharedLayout; 21 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/routes/reviewRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const { authenticateUser } = require('../middleware/authentication'); 4 | 5 | const { 6 | createReview, 7 | getAllReviews, 8 | getSingleReview, 9 | updateReview, 10 | deleteReview, 11 | } = require('../controllers/reviewController'); 12 | 13 | router.route('/').post(authenticateUser, createReview).get(getAllReviews); 14 | 15 | router 16 | .route('/:id') 17 | .get(getSingleReview) 18 | .patch(authenticateUser, updateReview) 19 | .delete(authenticateUser, deleteReview); 20 | 21 | module.exports = router; 22 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/utils/index.js: -------------------------------------------------------------------------------- 1 | const { createJWT, isTokenValid, attachCookiesToResponse } = require('./jwt'); 2 | const createTokenUser = require('./createTokenUser'); 3 | const checkPermissions = require('./checkPermissions'); 4 | const sendVerificationEmail = require('./sendVerficationEmail'); 5 | const sendResetPasswordEmail = require('./sendResetPasswordEmail'); 6 | const createHash = require('./createHash'); 7 | 8 | module.exports = { 9 | createJWT, 10 | isTokenValid, 11 | attachCookiesToResponse, 12 | createTokenUser, 13 | checkPermissions, 14 | sendVerificationEmail, 15 | sendResetPasswordEmail, 16 | createHash, 17 | }; 18 | -------------------------------------------------------------------------------- /01-node-tutorial/13-event-emitter.js: -------------------------------------------------------------------------------- 1 | // get back the class 2 | // if want custom extend from class 3 | // otherwise just for emitting and handling events create instance 4 | const EventEmitter = require('events') 5 | 6 | const customEmitter = new EventEmitter() 7 | 8 | // on and emit methods 9 | // keep track of the order 10 | // additional arguments 11 | // built-in modules utilize it 12 | 13 | customEmitter.on('response', (name, id) => { 14 | console.log(`data recieved user ${name} with id:${id}`) 15 | }) 16 | 17 | customEmitter.on('response', () => { 18 | console.log('some other logic here') 19 | }) 20 | 21 | customEmitter.emit('response', 'john', 34) 22 | -------------------------------------------------------------------------------- /10-e-commerce-api/final-front-end/react-front-end/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 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/build/index.html: -------------------------------------------------------------------------------- 1 | Jobster Development
-------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/build/index.html: -------------------------------------------------------------------------------- 1 | Jobster Development
-------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/assets/wrappers/ErrorPage.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components'; 2 | 3 | const Wrapper = styled.main` 4 | text-align: center; 5 | img { 6 | width: 90vw; 7 | max-width: 600px; 8 | display: block; 9 | margin-bottom: 2rem; 10 | } 11 | display: flex; 12 | align-items: center; 13 | justify-content: center; 14 | h3 { 15 | margin-bottom: 0.5rem; 16 | } 17 | p { 18 | margin-top: 0; 19 | margin-bottom: 0.5rem; 20 | color: var(--grey-500); 21 | } 22 | a { 23 | color: var(--primary-500); 24 | text-decoration: underline; 25 | text-transform: capitalize; 26 | } 27 | `; 28 | 29 | export default Wrapper; 30 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/assets/wrappers/ErrorPage.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components'; 2 | 3 | const Wrapper = styled.main` 4 | text-align: center; 5 | img { 6 | width: 90vw; 7 | max-width: 600px; 8 | display: block; 9 | margin-bottom: 2rem; 10 | } 11 | display: flex; 12 | align-items: center; 13 | justify-content: center; 14 | h3 { 15 | margin-bottom: 0.5rem; 16 | } 17 | p { 18 | margin-top: 0; 19 | margin-bottom: 0.5rem; 20 | color: var(--grey-500); 21 | } 22 | a { 23 | color: var(--primary-500); 24 | text-decoration: underline; 25 | text-transform: capitalize; 26 | } 27 | `; 28 | 29 | export default Wrapper; 30 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/routes/authRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | 4 | const { authenticateUser } = require('../middleware/authentication'); 5 | 6 | const { 7 | register, 8 | login, 9 | logout, 10 | verifyEmail, 11 | forgotPassword, 12 | resetPassword, 13 | } = require('../controllers/authController'); 14 | 15 | router.post('/register', register); 16 | router.post('/login', login); 17 | router.delete('/logout', authenticateUser, logout); 18 | router.post('/verify-email', verifyEmail); 19 | router.post('/reset-password', resetPassword); 20 | router.post('/forgot-password', forgotPassword); 21 | 22 | module.exports = router; 23 | -------------------------------------------------------------------------------- /02-express-tutorial/final/09-middleware-use.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const app = express() 3 | const logger = require('./logger') 4 | const authorize = require('./authorize') 5 | // req => middleware => res 6 | app.use([logger, authorize]) 7 | // api/home/about/products 8 | app.get('/', (req, res) => { 9 | res.send('Home') 10 | }) 11 | app.get('/about', (req, res) => { 12 | res.send('About') 13 | }) 14 | app.get('/api/products', (req, res) => { 15 | res.send('Products') 16 | }) 17 | app.get('/api/items', (req, res) => { 18 | console.log(req.user) 19 | res.send('Items') 20 | }) 21 | 22 | app.listen(5000, () => { 23 | console.log('Server is listening on port 5000....') 24 | }) 25 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/utils/sendVerficationEmail.js: -------------------------------------------------------------------------------- 1 | const sendEmail = require('./sendEmail'); 2 | 3 | const sendVerificationEmail = async ({ 4 | name, 5 | email, 6 | verificationToken, 7 | origin, 8 | }) => { 9 | const verifyEmail = `${origin}/user/verify-email?token=${verificationToken}&email=${email}`; 10 | 11 | const message = `

Please confirm your email by clicking on the following link : 12 | Verify Email

`; 13 | 14 | return sendEmail({ 15 | to: email, 16 | subject: 'Email Confirmation', 17 | html: `

Hello, ${name}

18 | ${message} 19 | `, 20 | }); 21 | }; 22 | 23 | module.exports = sendVerificationEmail; 24 | -------------------------------------------------------------------------------- /02-express-tutorial/final/13-router-people.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const router = express.Router() 3 | 4 | const { 5 | getPeople, 6 | createPerson, 7 | createPersonPostman, 8 | updatePerson, 9 | deletePerson, 10 | } = require('../controllers/people') 11 | 12 | // router.get('/', getPeople) 13 | // router.post('/', createPerson) 14 | // router.post('/postman', createPersonPostman) 15 | // router.put('/:id', updatePerson) 16 | // router.delete('/:id', deletePerson) 17 | 18 | router.route('/').get(getPeople).post(createPerson) 19 | router.route('/postman').post(createPersonPostman) 20 | router.route('/:id').put(updatePerson).delete(deletePerson) 21 | 22 | module.exports = router 23 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/BarChart.js: -------------------------------------------------------------------------------- 1 | import { 2 | BarChart, 3 | Bar, 4 | XAxis, 5 | YAxis, 6 | CartesianGrid, 7 | Tooltip, 8 | ResponsiveContainer, 9 | } from 'recharts'; 10 | 11 | const BarChartComponent = ({ data }) => { 12 | return ( 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ); 23 | }; 24 | export default BarChartComponent; 25 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/index.js: -------------------------------------------------------------------------------- 1 | import BigSidebar from './BigSidebar'; 2 | import ChartsContainer from './ChartsContainer'; 3 | import FormRow from './FormRow'; 4 | import FormRowSelect from './FormRowSelect'; 5 | import JobsContainer from './JobsContainer'; 6 | import Logo from './Logo'; 7 | import Navbar from './Navbar'; 8 | import SearchContainer from './SearchContainer'; 9 | import SmallSidebar from './SmallSidebar'; 10 | import StatsContainer from './StatsContainer'; 11 | 12 | export { 13 | Logo, 14 | FormRow, 15 | Navbar, 16 | SmallSidebar, 17 | BigSidebar, 18 | FormRowSelect, 19 | JobsContainer, 20 | SearchContainer, 21 | StatsContainer, 22 | ChartsContainer, 23 | }; 24 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/BarChart.js: -------------------------------------------------------------------------------- 1 | import { 2 | BarChart, 3 | Bar, 4 | XAxis, 5 | YAxis, 6 | CartesianGrid, 7 | Tooltip, 8 | ResponsiveContainer, 9 | } from 'recharts'; 10 | 11 | const BarChartComponent = ({ data }) => { 12 | return ( 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ); 23 | }; 24 | export default BarChartComponent; 25 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/index.js: -------------------------------------------------------------------------------- 1 | import BigSidebar from './BigSidebar'; 2 | import ChartsContainer from './ChartsContainer'; 3 | import FormRow from './FormRow'; 4 | import FormRowSelect from './FormRowSelect'; 5 | import JobsContainer from './JobsContainer'; 6 | import Logo from './Logo'; 7 | import Navbar from './Navbar'; 8 | import SearchContainer from './SearchContainer'; 9 | import SmallSidebar from './SmallSidebar'; 10 | import StatsContainer from './StatsContainer'; 11 | 12 | export { 13 | Logo, 14 | FormRow, 15 | Navbar, 16 | SmallSidebar, 17 | BigSidebar, 18 | FormRowSelect, 19 | JobsContainer, 20 | SearchContainer, 21 | StatsContainer, 22 | ChartsContainer, 23 | }; 24 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/pages/dashboard/Stats.js: -------------------------------------------------------------------------------- 1 | import { useEffect } from 'react'; 2 | import { StatsContainer, Loading, ChartsContainer } from '../../components'; 3 | import { useDispatch, useSelector } from 'react-redux'; 4 | import { showStats } from '../../features/allJobs/allJobsSlice'; 5 | 6 | const Stats = () => { 7 | const { isLoading, monthlyApplications } = useSelector( 8 | (store) => store.allJobs 9 | ); 10 | 11 | const dispatch = useDispatch(); 12 | useEffect(() => { 13 | dispatch(showStats()); 14 | }, []); 15 | return ( 16 | <> 17 | 18 | {monthlyApplications.length > 0 && } 19 | 20 | ); 21 | }; 22 | export default Stats; 23 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/pages/dashboard/Stats.js: -------------------------------------------------------------------------------- 1 | import { useEffect } from 'react'; 2 | import { StatsContainer, Loading, ChartsContainer } from '../../components'; 3 | import { useDispatch, useSelector } from 'react-redux'; 4 | import { showStats } from '../../features/allJobs/allJobsSlice'; 5 | 6 | const Stats = () => { 7 | const { isLoading, monthlyApplications } = useSelector( 8 | (store) => store.allJobs 9 | ); 10 | 11 | const dispatch = useDispatch(); 12 | useEffect(() => { 13 | dispatch(showStats()); 14 | }, []); 15 | return ( 16 | <> 17 | 18 | {monthlyApplications.length > 0 && } 19 | 20 | ); 21 | }; 22 | export default Stats; 23 | -------------------------------------------------------------------------------- /02-express-tutorial/final/01-http-basics.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | 3 | const server = http.createServer((req, res) => { 4 | // console.log(req.method) 5 | const url = req.url 6 | // home page 7 | if (url === '/') { 8 | res.writeHead(200, { 'content-type': 'text/html' }) 9 | res.write('

home page

') 10 | res.end() 11 | } 12 | // about page 13 | else if (url === '/about') { 14 | res.writeHead(200, { 'content-type': 'text/html' }) 15 | res.write('

about page

') 16 | res.end() 17 | } 18 | // 404 19 | else { 20 | res.writeHead(404, { 'content-type': 'text/html' }) 21 | res.write('

page not found

') 22 | res.end() 23 | } 24 | }) 25 | 26 | server.listen(5000) 27 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/AreaChart.js: -------------------------------------------------------------------------------- 1 | import { 2 | ResponsiveContainer, 3 | AreaChart, 4 | Area, 5 | XAxis, 6 | YAxis, 7 | CartesianGrid, 8 | Tooltip, 9 | } from 'recharts'; 10 | 11 | const AreaChartComponent = ({ data }) => { 12 | return ( 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ); 23 | }; 24 | export default AreaChartComponent; 25 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/AreaChart.js: -------------------------------------------------------------------------------- 1 | import { 2 | ResponsiveContainer, 3 | AreaChart, 4 | Area, 5 | XAxis, 6 | YAxis, 7 | CartesianGrid, 8 | Tooltip, 9 | } from 'recharts'; 10 | 11 | const AreaChartComponent = ({ data }) => { 12 | return ( 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ); 23 | }; 24 | export default AreaChartComponent; 25 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/build/asset-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": { 3 | "main.css": "/static/css/main.bfc991fb.css", 4 | "main.js": "/static/js/main.08722844.js", 5 | "static/media/main.svg": "/static/media/main.17b316de742b3a1202078c5ae18c8261.svg", 6 | "static/media/not-found.svg": "/static/media/not-found.5cfa24fa5e3ca7dffe02f358358ea9df.svg", 7 | "static/media/logo.svg": "/static/media/logo.35bb8e1d9b5745af32ff148cbee51dfa.svg", 8 | "index.html": "/index.html", 9 | "main.bfc991fb.css.map": "/static/css/main.bfc991fb.css.map", 10 | "main.08722844.js.map": "/static/js/main.08722844.js.map" 11 | }, 12 | "entrypoints": [ 13 | "static/css/main.bfc991fb.css", 14 | "static/js/main.08722844.js" 15 | ] 16 | } -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/build/asset-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": { 3 | "main.css": "/static/css/main.bfc991fb.css", 4 | "main.js": "/static/js/main.08722844.js", 5 | "static/media/main.svg": "/static/media/main.17b316de742b3a1202078c5ae18c8261.svg", 6 | "static/media/not-found.svg": "/static/media/not-found.5cfa24fa5e3ca7dffe02f358358ea9df.svg", 7 | "static/media/logo.svg": "/static/media/logo.35bb8e1d9b5745af32ff148cbee51dfa.svg", 8 | "index.html": "/index.html", 9 | "main.bfc991fb.css.map": "/static/css/main.bfc991fb.css.map", 10 | "main.08722844.js.map": "/static/js/main.08722844.js.map" 11 | }, 12 | "entrypoints": [ 13 | "static/css/main.bfc991fb.css", 14 | "static/js/main.08722844.js" 15 | ] 16 | } -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/FormRowSelect.js: -------------------------------------------------------------------------------- 1 | const FormRowSelect = ({ labelText, name, value, handleChange, list }) => { 2 | return ( 3 |
4 | 7 | 22 |
23 | ); 24 | }; 25 | export default FormRowSelect; 26 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/FormRowSelect.js: -------------------------------------------------------------------------------- 1 | const FormRowSelect = ({ labelText, name, value, handleChange, list }) => { 2 | return ( 3 |
4 | 7 | 22 |
23 | ); 24 | }; 25 | export default FormRowSelect; 26 | -------------------------------------------------------------------------------- /05-JWT-Basics/starter/app.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | require('express-async-errors'); 3 | 4 | const express = require('express'); 5 | const app = express(); 6 | 7 | const notFoundMiddleware = require('./middleware/not-found'); 8 | const errorHandlerMiddleware = require('./middleware/error-handler'); 9 | 10 | // middleware 11 | app.use(express.static('./public')); 12 | app.use(express.json()); 13 | 14 | app.use(notFoundMiddleware); 15 | app.use(errorHandlerMiddleware); 16 | 17 | const port = process.env.PORT || 3000; 18 | 19 | const start = async () => { 20 | try { 21 | app.listen(port, () => 22 | console.log(`Server is listening on port ${port}...`) 23 | ); 24 | } catch (error) { 25 | console.log(error); 26 | } 27 | }; 28 | 29 | start(); 30 | -------------------------------------------------------------------------------- /11-auth-workflow/final/front-end/src/utils/localState.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | const useLocalState = () => { 4 | const [alert, setAlert] = useState({ 5 | show: false, 6 | text: '', 7 | type: 'danger', 8 | }); 9 | const [loading, setLoading] = useState(false); 10 | const [success, setSuccess] = useState(false); 11 | 12 | const showAlert = ({ text, type = 'danger' }) => { 13 | setAlert({ show: true, text, type }); 14 | }; 15 | const hideAlert = () => { 16 | setAlert({ show: false, text: '', type: 'danger' }); 17 | }; 18 | return { 19 | alert, 20 | showAlert, 21 | loading, 22 | setLoading, 23 | success, 24 | setSuccess, 25 | hideAlert, 26 | }; 27 | }; 28 | 29 | export default useLocalState; 30 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/front-end/src/utils/localState.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | const useLocalState = () => { 4 | const [alert, setAlert] = useState({ 5 | show: false, 6 | text: '', 7 | type: 'danger', 8 | }); 9 | const [loading, setLoading] = useState(false); 10 | const [success, setSuccess] = useState(false); 11 | 12 | const showAlert = ({ text, type = 'danger' }) => { 13 | setAlert({ show: true, text, type }); 14 | }; 15 | const hideAlert = () => { 16 | setAlert({ show: false, text: '', type: 'danger' }); 17 | }; 18 | return { 19 | alert, 20 | showAlert, 21 | loading, 22 | setLoading, 23 | success, 24 | setSuccess, 25 | hideAlert, 26 | }; 27 | }; 28 | 29 | export default useLocalState; 30 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/middleware/auth.js: -------------------------------------------------------------------------------- 1 | const jwt = require('jsonwebtoken') 2 | const { UnauthenticatedError } = require('../errors') 3 | 4 | const authenticationMiddleware = async (req, res, next) => { 5 | const authHeader = req.headers.authorization 6 | 7 | if (!authHeader || !authHeader.startsWith('Bearer ')) { 8 | throw new UnauthenticatedError('No token provided') 9 | } 10 | 11 | const token = authHeader.split(' ')[1] 12 | 13 | try { 14 | const decoded = jwt.verify(token, process.env.JWT_SECRET) 15 | const { id, username } = decoded 16 | req.user = { id, username } 17 | next() 18 | } catch (error) { 19 | throw new UnauthenticatedError('Not authorized to access this route') 20 | } 21 | } 22 | 23 | module.exports = authenticationMiddleware 24 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/routes/auth.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const authenticateUser = require('../middleware/authentication'); 4 | const testUser = require('../middleware/testUser'); 5 | 6 | const rateLimiter = require('express-rate-limit'); 7 | 8 | const apiLimiter = rateLimiter({ 9 | windowMs: 15 * 60 * 1000, 10 | max: 10, 11 | message: { 12 | msg: 'Too many requests from this IP, please try again after 15 minutes', 13 | }, 14 | }); 15 | 16 | const { register, login, updateUser } = require('../controllers/auth'); 17 | router.post('/register', apiLimiter, register); 18 | router.post('/login', apiLimiter, login); 19 | router.patch('/updateUser', authenticateUser, testUser, updateUser); 20 | module.exports = router; 21 | -------------------------------------------------------------------------------- /06-jobs-api/final/models/Job.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const JobSchema = new mongoose.Schema( 4 | { 5 | company: { 6 | type: String, 7 | required: [true, 'Please provide company name'], 8 | maxlength: 50, 9 | }, 10 | position: { 11 | type: String, 12 | required: [true, 'Please provide position'], 13 | maxlength: 100, 14 | }, 15 | status: { 16 | type: String, 17 | enum: ['interview', 'declined', 'pending'], 18 | default: 'pending', 19 | }, 20 | createdBy: { 21 | type: mongoose.Types.ObjectId, 22 | ref: 'User', 23 | required: [true, 'Please provide user'], 24 | }, 25 | }, 26 | { timestamps: true } 27 | ) 28 | 29 | module.exports = mongoose.model('Job', JobSchema) 30 | -------------------------------------------------------------------------------- /01-node-tutorial/11-fs-async.js: -------------------------------------------------------------------------------- 1 | const { readFile, writeFile } = require('fs') 2 | 3 | console.log('start') 4 | readFile('./content/first.txt', 'utf8', (err, result) => { 5 | if (err) { 6 | console.log(err) 7 | return 8 | } 9 | const first = result 10 | readFile('./content/second.txt', 'utf8', (err, result) => { 11 | if (err) { 12 | console.log(err) 13 | return 14 | } 15 | const second = result 16 | writeFile( 17 | './content/result-async.txt', 18 | `Here is the result : ${first}, ${second}`, 19 | (err, result) => { 20 | if (err) { 21 | console.log(err) 22 | return 23 | } 24 | console.log('done with this task') 25 | } 26 | ) 27 | }) 28 | }) 29 | console.log('starting next task') 30 | -------------------------------------------------------------------------------- /02-express-tutorial/final/10-middleware-options.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const app = express() 3 | const morgan = require('morgan') 4 | const logger = require('./logger') 5 | const authorize = require('./authorize') 6 | // req => middleware => res 7 | 8 | // app.use([logger, authorize]) 9 | // app.use(express.static('./public')) 10 | app.use(morgan('tiny')) 11 | 12 | app.get('/', (req, res) => { 13 | res.send('Home') 14 | }) 15 | app.get('/about', (req, res) => { 16 | res.send('About') 17 | }) 18 | app.get('/api/products', (req, res) => { 19 | res.send('Products') 20 | }) 21 | app.get('/api/items', (req, res) => { 22 | console.log(req.user) 23 | res.send('Items') 24 | }) 25 | 26 | app.listen(5000, () => { 27 | console.log('Server is listening on port 5000....') 28 | }) 29 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/models/Job.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const JobSchema = new mongoose.Schema( 4 | { 5 | company: { 6 | type: String, 7 | required: [true, 'Please provide company name'], 8 | maxlength: 50, 9 | }, 10 | position: { 11 | type: String, 12 | required: [true, 'Please provide position'], 13 | maxlength: 100, 14 | }, 15 | status: { 16 | type: String, 17 | enum: ['interview', 'declined', 'pending'], 18 | default: 'pending', 19 | }, 20 | createdBy: { 21 | type: mongoose.Types.ObjectId, 22 | ref: 'User', 23 | required: [true, 'Please provide user'], 24 | }, 25 | }, 26 | { timestamps: true } 27 | ) 28 | 29 | module.exports = mongoose.model('Job', JobSchema) 30 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/NavLinks.js: -------------------------------------------------------------------------------- 1 | import { NavLink } from 'react-router-dom'; 2 | import links from '../utils/links'; 3 | 4 | const NavLinks = ({ toggleSidebar }) => { 5 | return ( 6 |
7 | {links.map((link) => { 8 | const { text, path, id, icon } = link; 9 | return ( 10 | { 13 | return isActive ? 'nav-link active' : 'nav-link'; 14 | }} 15 | key={id} 16 | onClick={toggleSidebar} 17 | > 18 | {icon} 19 | {text} 20 | 21 | ); 22 | })} 23 |
24 | ); 25 | }; 26 | export default NavLinks; 27 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/BigSidebar.js: -------------------------------------------------------------------------------- 1 | import NavLinks from './NavLinks'; 2 | import Logo from '../components/Logo'; 3 | import Wrapper from '../assets/wrappers/BigSidebar'; 4 | import { useSelector } from 'react-redux'; 5 | 6 | const BigSidebar = () => { 7 | const { isSidebarOpen } = useSelector((store) => store.user); 8 | 9 | return ( 10 | 11 |
18 |
19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 | ); 27 | }; 28 | export default BigSidebar; 29 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/NavLinks.js: -------------------------------------------------------------------------------- 1 | import { NavLink } from 'react-router-dom'; 2 | import links from '../utils/links'; 3 | 4 | const NavLinks = ({ toggleSidebar }) => { 5 | return ( 6 |
7 | {links.map((link) => { 8 | const { text, path, id, icon } = link; 9 | return ( 10 | { 13 | return isActive ? 'nav-link active' : 'nav-link'; 14 | }} 15 | key={id} 16 | onClick={toggleSidebar} 17 | > 18 | {icon} 19 | {text} 20 | 21 | ); 22 | })} 23 |
24 | ); 25 | }; 26 | export default NavLinks; 27 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/BigSidebar.js: -------------------------------------------------------------------------------- 1 | import NavLinks from './NavLinks'; 2 | import Logo from '../components/Logo'; 3 | import Wrapper from '../assets/wrappers/BigSidebar'; 4 | import { useSelector } from 'react-redux'; 5 | 6 | const BigSidebar = () => { 7 | const { isSidebarOpen } = useSelector((store) => store.user); 8 | 9 | return ( 10 | 11 |
18 |
19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 | ); 27 | }; 28 | export default BigSidebar; 29 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/routes/orderRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const { 4 | authenticateUser, 5 | authorizePermissions, 6 | } = require('../middleware/authentication'); 7 | 8 | const { 9 | getAllOrders, 10 | getSingleOrder, 11 | getCurrentUserOrders, 12 | createOrder, 13 | updateOrder, 14 | } = require('../controllers/orderController'); 15 | 16 | router 17 | .route('/') 18 | .post(authenticateUser, createOrder) 19 | .get(authenticateUser, authorizePermissions('admin'), getAllOrders); 20 | 21 | router.route('/showAllMyOrders').get(authenticateUser, getCurrentUserOrders); 22 | 23 | router 24 | .route('/:id') 25 | .get(authenticateUser, getSingleOrder) 26 | .patch(authenticateUser, updateOrder); 27 | 28 | module.exports = router; 29 | -------------------------------------------------------------------------------- /09-stripe-payment/starter/app.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | require('express-async-errors'); 3 | 4 | const express = require('express'); 5 | const app = express(); 6 | 7 | // controller 8 | 9 | // error handler 10 | const notFoundMiddleware = require('./middleware/not-found'); 11 | const errorHandlerMiddleware = require('./middleware/error-handler'); 12 | 13 | app.use(express.json()); 14 | app.use(express.static('./public')); 15 | 16 | // stripe 17 | app.use(notFoundMiddleware); 18 | app.use(errorHandlerMiddleware); 19 | 20 | const port = process.env.PORT || 3000; 21 | 22 | const start = async () => { 23 | try { 24 | app.listen(port, () => 25 | console.log(`Server is listening on port ${port}...`) 26 | ); 27 | } catch (error) { 28 | console.log(error); 29 | } 30 | }; 31 | 32 | start(); 33 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/routes/orderRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const { 4 | authenticateUser, 5 | authorizePermissions, 6 | } = require('../middleware/authentication'); 7 | 8 | const { 9 | getAllOrders, 10 | getSingleOrder, 11 | getCurrentUserOrders, 12 | createOrder, 13 | updateOrder, 14 | } = require('../controllers/orderController'); 15 | 16 | router 17 | .route('/') 18 | .post(authenticateUser, createOrder) 19 | .get(authenticateUser, authorizePermissions('admin'), getAllOrders); 20 | 21 | router.route('/showAllMyOrders').get(authenticateUser, getCurrentUserOrders); 22 | 23 | router 24 | .route('/:id') 25 | .get(authenticateUser, getSingleOrder) 26 | .patch(authenticateUser, updateOrder); 27 | 28 | module.exports = router; 29 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/routes/orderRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const { 4 | authenticateUser, 5 | authorizePermissions, 6 | } = require('../middleware/authentication'); 7 | 8 | const { 9 | getAllOrders, 10 | getSingleOrder, 11 | getCurrentUserOrders, 12 | createOrder, 13 | updateOrder, 14 | } = require('../controllers/orderController'); 15 | 16 | router 17 | .route('/') 18 | .post(authenticateUser, createOrder) 19 | .get(authenticateUser, authorizePermissions('admin'), getAllOrders); 20 | 21 | router.route('/showAllMyOrders').get(authenticateUser, getCurrentUserOrders); 22 | 23 | router 24 | .route('/:id') 25 | .get(authenticateUser, getSingleOrder) 26 | .patch(authenticateUser, updateOrder); 27 | 28 | module.exports = router; 29 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/assets/wrappers/RegisterPage.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | display: grid; 5 | align-items: center; 6 | .logo { 7 | display: block; 8 | margin: 0 auto; 9 | margin-bottom: 1.38rem; 10 | } 11 | .form { 12 | max-width: 400px; 13 | border-top: 5px solid var(--primary-500); 14 | } 15 | 16 | h3 { 17 | text-align: center; 18 | } 19 | p { 20 | margin: 0; 21 | margin-top: 1rem; 22 | text-align: center; 23 | } 24 | .btn { 25 | margin-top: 1rem; 26 | } 27 | .member-btn { 28 | background: transparent; 29 | border: transparent; 30 | color: var(--primary-500); 31 | cursor: pointer; 32 | letter-spacing: var(--letterSpacing); 33 | } 34 | ` 35 | export default Wrapper 36 | -------------------------------------------------------------------------------- /06-jobs-api/final/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/User') 2 | const jwt = require('jsonwebtoken') 3 | const { UnauthenticatedError } = require('../errors') 4 | 5 | const auth = async (req, res, next) => { 6 | // check header 7 | const authHeader = req.headers.authorization 8 | if (!authHeader || !authHeader.startsWith('Bearer')) { 9 | throw new UnauthenticatedError('Authentication invalid') 10 | } 11 | const token = authHeader.split(' ')[1] 12 | 13 | try { 14 | const payload = jwt.verify(token, process.env.JWT_SECRET) 15 | // attach the user to the job routes 16 | req.user = { userId: payload.userId, name: payload.name } 17 | next() 18 | } catch (error) { 19 | throw new UnauthenticatedError('Authentication invalid') 20 | } 21 | } 22 | 23 | module.exports = auth 24 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/assets/wrappers/RegisterPage.js: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Wrapper = styled.section` 4 | display: grid; 5 | align-items: center; 6 | .logo { 7 | display: block; 8 | margin: 0 auto; 9 | margin-bottom: 1.38rem; 10 | } 11 | .form { 12 | max-width: 400px; 13 | border-top: 5px solid var(--primary-500); 14 | } 15 | 16 | h3 { 17 | text-align: center; 18 | } 19 | p { 20 | margin: 0; 21 | margin-top: 1rem; 22 | text-align: center; 23 | } 24 | .btn { 25 | margin-top: 1rem; 26 | } 27 | .member-btn { 28 | background: transparent; 29 | border: transparent; 30 | color: var(--primary-500); 31 | cursor: pointer; 32 | letter-spacing: var(--letterSpacing); 33 | } 34 | ` 35 | export default Wrapper 36 | -------------------------------------------------------------------------------- /08-send-email/final/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/User') 2 | const jwt = require('jsonwebtoken') 3 | const { UnauthenticatedError } = require('../errors') 4 | 5 | const auth = async (req, res, next) => { 6 | // check header 7 | const authHeader = req.headers.authorization 8 | if (!authHeader || !authHeader.startsWith('Bearer')) { 9 | throw new UnauthenticatedError('Authentication invalid') 10 | } 11 | const token = authHeader.split(' ')[1] 12 | 13 | try { 14 | const payload = jwt.verify(token, process.env.JWT_SECRET) 15 | // attach the user to the job routes 16 | req.user = { userId: payload.userId, name: payload.name } 17 | next() 18 | } catch (error) { 19 | throw new UnauthenticatedError('Authentication invalid') 20 | } 21 | } 22 | 23 | module.exports = auth 24 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/utils/jwt.js: -------------------------------------------------------------------------------- 1 | const jwt = require('jsonwebtoken'); 2 | 3 | const createJWT = ({ payload }) => { 4 | const token = jwt.sign(payload, process.env.JWT_SECRET, { 5 | expiresIn: process.env.JWT_LIFETIME, 6 | }); 7 | return token; 8 | }; 9 | 10 | const isTokenValid = ({ token }) => jwt.verify(token, process.env.JWT_SECRET); 11 | 12 | const attachCookiesToResponse = ({ res, user }) => { 13 | const token = createJWT({ payload: user }); 14 | 15 | const oneDay = 1000 * 60 * 60 * 24; 16 | 17 | res.cookie('token', token, { 18 | httpOnly: true, 19 | expires: new Date(Date.now() + oneDay), 20 | secure: process.env.NODE_ENV === 'production', 21 | signed: true, 22 | }); 23 | }; 24 | 25 | module.exports = { 26 | createJWT, 27 | isTokenValid, 28 | attachCookiesToResponse, 29 | }; 30 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/components/ChartsContainer.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | 3 | import BarChart from './BarChart'; 4 | import AreaChart from './AreaChart'; 5 | import Wrapper from '../assets/wrappers/ChartsContainer'; 6 | import { useSelector } from 'react-redux'; 7 | const ChartsContainer = () => { 8 | const [barChart, setBarChart] = useState(true); 9 | const { monthlyApplications: data } = useSelector((store) => store.allJobs); 10 | return ( 11 | 12 |

Monthly Applications

13 | 16 | {barChart ? : } 17 |
18 | ); 19 | }; 20 | export default ChartsContainer; 21 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/components/ChartsContainer.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | 3 | import BarChart from './BarChart'; 4 | import AreaChart from './AreaChart'; 5 | import Wrapper from '../assets/wrappers/ChartsContainer'; 6 | import { useSelector } from 'react-redux'; 7 | const ChartsContainer = () => { 8 | const [barChart, setBarChart] = useState(true); 9 | const { monthlyApplications: data } = useSelector((store) => store.allJobs); 10 | return ( 11 | 12 |

Monthly Applications

13 | 16 | {barChart ? : } 17 |
18 | ); 19 | }; 20 | export default ChartsContainer; 21 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/User') 2 | const jwt = require('jsonwebtoken') 3 | const { UnauthenticatedError } = require('../errors') 4 | 5 | const auth = async (req, res, next) => { 6 | // check header 7 | const authHeader = req.headers.authorization 8 | if (!authHeader || !authHeader.startsWith('Bearer')) { 9 | throw new UnauthenticatedError('Authentication invalid') 10 | } 11 | const token = authHeader.split(' ')[1] 12 | 13 | try { 14 | const payload = jwt.verify(token, process.env.JWT_SECRET) 15 | // attach the user to the job routes 16 | req.user = { userId: payload.userId, name: payload.name } 17 | next() 18 | } catch (error) { 19 | throw new UnauthenticatedError('Authentication invalid') 20 | } 21 | } 22 | 23 | module.exports = auth 24 | -------------------------------------------------------------------------------- /07-file-upload/final/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/User') 2 | const jwt = require('jsonwebtoken') 3 | const { UnauthenticatedError } = require('../errors') 4 | 5 | const auth = async (req, res, next) => { 6 | // check header 7 | const authHeader = req.headers.authorization 8 | if (!authHeader || !authHeader.startsWith('Bearer')) { 9 | throw new UnauthenticatedError('Authentication invalid') 10 | } 11 | const token = authHeader.split(' ')[1] 12 | 13 | try { 14 | const payload = jwt.verify(token, process.env.JWT_SECRET) 15 | // attach the user to the job routes 16 | req.user = { userId: payload.userId, name: payload.name } 17 | next() 18 | } catch (error) { 19 | throw new UnauthenticatedError('Authentication invalid') 20 | } 21 | } 22 | 23 | module.exports = auth 24 | -------------------------------------------------------------------------------- /07-file-upload/starter/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/User') 2 | const jwt = require('jsonwebtoken') 3 | const { UnauthenticatedError } = require('../errors') 4 | 5 | const auth = async (req, res, next) => { 6 | // check header 7 | const authHeader = req.headers.authorization 8 | if (!authHeader || !authHeader.startsWith('Bearer')) { 9 | throw new UnauthenticatedError('Authentication invalid') 10 | } 11 | const token = authHeader.split(' ')[1] 12 | 13 | try { 14 | const payload = jwt.verify(token, process.env.JWT_SECRET) 15 | // attach the user to the job routes 16 | req.user = { userId: payload.userId, name: payload.name } 17 | next() 18 | } catch (error) { 19 | throw new UnauthenticatedError('Authentication invalid') 20 | } 21 | } 22 | 23 | module.exports = auth 24 | -------------------------------------------------------------------------------- /08-send-email/starter/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/User') 2 | const jwt = require('jsonwebtoken') 3 | const { UnauthenticatedError } = require('../errors') 4 | 5 | const auth = async (req, res, next) => { 6 | // check header 7 | const authHeader = req.headers.authorization 8 | if (!authHeader || !authHeader.startsWith('Bearer')) { 9 | throw new UnauthenticatedError('Authentication invalid') 10 | } 11 | const token = authHeader.split(' ')[1] 12 | 13 | try { 14 | const payload = jwt.verify(token, process.env.JWT_SECRET) 15 | // attach the user to the job routes 16 | req.user = { userId: payload.userId, name: payload.name } 17 | next() 18 | } catch (error) { 19 | throw new UnauthenticatedError('Authentication invalid') 20 | } 21 | } 22 | 23 | module.exports = auth 24 | -------------------------------------------------------------------------------- /09-stripe-payment/final/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/User') 2 | const jwt = require('jsonwebtoken') 3 | const { UnauthenticatedError } = require('../errors') 4 | 5 | const auth = async (req, res, next) => { 6 | // check header 7 | const authHeader = req.headers.authorization 8 | if (!authHeader || !authHeader.startsWith('Bearer')) { 9 | throw new UnauthenticatedError('Authentication invalid') 10 | } 11 | const token = authHeader.split(' ')[1] 12 | 13 | try { 14 | const payload = jwt.verify(token, process.env.JWT_SECRET) 15 | // attach the user to the job routes 16 | req.user = { userId: payload.userId, name: payload.name } 17 | next() 18 | } catch (error) { 19 | throw new UnauthenticatedError('Authentication invalid') 20 | } 21 | } 22 | 23 | module.exports = auth 24 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/utils/jwt.js: -------------------------------------------------------------------------------- 1 | const jwt = require('jsonwebtoken'); 2 | 3 | const createJWT = ({ payload }) => { 4 | const token = jwt.sign(payload, process.env.JWT_SECRET, { 5 | expiresIn: process.env.JWT_LIFETIME, 6 | }); 7 | return token; 8 | }; 9 | 10 | const isTokenValid = ({ token }) => jwt.verify(token, process.env.JWT_SECRET); 11 | 12 | const attachCookiesToResponse = ({ res, user }) => { 13 | const token = createJWT({ payload: user }); 14 | 15 | const oneDay = 1000 * 60 * 60 * 24; 16 | 17 | res.cookie('token', token, { 18 | httpOnly: true, 19 | expires: new Date(Date.now() + oneDay), 20 | secure: process.env.NODE_ENV === 'production', 21 | signed: true, 22 | }); 23 | }; 24 | 25 | module.exports = { 26 | createJWT, 27 | isTokenValid, 28 | attachCookiesToResponse, 29 | }; 30 | -------------------------------------------------------------------------------- /08-send-email/starter/app.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | require('express-async-errors'); 3 | 4 | const express = require('express'); 5 | const app = express(); 6 | 7 | // error handler 8 | const notFoundMiddleware = require('./middleware/not-found'); 9 | const errorHandlerMiddleware = require('./middleware/error-handler'); 10 | 11 | app.use(express.json()); 12 | 13 | // routes 14 | app.get('/', (req, res) => { 15 | res.send('

Email Project

'); 16 | }); 17 | 18 | app.use(notFoundMiddleware); 19 | app.use(errorHandlerMiddleware); 20 | 21 | const port = process.env.PORT || 3000; 22 | 23 | const start = async () => { 24 | try { 25 | app.listen(port, () => 26 | console.log(`Server is listening on port ${port}...`) 27 | ); 28 | } catch (error) { 29 | console.log(error); 30 | } 31 | }; 32 | 33 | start(); 34 | -------------------------------------------------------------------------------- /09-stripe-payment/starter/middleware/authentication.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/User') 2 | const jwt = require('jsonwebtoken') 3 | const { UnauthenticatedError } = require('../errors') 4 | 5 | const auth = async (req, res, next) => { 6 | // check header 7 | const authHeader = req.headers.authorization 8 | if (!authHeader || !authHeader.startsWith('Bearer')) { 9 | throw new UnauthenticatedError('Authentication invalid') 10 | } 11 | const token = authHeader.split(' ')[1] 12 | 13 | try { 14 | const payload = jwt.verify(token, process.env.JWT_SECRET) 15 | // attach the user to the job routes 16 | req.user = { userId: payload.userId, name: payload.name } 17 | next() 18 | } catch (error) { 19 | throw new UnauthenticatedError('Authentication invalid') 20 | } 21 | } 22 | 23 | module.exports = auth 24 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/routes/userRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const { 4 | authenticateUser, 5 | authorizePermissions, 6 | } = require('../middleware/authentication'); 7 | const { 8 | getAllUsers, 9 | getSingleUser, 10 | showCurrentUser, 11 | updateUser, 12 | updateUserPassword, 13 | } = require('../controllers/userController'); 14 | 15 | router 16 | .route('/') 17 | .get(authenticateUser, authorizePermissions('admin'), getAllUsers); 18 | 19 | router.route('/showMe').get(authenticateUser, showCurrentUser); 20 | router.route('/updateUser').patch(authenticateUser, updateUser); 21 | router.route('/updateUserPassword').patch(authenticateUser, updateUserPassword); 22 | 23 | router.route('/:id').get(authenticateUser, getSingleUser); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /06-jobs-api/starter/app.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | require('express-async-errors'); 3 | const express = require('express'); 4 | const app = express(); 5 | 6 | // error handler 7 | const notFoundMiddleware = require('./middleware/not-found'); 8 | const errorHandlerMiddleware = require('./middleware/error-handler'); 9 | 10 | app.use(express.json()); 11 | // extra packages 12 | 13 | // routes 14 | app.get('/', (req, res) => { 15 | res.send('jobs api'); 16 | }); 17 | 18 | app.use(notFoundMiddleware); 19 | app.use(errorHandlerMiddleware); 20 | 21 | const port = process.env.PORT || 3000; 22 | 23 | const start = async () => { 24 | try { 25 | app.listen(port, () => 26 | console.log(`Server is listening on port ${port}...`) 27 | ); 28 | } catch (error) { 29 | console.log(error); 30 | } 31 | }; 32 | 33 | start(); 34 | -------------------------------------------------------------------------------- /06-jobs-api/starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "06-jobs-api", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "nodemon app.js" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bcryptjs": "^2.4.3", 13 | "cors": "^2.8.5", 14 | "dotenv": "^10.0.0", 15 | "express": "^4.17.1", 16 | "express-async-errors": "^3.1.1", 17 | "express-rate-limit": "^5.3.0", 18 | "helmet": "^4.6.0", 19 | "http-status-codes": "^2.1.4", 20 | "joi": "^17.4.0", 21 | "jsonwebtoken": "^8.5.1", 22 | "mongoose": "^5.13.2", 23 | "rate-limiter": "^0.2.0", 24 | "swagger-ui-express": "^4.1.6", 25 | "xss-clean": "^0.1.1", 26 | "yamljs": "^0.3.0" 27 | }, 28 | "devDependencies": { 29 | "nodemon": "^2.0.9" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /06.5-jobster-api/final/client/src/utils/axios.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import { clearStore } from '../features/user/userSlice' 3 | import { getUserFromLocalStorage } from './localStorage' 4 | 5 | const customFetch = axios.create({ 6 | baseURL: '/api/v1', 7 | }) 8 | 9 | customFetch.interceptors.request.use((config) => { 10 | const user = getUserFromLocalStorage() 11 | if (user) { 12 | config.headers['Authorization'] = `Bearer ${user.token}` 13 | } 14 | return config 15 | }) 16 | 17 | export const checkForUnauthorizedResponse = (error, thunkAPI) => { 18 | if (error.response.status === 401) { 19 | thunkAPI.dispatch(clearStore()) 20 | return thunkAPI.rejectWithValue('Unauthorized! Logging Out...') 21 | } 22 | return thunkAPI.rejectWithValue(error.response.data.msg) 23 | } 24 | 25 | export default customFetch 26 | -------------------------------------------------------------------------------- /06.5-jobster-api/starter/client/src/utils/axios.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import { clearStore } from '../features/user/userSlice' 3 | import { getUserFromLocalStorage } from './localStorage' 4 | 5 | const customFetch = axios.create({ 6 | baseURL: '/api/v1', 7 | }) 8 | 9 | customFetch.interceptors.request.use((config) => { 10 | const user = getUserFromLocalStorage() 11 | if (user) { 12 | config.headers['Authorization'] = `Bearer ${user.token}` 13 | } 14 | return config 15 | }) 16 | 17 | export const checkForUnauthorizedResponse = (error, thunkAPI) => { 18 | if (error.response.status === 401) { 19 | thunkAPI.dispatch(clearStore()) 20 | return thunkAPI.rejectWithValue('Unauthorized! Logging Out...') 21 | } 22 | return thunkAPI.rejectWithValue(error.response.data.msg) 23 | } 24 | 25 | export default customFetch 26 | -------------------------------------------------------------------------------- /11-auth-workflow/final/server/routes/userRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const { 4 | authenticateUser, 5 | authorizePermissions, 6 | } = require('../middleware/authentication'); 7 | const { 8 | getAllUsers, 9 | getSingleUser, 10 | showCurrentUser, 11 | updateUser, 12 | updateUserPassword, 13 | } = require('../controllers/userController'); 14 | 15 | router 16 | .route('/') 17 | .get(authenticateUser, authorizePermissions('admin'), getAllUsers); 18 | 19 | router.route('/showMe').get(authenticateUser, showCurrentUser); 20 | router.route('/updateUser').patch(authenticateUser, updateUser); 21 | router.route('/updateUserPassword').patch(authenticateUser, updateUserPassword); 22 | 23 | router.route('/:id').get(authenticateUser, getSingleUser); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/routes/userRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const { 4 | authenticateUser, 5 | authorizePermissions, 6 | } = require('../middleware/authentication'); 7 | const { 8 | getAllUsers, 9 | getSingleUser, 10 | showCurrentUser, 11 | updateUser, 12 | updateUserPassword, 13 | } = require('../controllers/userController'); 14 | 15 | router 16 | .route('/') 17 | .get(authenticateUser, authorizePermissions('admin'), getAllUsers); 18 | 19 | router.route('/showMe').get(authenticateUser, showCurrentUser); 20 | router.route('/updateUser').patch(authenticateUser, updateUser); 21 | router.route('/updateUserPassword').patch(authenticateUser, updateUserPassword); 22 | 23 | router.route('/:id').get(authenticateUser, getSingleUser); 24 | 25 | module.exports = router; 26 | -------------------------------------------------------------------------------- /05-JWT-Basics/final/app.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | require('express-async-errors'); 3 | 4 | const express = require('express'); 5 | const app = express(); 6 | 7 | const mainRouter = require('./routes/main'); 8 | const notFoundMiddleware = require('./middleware/not-found'); 9 | const errorHandlerMiddleware = require('./middleware/error-handler'); 10 | 11 | // middleware 12 | app.use(express.static('./public')); 13 | app.use(express.json()); 14 | 15 | app.use('/api/v1', mainRouter); 16 | 17 | app.use(notFoundMiddleware); 18 | app.use(errorHandlerMiddleware); 19 | 20 | const port = process.env.PORT || 5000; 21 | 22 | const start = async () => { 23 | try { 24 | app.listen(port, () => 25 | console.log(`Server is listening on port ${port}...`) 26 | ); 27 | } catch (error) { 28 | console.log(error); 29 | } 30 | }; 31 | 32 | start(); 33 | -------------------------------------------------------------------------------- /10-e-commerce-api/final/models/temp.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Requires the MongoDB Node.js Driver 3 | * https://mongodb.github.io/node-mongodb-native 4 | */ 5 | 6 | const agg = [ 7 | { 8 | $match: { 9 | product: new ObjectId('615c873ad584c748cc86e5bb'), 10 | }, 11 | }, 12 | { 13 | $group: { 14 | _id: null, 15 | averageRating: { 16 | $avg: '$rating', 17 | }, 18 | numberOfReviews: { 19 | $sum: 1, 20 | }, 21 | }, 22 | }, 23 | ]; 24 | 25 | MongoClient.connect( 26 | '', 27 | { useNewUrlParser: true, useUnifiedTopology: true }, 28 | function (connectErr, client) { 29 | assert.equal(null, connectErr); 30 | const coll = client.db('').collection(''); 31 | coll.aggregate(agg, (cmdErr, result) => { 32 | assert.equal(null, cmdErr); 33 | }); 34 | client.close(); 35 | } 36 | ); 37 | -------------------------------------------------------------------------------- /11-auth-workflow/starter/server/models/temp.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Requires the MongoDB Node.js Driver 3 | * https://mongodb.github.io/node-mongodb-native 4 | */ 5 | 6 | const agg = [ 7 | { 8 | $match: { 9 | product: new ObjectId('615c873ad584c748cc86e5bb'), 10 | }, 11 | }, 12 | { 13 | $group: { 14 | _id: null, 15 | averageRating: { 16 | $avg: '$rating', 17 | }, 18 | numberOfReviews: { 19 | $sum: 1, 20 | }, 21 | }, 22 | }, 23 | ]; 24 | 25 | MongoClient.connect( 26 | '', 27 | { useNewUrlParser: true, useUnifiedTopology: true }, 28 | function (connectErr, client) { 29 | assert.equal(null, connectErr); 30 | const coll = client.db('').collection(''); 31 | coll.aggregate(agg, (cmdErr, result) => { 32 | assert.equal(null, cmdErr); 33 | }); 34 | client.close(); 35 | } 36 | ); 37 | -------------------------------------------------------------------------------- /04-store-api/final/models/product.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const productSchema = new mongoose.Schema({ 4 | name: { 5 | type: String, 6 | required: [true, 'product name must be provided'], 7 | }, 8 | price: { 9 | type: Number, 10 | required: [true, 'product price must be provided'], 11 | }, 12 | featured: { 13 | type: Boolean, 14 | default: false, 15 | }, 16 | rating: { 17 | type: Number, 18 | default: 4.5, 19 | }, 20 | createdAt: { 21 | type: Date, 22 | default: Date.now(), 23 | }, 24 | company: { 25 | type: String, 26 | enum: { 27 | values: ['ikea', 'liddy', 'caressa', 'marcos'], 28 | message: '{VALUE} is not supported', 29 | }, 30 | // enum: ['ikea', 'liddy', 'caressa', 'marcos'], 31 | }, 32 | }) 33 | 34 | module.exports = mongoose.model('Product', productSchema) 35 | --------------------------------------------------------------------------------