Restful API to menage users
HTTP methods | URI path | Description |
---|---|---|
POST | /api/user | Register user |
POST | /api/user/auth | User authenticate and retrieve token |
GET | /api/user | Retrieve user on JSON format |
GET | /api/users | Retrieve all users on JSON format |
PATCH | /api/user | Update user fields |
PATCH | /api/user/password | Update user password |
DELETE | /api/user/delete | Delete user |
{
"id": "5eb6525aeb6f612b84d6e674",
"name": "user",
"surname": "userName",
"username": "theUser",
"email": "user@example.com"
}
const UserSchema = new Schema({
name: {type: String, required: true, trim: true},
surname: {type: String, required: true, trim: true},
username: {type: String, required: true, trim: true},
email: {type: String, required: true, trim: true},
password: {type: String, required: true, trim: true},
createdAt: {type: Date, required: true, default: Date.now()},
authenticatedAt: {type: Date},
deactivated: {type: Boolean, default: false}
})
- Node Js
- Express Js
- MongoDB
- Mongoose
- JSON Web Token
- Bcrypt
- Testing:
- Mocha
- Chai