The goal to of this project is to do the following:
-
Check why the test is failing and fix what's necessary
-
Add an endpoint that creates a
Lead
object that belongs to a user, here's an example of theLead
object:
{
"name": "Albacross",
"domain": "albacross.com",
"lastVisit": "2020-02-11 21:37:00"
}
- Add an endpoint to find user using any of its text-based properties with his Leads included, e.g. if someone searches for
'joh'
it'll return user
{
"firstName": "John",
"lastName": "Wick",
"email": "john.wick@gmail.com",
"leads": [
{
"name": "Albacross",
"domain": "albacross.com",
"lastVisit": "2020-02-11 21:37:00"
}
]
}
- (optional) If you want you can add any improvements as you see fit
If you have any questions feel free to reach out to us!
Get a list of users.
- Method:
GET
- URL:
/users
[
{
"id": 1,
"firstName": "John",
"lastName": "Ondricka",
"email": "Melyssa39@hotmail.com",
"createdAt": "2021-04-09T08:14:56.000Z",
"updatedAt": "2021-04-12T05:39:35.000Z"
},
{
"id": 2,
"firstName": "Jane",
"lastName": "McCullough",
"email": "Rosie54@yahoo.com",
"createdAt": "2021-04-09T08:14:56.000Z",
"updatedAt": "2021-04-09T08:14:56.000Z"
}
]
Update part of the user with specific id.
- Method:
PATCH
- URL:
/users/:id
- Body:
{
"firstName": "Adam"
}
Get users with a matching result of text-based properties with his Leads included
- Method:
GET
- URL:
/users/:searchQuery
[
{
"id": 259,
"firstName": "Augusta",
"lastName": "Haley",
"email": "Tressie99@gmail.com",
"createdAt": "2021-04-12T05:38:37.000Z",
"updatedAt": "2021-04-12T05:38:37.000Z",
"leads": [
{
"id": 1,
"name": "Albacross",
"domain": "albacross.com",
"lastVisit": "2020-02-11T21:37:00.000Z",
"createdAt": "2021-04-12T06:06:32.000Z",
"updatedAt": "2021-04-12T06:06:32.000Z",
"UserId": 259
}
]
}
]
Create a new lead object that belongs to existing user.
- Method:
POST
- URL:
/leads/:userId
- Body:
{
"name": "Albacross",
"domain": "albacross.com",
"lastVisit": "2020-02-11 21:37:00"
}
You need to have Docker installed to run the project
To start the project just run:
$ yarn start
The API will be available on port 3250, if you want you can change it.
You can find the connection details in src/db/config.js
To run the tests use:
$ yarn test
Optionally to run tests in watch mode:
$ yarn test --watch
To use linter use:
$ yarn lint