GithubHelp home page GithubHelp logo

class8project's People

Contributors

najeembot avatar oyolah avatar shaimaaelsayed98 avatar sohailhaqyar avatar tuncerschmidt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

najeembot

class8project's Issues

Setting up the routes on the frontend

  • Set up react router with react
  • Make routes with dummy components or just an h1
    ` <Route to='' render{() =>

    I am a dummy component

    }
    Set up the following routes
  1. Home page /
  2. Login /login
  3. Register /register
  4. Listboard /listboard
  5. Dashboard /dashboard
  6. Postfeed /posts
    7/. Dynamic route for ngos /listboard/:nclgoId

Authentication Done on Front-end

  • Make an action that takes in the token from the back-end through the login flow
  • Sets the token in the local storage
  • Checks for a token when the app.js component mounts
  • Sets the request headers in axios be the token

Setting Up Express

  • Installing and Importing Express
    npm install express --save
    -Add Boilerplate express code
    -create a port,
    listening to a port

Post Route : Create an NGO

  • Import Organisation Model
  • The Url is '/create-ngo/
  • Make an object with all the fields in req.body
  • new Organisation({the object })
  • We add error handling
  • You save the profile in the database.
  • If success you send back the new ngo and status 201

Set up Redux

  • Set up the store and the reducer and all the reduxy stuff

GET : get all the posts belonging to an organisation

  • You have to be authenticated :
    • Import passport middle ware.
    • You add it as the second argument to the route.
  • You query the database using the id of the author.
  • You send back the posts related to the organisation.

Setting Express Router

-Making a Routes Folder
-Import it into express
-Use it as middleware .
-Boilerplate Router file with an empty router

Setting Up Hashing

  • Install Bcrypt
  • When creating a user go to the password and get change the password field with a hashed version.

POST : Login

  • Get the ngo by their email
  • if no such ngo throw 404
  • if ngo found check the password
  • if matched :
    • Sign the token
    • Send back the token
  • if not matched we send back a 400 status.

GET : Get a current NGO

  • We need authentication before we start
  • after we authenticate we have access to the user in the request body
  • We send back the user

Configuring Passport

  • Initialise the passport middeware in the main file
  • Configure passport file in a separate file

Email Must be unique

  • Make a query for the database when creating a new user
  • If there is such an email send back a response 400 and a message email already exists.

Creating The Post Model

  • Create a Post-Model File
  • Import Mongoose
  • Create A Schema : With the Following Fields
  1. Subject : String,
  2. Image : Url,
  3. Contact : String
  4. text-post : String !
  5. Comments : [ { name : String , Feedback : String }]
  • User variable for the mongoose.model('posts',PostSchema)
  • Export User as default

The Organization Model

  • Make a File Organization-Model
  • Import Mongoose
  • Create a Schema with the following fields :
  1. Logo : URL !
  2. Name : String !
  3. password : hash !
  4. address : String !
  5. email : String !
  6. Phone : String !
  7. Year : Date
  8. Industry : String
  9. Keyword : [String] !
  10. Services : [String] !
  11. Description : String !
  12. Team Member : [{ name : String , avatar : url  , bio : String , title: String}]!
  13. Posts : [  The ID of the Posts ]! Schema.Types.ObjectId basically the type is supposed to be an Id
  • Make a Model providing the OrganizationSchema
  • Export as default OrganizationSchema

POST : create a new Post

  • You have to be authenticated to access this route
  • You get the Post model and you create a new object with all the fields in the request body
  • Send back that object in the post method
  • Very Important also to add in also the owner field from req.user so that we can use that to get all the posts within an organisation.

PUT : Update an ngo

  • Private route so we need authentication before we go.
  • update the user
  • check weather the password is modified and rehash the password
  • save the user

Body Parser

  • install body parser
  • Add it to the project
  • initialize bodyparser.json() as middleware.
  • urlencoded : extended true

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.