People Around is a simple NestJS application to find people aroud you and send them likes and also dislikes.
After these first three steps below, you can open http://localhost:3000/feed to see user list.
$ npm install
$ npm run start
# $ npm run prisma:init
$ npm run prisma:migrate
$ npm run prisma:seed
Note: Please change .env
file contents with your credentials for database connection.
$ npm run test:e2e
List all users, including their calculated distance as _distance
field in the returning JSON response.
Name | Type | Default | Description |
---|---|---|---|
location | String? | - | Used as latitude/longitude coordinations to filter users in format of latitude,longitude . |
distance | Integer? | 1 | Used as proximity value to compare distance value like HAVING (_distance <= proximity) . |
metric | String? | km | Used as metric factor to calculate the distance. Valid values km = 0.001 for kilometers, mi = 0.000621371192 for miles. |
GET /feed
GET /feed?location=1.81912248,39.53409246
GET /feed?location=1.81912248,39.53409246&distance=10
GET /feed?location=1.81912248,39.53409246&distance=10&metric=mi
[
{
"id": 1,
"name": "Ali",
"email": "ali@baz.com",
"bio": "Hello!",
"latitude": 1.81912248,
"longitude": 39.53409246,
"createdAt": "2024-07-31T22:34:14.823Z",
"updatedAt": "2024-08-02T01:31:13.931Z",
"_distance": 0
},
...
]
400 Bad Request
: If metric is not km
or mi
Fetch a single user profile by given ID.
Name | Type | Default | Description |
---|---|---|---|
id | Integer | - | The target user ID. |
GET /user/1
{
"id": 1,
"name": "Ali",
"email": "ali@baz.com",
"bio": "Hello!",
"latitude": 1.81912248,
"longitude": 39.53409246,
"createdAt": "2024-07-31T22:34:14.823Z",
"updatedAt": "2024-08-02T12:41:58.258Z"
}
404 Not Found
: If user does not exist with given ID.
Send a like or dislike for a user by given ID.
Name | Type | Default | Description |
---|---|---|---|
id | Integer | - | The target user ID. |
Name | Type | Default | Description |
---|---|---|---|
action | Integer | - | The action to apply, 1 as like and 0 as dislike. |
POST /user/1/like?action=1
POST /user/1/like?action=0
{
"id": 123,
"likerId": 1,
"likedId": 2,
"action": 1,
"createdAt": "2024-08-02T13:06:02.003Z",
"updatedAt": "2024-08-02T13:06:02.003Z"
}
400 Bad Request
: If user ID or action is not valid.
409 Conflict
: If user was liked / disliked already, depending on same action.
Remove a like for a user by given ID.
Name | Type | Default | Description |
---|---|---|---|
id | Integer | - | The target user ID. |
DELETE /user/1/like
{
"id": 123,
"likerId": 1,
"likedId": 2,
"action": 1,
"createdAt": "2024-08-02T13:06:02.003Z",
"updatedAt": "2024-08-02T13:06:02.003Z"
}
400 Bad Request
: If user ID is not valid.
404 Not Found
: If no like / dislike found that was sent before.
Log in as a user.
Name | Type | Default | Description |
---|---|---|---|
String | - | User email. | |
password | String | - | User password. |
{
"email": "ali@baz.com",
"password": "123"
}
{
"id": 1,
"name": "Ali",
"email": "ali@baz.com",
"bio": "Dolor..",
"latitude": 1.81912248,
"longitude": 39.53409246,
"createdAt": "2024-07-31T22:34:14.823Z",
"updatedAt": "2024-07-31T22:34:14.823Z"
}
400 Bad Request
: If no valid email or password provided.
404 Not Found
: If no user found with given email.
401 Unauthorized
: If given password did not match.
Log out as a user.
Name | Type | Default | Description |
---|---|---|---|
String | - | User email. |
{
"email": "ali@baz.com"
}
{
"okay": true,
"email": "ali@baz.com"
}
400 Bad Request
: If no valid email provided.
Register as a user.
Name | Type | Default | Description |
---|---|---|---|
name | String | - | User name. |
String | - | User email. | |
password | String | - | User password. |
bio | String? | - | User bio. |
latitude | Float? | - | User latitude. |
longitude | Float? | - | User longitude. |
{
"name": "Kerem",
"email": "ben@kerem.com",
"password": "123",
"bio": "Hello, world!",
"latitude": 1.234,
"longitude": 1.234
}
{
"id": 20,
"name": "Kerem",
"email": "ben@kerem.com",
"bio": "Hello, world!",
"latitude": 1.234,
"longitude": 1.234,
"createdAt": "2024-08-02T13:36:18.220Z",
"updatedAt": "2024-08-02T13:36:18.220Z"
}
400 Bad Request
: If required fields not provided.
409 Conflict
: If email was taken already.
Update as a user.
Name | Type | Default | Description |
---|---|---|---|
id | Integer | - | User ID. |
name | String | - | User name. |
String? | - | User email. | |
password | String? | - | User password. |
bio | String? | - | User bio. |
latitude | Float? | - | User latitude. |
longitude | Float? | - | User longitude. |
{
"id": 20,
"name": "Kerem",
"email": "ben@kerem.com",
"password": "123",
"bio": "Hello, world!",
"latitude": 1.234,
"longitude": 1.234
}
{
"id": 20,
"name": "Kerem",
"email": "ben@kerem.com",
"bio": "Hello, world!",
"latitude": 1.234,
"longitude": 1.234,
"createdAt": "2024-08-02T13:36:18.220Z",
"updatedAt": "2024-08-02T13:42:01.380Z"
}
400 Bad Request
: If required fields not provided.
404 Not Found
: If no user found by ID.
409 Conflict
: If email was taken already.