Giter VIP home page Giter VIP logo

mentor-me-back's Introduction

Mentor Me - Back End

Mentor me app let entrepreneurs who are just starting out or small business owners to ask for advices or guidances on various business topics from (qualified) business professionals working in the industries for free.

Technology Used

  • Server: Node.js | Express
  • Authentication: Bcrypt & JWT.
  • Database Builder: Knex.js
  • Testing Database: Jest | Supertest | SQLite3
  • Production & Development Database: PostgreSQL
  • Package management: yarn

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

  • Clone github repository onto your local machine
  • Change directory into project folder.
  • Run yarn yarn install
  • Start server yarn server

Add environment variables - example .env template

DATABASE_URL=connect to personal database
SECRET=input your secret for password hashing here
DB_ENV=development
PORT=4000

Database Schema

Mentor Me Database Schema

RESTful API Endpoints

User Endpoints

Register new user - POST

https://bw-mentor-me.herokuapp.com/api/register

Argument
  {
    "username": "string",
    "password": "string",
    "name": "string",
    "email": "string",
    "role": "string",
    "photo": "string", // optional
  }
Return
{
"message": "Registration successful",
"user_id": number,
"token": “abcd"
}

Login existing user - POST

https://bw-mentor-me.herokuapp.com/api/login

Arguments
  {
    "username": “string",
    "password": “string"
  }
Return
  {
    "message": "Registration successful",
    "user_id": number,
    "token": “abcd"
  }

  Database generates id and timestamp.

Get all users - GET - RESTRICTED

https://bw-mentor-me.herokuapp.com/api/users

Return
  [
    {
      "user_id": number,
      "username": “string",
      "name": “string",
      "email": “string",
      "role": “string",
      "about": “string",
      "photo": “string"
    }, ...
  ]

Get user by id - GET

https://bw-mentor-me.herokuapp.com/api/user/:id

Return
  {
    "user_id": number,
    "username": “string",
    "name": “string",
    "email": “string",
    "role": “string",
    "about": “string",
    "photo": “string"
  }

Update user by id - PATCH

https://bw-mentor-me.herokuapp.com/api/user/:id

Optional Arguments
  {
    "username": "string",
    "name": "string",
    "email": "string",
    "role": "string",
    "about": "string",
    "photo": "string"
  }

Delete user by id - DELETE - RESTRICTED

https://bw-mentor-me.herokuapp.com/api/user/:id

Note: cannot delete user if they have messages.

Return
  {
    "message": "User successfully deleted"
  }

Posts Endpoints - question / message

Get questions - GET

https://bw-mentor-me.herokuapp.com/api/questions

Return
  [
    {
      "post_id": number,
      "post": “string",
      "description": “string",
      "category": “string",
      "user_id": number,
      "name": “string",
      "photo": “string"
    }
  ]

Get answers - GET

https://bw-mentor-me.herokuapp.com/api/answers

Returns all answers
[
    {
        "post_id": number,
        "post": "string",
        "description": "string",
        "category": "string",
        "user_id": number,
        "name": "string",
        "photo": "string"
    }, ...
]

Get answers by question id - GET

https://bw-mentor-me.herokuapp.com/api/answers/:id

Returns answers to question by question id
[
    {
        "post_id": number,
        "post": "string",
        "description": "string",
        "category": "string",
        "user_id": number,
        "name": "string",
        "photo": "string"
    }, ...
]

Add new post - user to add question or message - POST

https://bw-mentor-me.herokuapp.com/api/posts

Argument
  {
    “post": “string",
    “description": “string”,
    “category”: “string"
    “type": “string”, // question || message
    “user_fk": number
    "photo_path": "string", // optional
    "file_path": "string" // optional
    "conversation_fk": number  // optional
  }

  Database generates id and timestamp.

Add new post - user to add answer to question - POST

https://bw-mentor-me.herokuapp.com/api/answers

Argument
{
post: 'string',
category: 'string',
user_fk: number,  // user id who answers
question_fk: number,  // post id this answer relates to
}

Database generates id and timestamp.
Return:
{
    post_i": number,
    post: "string",
    category: "string",
    type: "string",
    name: "string",
    photo: "string"
}

Get post by id - GET

https://bw-mentor-me.herokuapp.com/api/posts/:id

Return
{
    "post_id": number,
    "post": "string",
    "description": "string",
    "category": "string",
    "user_id": number,
    "name": "string",
    "photo": "string"
}

Update post by id - PATCH

https://bw-mentor-me.herokuapp.com/api/posts/:id

Optional Arguments
  {
    "post": “string",
    "description": “string",
    "category": “string",
    "type": "string",
    "photo_path": “string",
    "file_path": “string"
  }

Delete post by id - DELETE

https://bw-mentor-me.herokuapp.com/api/posts/:id

Return
    { deleted: id }

Conversation Endpoints

Get conversation between two users by conversation id - GET

https://bw-mentor-me.herokuapp.com/api/conversations/:id

Return
  [
      {
        "post_id": 1,
        "post": "What's the relationship between aperture and ISO?",
        "description": "extended question goes here",
        "category": "Photography",
        "type": "question",
        "conversation_fk": 1,
        "user_id": 1,
        "name": "Angello Lopez"
    },
    {
        "post_id": 4,
        "post": "message from mentor",
        "description": null, // will be null for non-question
        "category": "Photography",
        "type": "message",
        "conversation_fk": 1,
        "user_id": 4,
        "name": "Lucy Lee"
    }, ...
  ]

Get conversation ids for a user by user id - GET

https://bw-mentor-me.herokuapp.com/api/conversation-list/:id

return
[
  number,
  number
]

mentor-me-back's People

Contributors

alex-ak avatar hunter315 avatar

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.