Skip to content

Backend sample test APIs

Funmilayo E. Olaiya edited this page Nov 2, 2020 · 20 revisions

Welcome to the code-jammers-backend wiki!

This wiki will walk you through on how to test all the present APIs in code jammers backend repo.

KeyNote: The APIs are well validated. It's best to follow the error messages to get an understanding when something is not working as it should.

  1. To sign up:

    POST http://localhost:3000/api/v1/users/signup
{
	"email": "[email protected]", // you can put your real email.
	"password": "123456",
	"username": "funmibaby"
}

A verification email will be sent to your email, open the email and click on the verify me button.

  1. To sign in:

    POST http://localhost:3000/api/v1/users/signin
{
	"email": "[email protected]",
	"password": "123456"
}
  1. To reset password:

    POST http://localhost:3000/api/v1/users/recover
{
	"email": "[email protected]"
}

Then in the email gotten, click on the reset password button and copy the link on the page.

Then: POST http://localhost:3000<the copied link>

{
	"newPassword": "123456"
}
  1. To update profile:

    PATCH http://localhost:3000/api/v1/user-profile
  • Authentication required after sign up/in: Bearer token
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "firstName": "Ufuoma",
    "lastName": "Ogodo",
    "profilePicture": "https://www.instagram.com/_bellogo/"
}
  1. To subscribe to the newsletter

    POST http://localhost:3000/api/v1/newsletter/subscribe
{
   "firstName": "Funmilayo",
   "email": "[email protected]"
}
  1. To make an admin send newsletters

    POST http://localhost:3000/api/v1/newsletter/admin/create_newsletter
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "title": "What is Lorem Ipsum?",
    "message": "Lorem Ipsum is simply dummy text of the printing"
}
  1. To unsubscribe from the newsletter

    GET http://localhost:3000/api/v1/newsletter/unsubscribe/:email

  2. For an admin to add a country

    POST http://localhost:3000/api/v1/admin/country

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
     "nameOfCountry": "Ghana",
     "gallery": "https://image.shutterstock.com/image-illustration/togo-flag-silk-260nw-419363206.jpg",
     "capital": "Lome",
     "population": 205,
     "officialLanguage": "English",
     "region": "West Africa",
     "currency": "CFA franc"
}
  1. For an admin to update a country

    PATCH http://localhost:3000/api/v1/admin/country/:countryId
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
     "nameOfCountry": "Togo",
     "gallery": "https://image.shutterstock.com/image-illustration/togo-flag-silk-260nw-419363206.jpg",
     "capital": "Lome",
     "population": 205,
     "officialLanguage": "English",
     "region": "West Africa",
     "currency": "CFA franc"
}
  1. For an admin to delete a country

DELETE http://localhost:3000/api/v1/admin/country/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
  1. For any user to get a country

GET http://localhost:3000/api/v1/country/:countryId

  1. For any user to get all countries

GET http://localhost:3000/api/v1/countries

  1. For an admin to add a state

POST http://localhost:3000/api/v1/admin/state/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "name": "Kano",
    "capital": "Ibadan",
    "gallery": "https://en.wikipedia.org/wiki/Lusaka#/mediaJPG"
}
  1. For an admin to update a state

PATCH http://localhost:3000/api/v1/admin/state/:stateId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "name": "Kano",
    "capital": "Kano",
    "gallery": "https://en.wikipedia.org/wiki/Lusaka#/mediaJPG"
}
  1. For an admin to delete a state

DELETE http://localhost:3000/api/v1/admin/state/:stateId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
  1. For any user to get a state

GET http://localhost:3000/api/v1/state/:stateId

  1. For any user to get all states

GET http://localhost:3000/api/v1/states

  1. For an admin to add a tourist center

POST http://localhost:3000/api/v1/admin/tourist-center/:countryId

{
    "name": "Robben Island Museumm",
    "location": "Cape Town",
    "gallery": "https://www.fodors.com/assets/destinations/45/robben-island-prison-robben-island-cape-town-south-africa_main.jpg",
    "about": "Robben Island is an island in Table Bay, 6.9 kilometres west of the coast of Bloubergstrand, north of Cape Town, South Africa. It takes its name from the Dutch word for seals, hence the Dutch/Afrikaans name Robbeneiland, which translates to Seal Island"
}

  1. For an admin to update a tourist center

PATCH http://localhost:3000/api/v1/admin/tourist-center/:tourist-centerId

{
    "name": "Robben Island Museum",
    "location": "Cape Town",
    "gallery": "https://www.fodors.com/assets/destinations/45/robben-island-prison-robben-island-cape-town-south-africa_main.jpg",
    "about": "Robben Island is an island in Table Bay, 6.9 kilometres west of the coast of Bloubergstrand, north of Cape Town, South Africa. It takes its name from the Dutch word for seals, hence the Dutch/Afrikaans name Robbeneiland, which translates to Seal Island"
}

  1. For an admin to delete a tourist center

DELETE http://localhost:3000/api/v1/admin/tourist-center/:tourist-centerId

  1. For an admin to get a tourist center

GET http://localhost:3000/api/v1/tourist-center/:tourist-centerId

  1. For an admin to get a tourist center

GET http://localhost:3000/api/v1/tourist-centers

Clone this wiki locally