GithubHelp home page GithubHelp logo

edu_lookbook's Introduction

EDU LOOKBOOK

A place where all edu profiles can be stored and accessed.

Tech Stack

  • Node.js
  • Express.js
  • JSON web token (JWT)
  • Bcrypt

Main Files: Project Structure

     |-- src
        |-- index.js' ** the main driver of the app'
        |-- server
            |-- app.js
            |-- config
            |   |-- connect.js
            |   |-- envTypes.js
            |-- controllers
            |   |-- profile.js
            |   |-- user.js
            |-- helpers
            |   |-- validation.js
            |   |-- schemas
            |       |-- profiles.js
            |       |-- users.js
            |-- models
            |   |-- profile.js
            |   |-- user.js
            |   |-- schemas
            |       |-- profile.js
            |       |-- user.js
            |       |-- usersAllowed.js
            |-- routers
                |-- profileRouter.js
                |-- userRouter.js

Environment Variables

  • PORT -- server port number
  • DB_URL -- database URL
  • SECRET -- Secret key for verifying the token
  • NODE_ENV -- Specifies the Server environment (development, local, production)

Usage

  1. clone this repository.
  2. cd into project root directory.
  3. run npm install to install all dependencies. (you must have node installed)
  4. Run npm start to start the server.
  5. Open up Postman and then test out the Endpoints.

User CRUD Operations

SignUp User

Signs in a single user into the Application.

Endpoint Method Params Data type
/api/users/signup POST None None
  • Request Body

        {
            "username"    : "[email protected]",
            "method"      : "Local-auth",
            "firstName"   : "mefirst",
            "otherName"   : "meOther",
            "password"    : "mePassword",
            "userLevel"   :"1"
        }
  • Request Headers

    None

  • Success Response:

    Status: 200 OK
    Sample Content:

         {
             Message: "User account succesfully created!",
             token:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXV
             CJ9eyJpZCI6IjVmMGYwY2UxZmZjNTQ1MGI
             3YzllMzk4OSIsI"
         }
  • Error Response:

    • Status: 409 CONFLICT
      Content: { "Error": "User Already Exists" }

    OR

    • Status: 417 EXPECTATION_FAILED
      Content: { Error: 'Server error occured, user account creation failed!'}


Login User

Logs in a single user in the application.

Endpoint Method Params Data type
/api/users/login GET None None
  • Request Body

        {
            "username"    : "[email protected]",
            "password"    : "mePassword"
        }
  • Request Headers

    None

  • Success Response:

    Status: 200 OK
    Sample Content:

        {
           token:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXV
           CJ9eyJpZCI6IjVmMGYwY2UxZmZjNTQ1MGI
           3YzllMzk4OSIsI"
         }
  • Error Response:

    • Status: 400 BAD REQUEST
      Content: { error: 'Invalid password, retry with correct password!' }

    OR

    • Status: 404 NOT FOUND
      Content: { error: 'No such user exists!', err }

    OR

    • Status: 417 EXPECTATION_FAILED
      Content: { error: 'Server error occured during login, please try again later!'}


Get User By ID

Returns json data about a single user.

Endpoint Method Params Data type
/api/users/ GET None None
  • Request Body

    None

  • Request Headers

    { authorization: "Bearer Token" }

  • Success Response:

    Status: 200 OK
    Sample Content:

        
        {
          "username": "[email protected]",
          "firstName": "firstname",
          "otherName": "otherName"
        }
        
  • Error Response:

    • Status: 403 FORBIDDEN
      Content: { Error: 'Something Went Wrong!' }


Update User By ID

Updates data about a single user in the database.

Endpoint Method Params Data type
/api/users/ PATCH None None
  • Request Body

    Fields are not all required since its an update

        {
            "username"    : "[email protected]",
            "method"      : "Local-auth",
            "firstName"   : "mefirst",
            "otherName"   : "meOther",
            "password"    : "mePassword",
            "userLevel"   :"1"
        }
  • Request Headers

    { authorization: "Bearer Token" }

  • Success Response:

    Status: 200 OK
    Sample Content:

        {
            Message: "User has been successfully Updated"
        }
  • Error Response:

    • Status: 404 NOT FOUND
      Content: { Error: 'Something Went Wrong >>> User of Given ID was Not Found'}


Delete User By ID

Delets a single user from the Data Base.

Endpoint Method Params Data type
/api/users/:id DELETE required string
  • Request Body

    None

  • Request Headers

    { authorization: "Bearer Token" }

  • Success Response:

    Status: 200 OK
    Sample Content:

        {
             "Message": "User has been Deleted Successfully"
        }
  • Error Response:

    • Status: 400 BAD REQUEST
      Content: { Error: "Something went Wrong >> User OF given ID was not found",err}




Profile CRUD Operations

Create User profile

Create in a single user profile into the Application.

Endpoint Method Params Data type
/api/profiles/ POST None None
  • Request Body

        {
            "username"    : "meusername",
            "email"      : ['[email protected]','[email protected]'],
            "phone"   : ['0736284897','0736284897'],
            "organisation"   : [{name:"MTN",position:"PRO",   date:"24/09/2018"}],
            "skills"    : [{name:"playing",proficiency: "champion",favorite:true}],
            "address"    : [{country: "Uganda",state: "Wakiso",address_line: "plot_20"}],
            "strength"   :"Agility",
            "topics_of_interest"   :['currentStuff','Google']
        }
  • Request Headers

    None

  • Success Response:

    Status: 200 OK
    Sample Content:

         {
             Message: 'Your profile was successfully created', Profile }
         }
  • Error Response:

    • Status: 403 BAD REQUEST
      Content: { Error: 'User Profile Already Exists' }

    OR

    • Status: 403 BAD REQUEST
      Content: { error: 'An unknown server error occured while creating your profile, please retry!'}


View User Profiles

Logs in all single user profiles in the application.

Endpoint Method Params Data type
/api/profiles/ GET None None
  • Request Body

    None

  • Request Headers

    None

  • Success Response:

    Status: 200 OK
    Sample Content:

         {
              Profiles: [] 
         }
  • Error Response:

    • Status: 404 NOT FOUND
      Content: { Message: 'No Profiles Available' }

    OR

    • Status: 404 NOT FOUND
      Content: { Message: Something Went Wrong. Profiles Not Found, Error: err }


Get User Profile By ID

Returns json data about a single user Profile.

Endpoint Method Params Data type
/api/profiles/:id GET required string
  • Request Body

    None

  • Request Headers

    None

  • Success Response:

    Status: 200 OK
    Sample Content:

        {
             profile: profile 
        }
  • Error Response:

    • Status: 404 NOT FOUND
      Content: { Message: 'profile Not Found' }

    OR

    • Status: 404 NOT FOUND
      Content: {Message : Something Went Wrong. User Profile of Given id >> profileId << was Not Found , Error: err}


Update User Profile By ID

Updates data about a single user Profile in the database.

Endpoint Method Params Data type
/api/profiles/:id PATCH required string
  • Request Body

    Fields are not all required since its an update update only what you need to update.

        {
            "username"    : "upadatedUsername",
            "email"      : ['[email protected]','[email protected]'],
            "phone"   : ['0736284897','0736284897'],
            "organisation"   : [{name:"MTN",position:"PRO",   date:"24/09/2018"}],
            "skills"    : [{name:"playing",proficiency: "champion",favorite:true}],
            "address"    : [{country: "Uganda",state: "Wakiso",address_line: "plot_20"}],
            "strength"   :"Agility",
            "topics_of_interest"   :['currentStuff','Google']
        }
  • Request Headers

    None

  • Success Response:

    Status: 200 OK
    Sample Content:

        {
            Message: `User's Profile has been Updated` 
        }
  • Error Response:

    • Status: 404 NOT FOUND
      Content: { Message: Profile of given ID >> profileId << was not Found, Error: err }

    OR

    • Status: 403 FORBIDDEN
      Content: { Message: 'Username provided Already Taken >> Enter Unique Username' }


Delete User Profile By ID

Delets a single user Profile from the Data Base.

Endpoint Method Params Data type
/api/profiles/:id DELETE required string
  • Request Body

    None

  • Request Headers

    None

  • Success Response:

    Status: 200 OK
    Sample Content:

        {
             message: `User's Profile has been deleted successfully`
        }
  • Error Response:

    • Status: 400 BAD REQUEST
      Content: { error: 'Profile cannot be deleted.Try again' }


Contributing

You can help improve the code base of the application where neccessary by raising an issue or opening a pull request.

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.