Skip to content

Backend implementation demonstration in go with JWT, MongoDB, etc.

License

Notifications You must be signed in to change notification settings

1995parham-teaching/fandogh

Repository files navigation

Fandogh 🌰

GitHub Workflow Status Codecov GitHub go.mod Go version

APIs

Register new user with JSON request as follows:

curl 127.0.0.1:1378/register -X POST -d '{ "email": "[email protected]", "name": "Parham Alvani", "password": "123456" }' -H 'Content-Type: application/json'
{
  "Email": "[email protected]",
  "Password": "123456",
  "Name": "Parham Alvani"
}

Login into system and getting the token:

curl 127.0.0.1:1378/login -X POST -d '{ "email": "[email protected]", "password": "123456" }' -H 'Content-Type: application/json'
{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ1c2VyIiwiZXhwIjoxNjI1MzU4MDQ1LCJqdGkiOiI4NTYxYzA4NC1kYzAxLTQ0ZmEtODEyZS05ZjNhZDJlNDcxNTAiLCJpYXQiOjE2MjUzNTQ0NDUsImlzcyI6ImZhbmRvZ2giLCJuYmYiOjE2MjUzNTQ0NDUsInN1YiI6InBhcmhhbS5hbHZhbmlAZ21haWwuY29tIn0.hUiEGqQxCSTQOFDPBypKkdI85q7TxSGENY6IwA2QR7E",
  "Email": "[email protected]",
  "Password": "123456",
  "Name": "Parham Alvani"
}

Creating new home requires using the POST request with form data because it contains images:

curl -vvv 127.0.0.1:1378/api/homes -X POST  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ1c2VyIiwiZXhwIjoxNjI1Mzc5MDE3LCJqdGkiOiI4NDRhMzQ4Yy03OGVjLTRlNTctODJhZi03YjU3NTNmNjk5ZjciLCJpYXQiOjE2MjUzNzU0MTcsImlzcyI6ImZhbmRvZ2giLCJuYmYiOjE2MjUzNzU0MTcsInN1YiI6InBhcmhhbS5hbHZhbmlAZ21haWwuY29tIn0.EZUWQ-sLP1ClA0vtK6vZEcQ4qf3ZaBm9VpFV6smEwUc' -F 'title=sweet' -F 'location=italy' -F 'description=a place to live' -F 'peoples=3' -F 'room=good' -F 'bed=single' -F 'rooms=4' -F'bathrooms=1' -F'contract=good' -F'price=100' -F'security_deposit=1000' -F'photos=1,2' -F'[email protected]' -F'[email protected]'
{
  "ID": "60e1535541e125c415973cd2",
  "Owner": "[email protected]",
  "Title": "sweet",
  "Location": "italy",
  "Description": "a place to live",
  "Peoples": 3,
  "Room": "good",
  "Bed": 1,
  "Rooms": 4,
  "Bathrooms": 1,
  "Smoking": false,
  "Guest": false,
  "Pet": false,
  "BillsIncluded": false,
  "Contract": "good",
  "SecurityDeposit": 1000,
  "Photos": {
    "1": "60e1535541e125c415973cd2_1",
    "2": "60e1535541e125c415973cd2_2"
  },
  "Price": 100
}

About

Backend implementation demonstration in go with JWT, MongoDB, etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published