Git Product home page Git Product logo

find-a-mentor-api's Introduction

Gatsby

Gatsby's default starter

Kick off your project with this default boilerplate. This starter ships with the main Gatsby configuration files you might need to get up and running blazing fast with the blazing fast app generator for React.

Have another more specific idea? You may want to check out our vibrant collection of official and community-created starters.

πŸš€ Quick start

  1. Create a Gatsby site.

    Use the Gatsby CLI to create a new site, specifying the default starter.

    # create a new Gatsby site using the default starter
    gatsby new my-default-starter https://github.com/gatsbyjs/gatsby-starter-default
  2. Start developing.

    Navigate into your new site’s directory and start it up.

    cd my-default-starter/
    gatsby develop
  3. Open the source code and start editing!

    Your site is now running at http://localhost:8000!

    Note: You'll also see a second link: http://localhost:8000/___graphql. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the Gatsby tutorial.

    Open the my-default-starter directory in your code editor of choice and edit src/pages/index.js. Save your changes and the browser will update in real time!

🧐 What's inside?

A quick look at the top-level files and directories you'll see in a Gatsby project.

.
β”œβ”€β”€ node_modules
β”œβ”€β”€ src
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .prettierrc
β”œβ”€β”€ gatsby-browser.js
β”œβ”€β”€ gatsby-config.js
β”œβ”€β”€ gatsby-node.js
β”œβ”€β”€ gatsby-ssr.js
β”œβ”€β”€ LICENSE
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
└── README.md
  1. /node_modules: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed.

  2. /src: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template. src is a convention for β€œsource code”.

  3. .gitignore: This file tells git which files it should not track / not maintain a version history for.

  4. .prettierrc: This is a configuration file for Prettier. Prettier is a tool to help keep the formatting of your code consistent.

  5. gatsby-browser.js: This file is where Gatsby expects to find any usage of the Gatsby browser APIs (if any). These allow customization/extension of default Gatsby settings affecting the browser.

  6. gatsby-config.js: This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins you’d like to include, etc. (Check out the config docs for more detail).

  7. gatsby-node.js: This file is where Gatsby expects to find any usage of the Gatsby Node APIs (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process.

  8. gatsby-ssr.js: This file is where Gatsby expects to find any usage of the Gatsby server-side rendering APIs (if any). These allow customization of default Gatsby settings affecting server-side rendering.

  9. LICENSE: Gatsby is licensed under the MIT license.

  10. package-lock.json (See package.json below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. (You won’t change this file directly).

  11. package.json: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project.

  12. README.md: A text file containing useful reference information about your project.

πŸŽ“ Learning Gatsby

Looking for more guidance? Full documentation for Gatsby lives on the website. Here are some places to start:

  • For most developers, we recommend starting with our in-depth tutorial for creating a site with Gatsby. It starts with zero assumptions about your level of ability and walks through every step of the process.

  • To dive straight into code samples, head to our documentation. In particular, check out the Guides, API Reference, and Advanced Tutorials sections in the sidebar.

πŸ’« Deploy

Deploy to Netlify

find-a-mentor-api's People

Contributors

arku avatar brentmclark avatar crysfel avatar damilare1 avatar davidkwan95 avatar dependabot[bot] avatar dmshvetsov avatar elft3r avatar mia01 avatar moshfeu avatar muthomimate avatar rohithgilla12 avatar shayanypn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

find-a-mentor-api's Issues

Add and configure Sentry

Is your feature request related to a problem? Please describe.
We currently lack visibility into errors that occur on our site and rely on the goodwill of others to report these errors. There are tools on the market that will automatically capture errors while providing enhanced workflows for resolving the bugs. My favorite among these tools is Sentry.io; I've been using them for years with great success.

Sentry offers open-source sponsorship and has accepted our request for sponsorship because they. are. awesome.

The only thing left to do is actually install and configure their tool.


If anyone has suggestions to offer, or questions before Sentry is installed please comment below.

Migrate the current mentors to mongo

We need to create a script to pull the data from mentors.json and save to the DB.

Additionally, when a new user registers, we need to find out if this new user is an existing mentor and link the new account to the profile.

Return all lists with mentors

We need to return all lists for the given user.

Request:

GET /users/{user._id}/lists

Response:

{
  success: true,
  lists: [
    { _id: 123, public: false, name: "QA Mentors", mentors: [{_id: 123, name: "John Doe", avatar: "..."}] },
    { _id: 456, public: true, name: "Designers", mentors: [] },
  ]
}

Restrictions

  • Members can only get their own private lists
  • Only admins can get other user's private list
  • Other members can see public lists from other users

Add CORS support

We need support for CORS, currently @moshfeu had to create a proxy in order to access the API deployed at api.codingcoach.io

We are going to deploy a development API frontend devs can use in their local environments, so they don't have to install the backend in their local.

I think we should use an environment variable to set the origin value, in development we will have origin=* but when going to production origin=codingcoach.io

Here's are some links on how enable CORS in nestjs
https://docs.nestjs.com/techniques/security#cors
https://github.com/expressjs/cors#configuration-options

Return the total number of mentors

Now that we have the pagination in place, we need to return the total amount of mentor that match the given filters, this is needed in the client to find out if there's a need to load more records or not.

The proposed response looks like this:

{
  success: true,
  "pagination": {
      "total": 281,
      "page": 15,
      "perpage": 20,
      "hasMore": false
  },
  filters: { ... },
  data: [ .... ]
}

Add/Remove a mentor from the favorite list

We want to allow users to create a list of favorite mentors. We need to create a new endpoint to add or remove a single mentor from this list, and if this list doesn't exist yet, we need to automatically create it.

Request

POST /users/{user._id}/favorites/{mentor._id}

Response

{ success: true }

When calling the endpoint, if the user doesn't exist in the list we need to add it, if the user exist in the list we need to remove it.

Validations

  • Make sure mentor exist
  • only admins can add favorites to different users
  • only admins can remove favorites to different users

As a mentor is possible to enter an email address that is too long

Describe the bug
As a mentor is possible to enter an email address is too long (254+ chars)
Also there is an arbitrary limits of 50-100 chars?

Expected behavior
RFC5321 specifies an email address can't exceed 254 chars.
However, there is 71-char limit:
jan@abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde0123456789abc.com

reports no client side validation message, only:

image

Also: the channel-email field takes a longer email address, I did not test its limits, but it appears to work fine.

Generate slugs for all users

We need to generate a slug for all users in the database (and all new users), we are going to use it to create links in the FE for their profile pages.

  • This task requires to update the user schema and add a new slug field, it should be unique and indexed in the database.
  • When a new user is created we need to generate a new slug for the new user
  • Update all user endpoints to find the user by slug or _id
  • Create a script to assign a slug to the current user in the database

Store the favorite mentors for the current user

We need to store the favorite mentors by the current user, for this we need:

An endpoint to get all favorite mentors for the current user

GET /mentors/favorites

An endpoint to like or dislike a mentor. If the mentor is not a favorite, then it will become a favorite mentor. If is already in favorites, the it will be removed from the list.

POST /mentors/favorites/{mentor_id}

Update existing list

We want to allow users to update the name and public field from existing lists. We need a new endpoint that receives these values, validates and update the records in the database

Request

PUT /users/{user._id}/lists/{list._id}

{
  "name": "Updating title",
  "public": true
}

Response

{ "success": true  }

Restrictions

  • Other users can't update other people's lists
  • Admin can update other people's lists
  • Users can't update the favorite list, this list should always be private. There's a isFavorite flag in the DB

Validations

  • name is required

Send deleted user email when user is deleted by admin

We want to let the user to know that we deleted them.

await this.mentorService.removeAllApplicationsByUserId(params.id);

Something like

if (res.ok && current.roles.includes(Role.ADMIN)) {
  const emailData = {
    to: user.email,
    templateId: Template.USER_DELETED,
    dynamic_template_data: {
      reason: params.reason,
    },
  };

  this.emailService.send(emailData);
}

I'll create the template in SendGrid
Template Id: de2e0c5217b6422a88274a6affd327e7

Relates to: Coding-Coach/find-a-mentor#628

Better error messages for User data

Right now, if a User is updated with anything that fails validation at the DB level, the API returns a 500 with a generic response. It would be much better if a 400 was returned with a specific error message so it's easier to figure out what went wrong.

Users can't delete their account

There's an error while deleting the user from mongo:

0|CodingCo | [Nest] 31013   - 08/07/2019, 6:41 PM   [ExceptionsHandler] Cast to ObjectId failed for value "auth0|123456789abc" at path "_id" for model "User" +927906ms
0|CodingCo | CastError: Cast to ObjectId failed for value "auth0|123456789abc" at path "_id" for model "User"
0|CodingCo |     at new CastError (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/error/cast.js:29:11)
0|CodingCo |     at ObjectId.cast (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/schema/objectid.js:242:11)
0|CodingCo |     at ObjectId.SchemaType.applySetters (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/schematype.js:892:12)
0|CodingCo |     at ObjectId.SchemaType._castForQuery (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/schematype.js:1304:15)
0|CodingCo |     at ObjectId.SchemaType.castForQuery (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/schematype.js:1294:15)
0|CodingCo |     at ObjectId.SchemaType.castForQueryWrapper (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/schematype.js:1273:15)
0|CodingCo |     at cast (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/cast.js:307:32)
0|CodingCo |     at model.Query.Query.cast (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/query.js:4528:12)
0|CodingCo |     at model.Query.Query._castConditions (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/query.js:1762:10)
0|CodingCo |     at model.Query.<anonymous> (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/query.js:2015:8)
0|CodingCo |     at model.Query._wrappedThunk [as _findOne] (/var/www/api.codingcoach.com/staging/releases/19/node_modules/mongoose/lib/helpers/query/wrapThunk.js:16:8)
0|CodingCo |     at process.nextTick (/var/www/api.codingcoach.com/staging/releases/19/node_modules/kareem/index.js:369:33)
0|CodingCo |     at process._tickCallback (internal/process/next_tick.js:61:11)

Based on the error all we need to do is fix the casting.

Email notifications

When a new member signs up as a mentor, we need to send an email right after the user submitted the application. Informing them we will review their application shortly.

Once the admin accepts a mentor request, we need to send an email to the new mentor with a confirmation/welcome message.

If the admin rejects the application, we need to send another email notifying the user the application has been rejected, we need to include the reason why the admin rejected the application.

Increase test coverage for MentorsController

In an effort to increase confidence when updating our codebase, or adding a new feature. We want to increase the test coverage with unit test.

The goal of this issue is to write unit tests for the MentorsController, when writing tests keep the following guidelines in mind:

  • We are testing each method in its own, meaning we need to mock all service dependencies and test calls to services when it makes sense.
  • Group all tests for a single method together:
describe('modules/mentors/MentorController', () => {
  describe('index', () => {
    it('should return all mentors', () => expect(true).toBe(true));
  });

  describe('featured', () => {
    it('should return a single mentor', () => expect(true).toBe(true));
  });

  describe('applications', () => {
    it('should throw an error if current user is not admin', () => expect(true).toBe(true));

    it('should return all applications', () => expect(true).toBe(true));

    it('should return applications by the given status', () => expect(true).toBe(true));

   // etc...
  });

  // etc...
});

Add CI

  • Test
  • Lint
  • Build
  • Deploy

Set up swagger environment

Currently it's not possible to view the swagger docs without running the BE which comes with its own config requirements and dependencies. It would be ideal to see the swagger docs on an established environment.

Create a marketing list in sendgrid for mentors

Background

We want to keep all mentors in a marketing list so we can communicate through email easily, so far @moshfeu has been manually adding mentors when approving PRs (mailchimp), however now that we deployed the new version we need to add those emails automatically when approving a mentor application.

Acceptance Criteria

  • Create a list in sendgrid
  • Add email to the list when approving a mentor

Mark User fields required at the database

As of now it's possible to get a user object into the database with invalid data. To guard against this, the following fields on the UserSchema should be marked as required:

  • auth0Id
  • email
  • name
  • avatar

Look here for an example of how to set a field in the schema as required.

Tags schema

Currently tags' schema

[
  {
    "label": {
        "value": "chocolate",
        "label": "Chocolate"
    },
    "value": {
        "value": "chocolate",
        "label": "Chocolate"
    }
  }
]

But it should be (like currently in the app)

[
  "frontend",
  "reactjs",
  "vuejs"
]

Get mentors for non loggedin users

Currently, when user is not loggedin, the server returns 401 error.
Expected result will be to return the mentors but without the channels so user will have to do login to contact a mentor.

Use smaller, more focused error response payload.

Right now, any errors surfaced by the validation routines send back a response with a fairly dense payload that makes isolating the error text complicated on the front end. It also leaks database identifiers, which is not ideal.

Here's an example of a constraint error:

{
   "statusCode":400,
   "error":"Bad Request",
   "message":[
      {
         "target":{
            "spokenLanguages":[
               "en"
            ],
            "tags":[
               "reactjs",
               "html",
               "css",
               "python",
               "graphql"
            ],
            "roles":[
               "Member",
               "Mentor"
            ],
            "name":"Brent M Clark",
            "email":"[email protected]",
            "avatar":"https://s.gravatar.com/avatar/2a2d22c34d297073e37687d3a846de47?s=80",
            "title":"Sr. Software Engineer",
            "country":"US",
            "channels":[
               {
                  "_id":"...",
                  "type":"linkedin",
                  "id":""
               },
               {
                  "_id":"...",
                  "type":"twitter",
                  "id":"brent_m_clark"
               },
               {
                  "_id":"...",
                  "type":"github",
                  "id":"brentmclark"
               },
               {
                  "type":"slack",
                  "id":"12345"
               }
            ]
         },
         "value":[
            {
               "_id":"...",
               "type":"linkedin",
               "id":""
            },
            {
               "_id":"...",
               "type":"twitter",
               "id":"brent_m_clark"
            },
            {
               "_id":"...",
               "type":"github",
               "id":"brentmclark"
            },
            {
               "type":"slack",
               "id":"12345"
            }
         ],
         "property":"channels",
         "children":[

         ],
         "constraints":{
            "arrayMaxSize":"channels must contain not more than 3 elements"
         }
      }
   ]
}

Eventually, you'll notice the useful portion of the payload: channels must contain not more than 3 elements. The rest of the information is seemingly unnecessary.

How about shrinking this down to something like:

{
   "statusCode":400,
   "error":"Bad Request",
   "messages": [
      "Error Message #1",
      "Error Message #2",
   ]
}

Add example .env file

There's no example .env file, making getting started on this repo a little bit harder. So, I think we should add one.

Add a new endpoint to return data for the filters

Description

Now that we have pagination in place, we need to provide the filters to the client. We need a single endpoint that returns all the data.

{
  "success": true,
  "data": {
    "countries": [{"id": "us", "label": "United State"}, ....],
    "languages": [{"id": "en", "label": "English"}, ....],
    "technologies": ["javascript", "reactjs", ....]
  }
}

The name filter will have its own endpoint.

We need to make sure all data returned has at least one mentor associated, we are not going to list countries, languages or technologies without any mentor

Return the favorite list

We need to create an endpoint to return only the favorite list for the given user.

Request

GET /users/{user._id}/favorites

{
  success: true,
  data: {
    name: "Favorites"
    mentors: [{ name: "john doe" }, .... ]
  }
}

Restrictions

  • This list is always private
  • Only current user (or admin) can get the favorite list

New endpoint to find out the status of the current user's applications

When user already sent his application and he wants to update his details, the client saves his details and try to create an application (and get an error of course).

This is because the client doesn't know if the current user has an application or not. We need an endpoint to check if this users have an application pending or not.

Increase test coverage for UserController

In an effort to increase confidence when updating our codebase, or adding a new feature. We want to increase the test coverage with unit test.

The goal of this issue is to write unit tests for the UsersController, when writing tests keep the following guidelines in mind:

  • We are testing each method in its own, meaning we need to mock all service dependencies and test calls to services when it makes sense.
  • Group all tests for a single method together, for example:
describe('modules/mentors/MentorController', () => {
  describe('index', () => {
    it('should return all mentors', () => expect(true).toBe(true));
  });

  describe('featured', () => {
    it('should return a single mentor', () => expect(true).toBe(true));
  });

  describe('applications', () => {
    it('should throw an error if current user is not admin', () => expect(true).toBe(true));

    it('should return all applications', () => expect(true).toBe(true));

    it('should return applications by the given status', () => expect(true).toBe(true));

   // etc...
  });

  // etc...
});

Review a mentor or giving "kudos".

I was thinking of a way for allowing users to review a mentor or giving him some kind of kudo(congrats) for his help.

My suggested flow is:

  1. User asks mentor help clicking in an action button.
  2. Mentor accepts it.
  3. After being accepted, the user at any time could thank the mentor by a review or something like that.

It is just an idea. But, having this we could have a base for a ranking system.

Regards.

Add a mentor to an existing list

We want to allow users to add mentors to any of the available lists. We need an endpoint to update add a new mentor to the existing list.

Request

PUT /users/{user._id}/lists/{list._id}/add

{
  mentors: [{ _id: "12345"}, { _id: "a user._id"}]
}

Response

{ success: true }

Restrictions

  • Members can only add their mentors to their own lists
  • Admins can add mentors to any list

Send all the user profile for each application

We want to show to the admin all information related to the user applying to become a mentor, therefore we need to return all user's data when calling GET /mentors/applications?status=pending

Create mentors lists

Users can create lists of mentors, for example: QA Mentors, Rockstars Devs, etc..

We need one endpoint to receive the name of the new list, along with the mentors we want to add to the list:

Request:

POST /users/{user._id}/lists

{
  "name": "QA Mentors",
  "public": false,
  "mentors": [{ _id: "1234" }, ... ]
}

Response:

{
  success: true,
  list: { _id: "12345" }
}

Validations

  • name should be required
  • public is optional and defaults to false
  • mentors is optional and defaults to an empty array

Restrictions

  • Members can create their own lists
  • Members can't create lists for other members
  • Admin can create lists for any other member

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.