Skip to content

User Routes

Alex Aralis edited this page Aug 1, 2017 · 7 revisions

User Routes

Create New User

Authorization token NOT required. Creates a new user and returns a session token along with the user data.

POST /user

requires

{
  email: String,
  username: String,
  password: String,
  isTutor: ?Boolean,
  subjects: ?Array<String>,
  zipCode: ?Number,
  wage: ?Number,
}

returns

{
  token: String,
  user: {
    _id: String,
    email: String,
    username: String
    isTutor: Boolean,
    subjects: Array<String>,
    zipCode: Number,
    wage: Number,
  }
}

Get User

Authorization required. Returns the given tokens user information.

GET /user

returns

{
  _id: String,
  email: String,
  username: String,
  isTutor: Boolean,
  subjects: Array<String>,
  zipCode: Number,
  wage: Number,
}

Get single user. requires auth.

GET /user/:userId

returns

{
  user: User,
  message: string,
}

Delete User

Authorization required. Deletes the user account if the password of the account associated with the provided authorization token is provided.

DELETE user/

requires

{
  password: String
}

returns
```javascript
{
  user: User,
  message: String
}

Update User

Authorization required. If the field exists in the User model, update that field with the given value. Fields that are not part of the user model will be ignored.

PATCH /user

requires

{
  username: ?String,
  email: ?String,
  password: ?String,
  isTutor: ?Boolean,
  subjects: ?Array<String>,
  zipCode: ?Number,
  wage: ?Number,
}

returns

{
  user: User
}

Clone this wiki locally