joeljohn159 / SERNDating

A dating app where users can connect based on compatibility. It includes a Landing Page, User Registration & Login, a Match Finding Page with an algorithm to suggest matches, a Notification Page for updates, a Profile Page with match details, and a Chatting Page for real-time communication. The backend ensures smooth matching and messaging.
0 stars 0 forks source link

Create User Registration & Login (apis) #1

Open joeljohn159 opened 1 month ago

aa1588 commented 3 weeks ago

1. Register a user

Request

curl --request POST \
  --url http://localhost:8080/users/register \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/2023.5.8' \
  --data '{
    "username": "random user",
    "email": "random@user.com",
    "password": "abcdef"
}'

Response 201

{
    "msg": "User Registration Success!",
    "data": {
        "id": 1,
        "username": "random user",
        "email": "random@user.com",
        "updatedAt": "2024-10-31T22:52:29.610Z",
        "createdAt": "2024-10-31T22:52:29.610Z"
    },
    "status": "SUCCESS"
}
aa1588 commented 3 weeks ago

2. Login a user

Request

curl --request POST \
  --url http://localhost:8080/users/login/ \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/2023.5.8' \
  --data '{
    "email": "random@user.com",
    "password": "abcdef"
}'

Response 200

{
    "msg": "Login success",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJyYW5kb21AdXNlci5jb20iLCJpYXQiOjE3MzA0MTUxNzZ9.KjhUwIH5EJ4CtsNz2aTSjt0HE3qxRdB541tPV9JF9R0",
    "data": {
        "id": 1,
        "email": "random@user.com",
        "username": "random user",
        "createdAt": "2024-10-31T22:52:29.000Z",
        "updatedAt": "2024-10-31T22:52:29.000Z"
    }
}
aa1588 commented 3 weeks ago

3. Get user data

Request

curl --request GET \
  --url http://localhost:8080/users/me/ \
  --header 'User-Agent: insomnia/2023.5.8' \
  --header 'x-auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJyYW5kb21AdXNlci5jb20iLCJpYXQiOjE3MzA0MTUxNzZ9.KjhUwIH5EJ4CtsNz2aTSjt0HE3qxRdB541tPV9JF9R0'

Response 200

{
    "msg": "SUCCESS",
    "data": {
        "id": 1,
        "username": "random user",
        "email": "random@user.com",
        "createdAt": "2024-10-31T22:52:29.000Z",
        "updatedAt": "2024-10-31T22:52:29.000Z"
    }
}
aa1588 commented 3 weeks ago

@joeljohn159 @Azeemrm6 Please review and let me know if any update is required.