/w9_backend-project-power-coders-fe

w9_backend-project-power-coders-fe created by GitHub Classroom

Primary LanguageJavaScript

Logo

SOC WELLBEING TOOLKIT - BACK-END

The SoC Wellbeing Toolkit helps bootcampers manage their wellbeing using tools and resources in one handy location.

This is the back-end documentation for the app.

The back-end creates and populates tables on a postgres database. It also serves as an API for the front-end.

Looking for the Front-end?

Installation

  git clone https://github.com/SchoolOfCode/w9_backend-project-power-coders-fe.git
  
  cd w9_backend-project-power-coders-fe
  
  npm i

Environment Variables

To run this project, you will need to add a .env file to the root with the following environment variables.

PGHOST

PGDATABASE

PGUSER

PGPASSWORD

PGPORT

Assign these variables to your relevant database credentials.

Database Setup

To initialise and populate the database, run the following commands:

  npm run db:resetResTable

  npm run db:resetFeedTable

Documentation

This is not yet deployed, so only works on localhost:3001 (back-end).

To run the back end:

  npm run dev

API Reference

Resources

Get all resources

  GET /resources
  • Sample Request
    fetch("http://localhost:3001/resources")
  • Sample Response
    {success: true, message: "", payload: [
        {
        "id":1,"title":"Hero's Journey",
        "description":"SoC is designed to challenge you. There may be times of doubt...",
        "week":1,
        "category":"Resilience",
        "link":"https://www.mybestself101.org/blog/2021/2/2/adventure-mindset-the-heros-journey",
        "author":"Joseph Trodden",
        "image_path":"1_hero_journey.png"},
    },
    ...]}

Get all resources by week

  GET /resources/week/${weekNumber}
  • Sample Request
    fetch("http://localhost:3001/resources/week/2")
  • Sample Response
    {"success": true,"message": "Week resources","payload":[ 
        {
        "id":2,
        "title":"Myers Briggs",
        "description":"There are different types of people in the bootcamp and in the coding industry...",
        "week":2,
        "category":"Personality",
        "link":"https://www.verywellmind.com/the-myers-briggs-type-indicator-2795583",
        "author":"Joseph Trodden",
        "image_path":"2_personality_types.png"
        }
    ]}

Get all resources by category

  GET /resources/category/${categoryName}
  • Sample Request
    fetch("http://localhost:3001/category/resilience")
  • Sample Response
    {"success":true,"message":"Category resources","payload":[
        {
        "id":1,
        "title":"Hero's Journey",
        "description":"SoC is designed to challenge you. There may be times of doubt and uncertainty... ",
        "week":1,
        "category":"Resilience",
        "link":"https://www.mybestself101.org/blog/2021/2/2/adventure-mindset-the-heros-journey",
        "author":"Joseph Trodden",
        "image_path":"1_hero_journey.png"
        }
    ]};

Feedback

Create new feedback post

  POST /feedback
  • Sample Request
    fetch("http://localhost:3001/feedback", {
      method: "POST",
      headers: {
        Accept: "application/json",
        "Content-Type": "application/json",
      },
      body: {
        "name": "Craig Summers",
        "coach": "Rikkiah Williams",
        "score": 3
        }
    });
  • Sample Response
    {"success": true, "message": "Feedback posted", "payload": [
        {
        "feedback_id": 5,
        "time": "2022-06-28T15:19:18.547Z",
        "name": "Craig Summers",
        "coach": "Rikkiah Williams",
        "score": 3
        }
    ]
}

Get all feedback

  GET /feedback
  • Sample Request
    fetch("http://localhost:3001/feedback")
  • Sample Response
    {
    "success": true,
    "message": "All feedback",
    "payload": [
        {
            "feedback_id": 1,
            "time": "2022-06-28T10:48:37.480Z",
            "name": "Craig",
            "coach": "Rikki",
            "score": 8
        },
        {
            "feedback_id": 2,
            "time": "2022-06-28T10:48:37.480Z",
            "name": "Rajesh",
            "coach": "Vicki",
            "score": 7
        },
    }

Roadmap

Stretch Goals

  • Additional ‘users’ table to store user data in DB
  • Additional models and routes to facilitate logins using the users table

Running Tests

Currently implemented test suites check all CRUD operations on both routers (resources and feedback) and assert that the status code and data received is as expected.

To run tests, run the following command

  npm run test

Tech Stack

Server: Node, Express, PostgreSQL, Jest, Supertest

Appendix

CRUD routes currently not used by Front-end:

  • Get /resources
  • Get /resources/category/${categoryName}
  • Get /feedback

DB Schema

db_schema

Client/Server Interaction

stack_interaction

Authors

Acknowledgements

Documentation created using readme.so