alindaByamukama / nodejs-w-irene

Learning Nodejs with Irene - Catalyst Cohort 12

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nodejs with Irene

Day Two

Day Three

Day Four

  • Testing our endpoints with Postman
  • How to use middleware
    • body parser --> process incoming data such as body payload - data received from client
    • session --> a session is often used in applications such as login/signup
    • time logger --> logs the time/date of each route change
      • can be used on specific routes

Day Five

Day Six

  • write a simple PUG page
  • URI (uniform resource identifier - name, location of both)
    • URL - uniform resource locator
    • URN - uniform resource name
  • Pug - formaerly known as Jade

Day Seven

  • Adding images, js and css to our pug files
  • app.use(express.static(path.join(__dirname, 'public')))
    • this loads any images, css, js and other files you may want in your project
    • it sets the default directory for all these files in the public directory
    • no need o reference the directory when linking css or images for examples
  • app.use('/public/images', express.static(__dirname + '/public/images'))
    • handles images you upload
  • installation of the following dependecies into our project
    • npm install connect-ensure-login
    • npm install express-session
    • npm install multer
    • npm install mongoose
    • npm install passport
    • npm install passport-local
    • npm install passport-local-mongoose
    • npm install moment
  • Assignment: Read about the MVC (model views controller) structure
  • Assignment: Add more Pug files to your project
    • Push your files to GitHub
    • Share the link to the repo

Day 8

  • Appyling the MVC architecture in our project
  • What is a mdolue?
  • Setup the router file, exported it
    • const express = require("express");
    • const router = express.Router();
  • Created a variable in the server file to access our routes
    • const registrationRoutes = require("./routes/regRoutes");
  • Middleware that allows us to acces the routes in the router file in the browser
    • app.use("/user", registrationRoutes);

Day 9

  • Database Creation
  • Import mongoose into the server -> this helps us to connect to mongodb without constantly opening it
  • Create a config dir and a db.js file
    • then import the db file into the server
  • setup db connections in server
  • import passport into server and add middleware
    • passport will help with us authentication
    • and tracking authentication in our system
  • import express-session and its middleware intot the server
  • Models (MVC)

Day 10

  • Learning about JS Async/Await, Callbacks, Promises by making ice cream -->
  • Assignment (see google classroom)

Day 11

  • check for users with existing user id, to stop duplicates
  • how to add routes for another file
  • how to get the list of registered users (specifically farmer one)
  • create a schema for produce upload with provision for owner of the produce

Day 12

  • create a produce upload route
    • handles image uploads with multer
    • uses aycn await in routes
    • the commented route was checking for registered FOs and the rendering the upload page
    • the post route was saving the file path of a single uploaded image and redirecting back to the dashboard
  • Assignment (see google classroom)

Day 13

  • Created authentication routes for our login/logout
    • Used CONNECT-ENSURE-LOGIN on the get route for produce uploads - cannot upload w/o being logged in
    • connect-ensure-login tracks users login sessions
    • Addes a logout button on the landing page that destroys a users login session and redirects back to the login page
    • The logout btn is a mini form that can be added to any page where you want a user to be able to logout
  • [status: { type: String, default: 'pending', enum: ['pedning', 'approved'], }]
    • find out what this does
  • [xxx: { type: mongoose.Schema.Types.ObjectId, ref: 'RegisterUser', required: true]
    • find out what this does
  • Assignment --> create dashboards for the respective users AO, FO, UF (see more on the Google Classroom)

Day 14

Day 15

Day 16

Day 17

Day 18

Day 19

Day 20 FINAL DAY

Resources

About

Learning Nodejs with Irene - Catalyst Cohort 12


Languages

Language:JavaScript 47.0%Language:Pug 44.8%Language:CSS 8.2%