NPS API
😞
😟
😐
😏
😃 NPS is a Restfull API to Net Promoter Score
📝About
NPS is a project developed during the Next Level Week presented by Rockeseat.
🚀 Getting started
# Clone this repository
$ git clone https://github.com/Luksdantas/NodeJS-NPS.git
# Access the project folder cmd/terminal
$ cd NodeJS-NPS
# install the dependencies
$ npm install
# Run the application in development mode
$ npm run dev
# Run tests
$ npm test
# The application will open on the port: 3333 - go to http://localhost:3333
🛠 NPS APIInsomnia document
POST Create User
Request
POST /users
curl --request POST \
--url http://localhost:3333/users \
--header 'Content-Type: application/json' \
--data '{
"name": "Example Name",
"email": "example@email.com"
}'
Response
{
"id": "uuid",
"name": "Example Name",
"email": "example@email.com",
"created_at": "timestamp"
}
POST Create Survey
Request
POST /surveys
curl --request POST \
--url http://localhost:3333/surveys \
--header 'Content-Type: application/json' \
--data '{
"title": "Example Survey",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam egestas eu odio vel pharetra. Donec faucibus consectetur ex. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas."
}'
Response
{
"id": "uuid",
"title": "Example Survey",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam egestas eu odio vel pharetra. Donec faucibus consectetur ex. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"created_at": "timestamp"
}
POST Send Mail
Request
POST /sendMail
curl --request POST \
--url http://localhost:3333/sendMail \
--header 'Content-Type: application/json' \
--data '{
"email": "example@email.com",
"survey_id": "uuid"
}'
Response
{
"id": "uuid",
"user_id": "uuid",
"survey_id": "uuid",
"value": null,
"created_at": "timestamp",
"user": {
"id": "uuid",
"name": "Example Name",
"email": "example@email.com",
"created_at": "timestamp"
},
"survey": {
"id": "uuid",
"title": "Example Survey",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam egestas eu odio vel pharetra. Donec faucibus consectetur ex. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"created_at": "timestamp"
}
}
GET List of Surveys
Request
GET /surveys
curl --request GET \
--url http://localhost:3333/surveys
Response
[
{
"id": "uuid",
"title": "Example Survey",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam egestas eu odio vel pharetra. Donec faucibus consectetur ex. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"created_at": "timestamp"
},
]
GET Email Answer
Request
GET /answers
curl --request GET \
--url 'http://localhost:3333/answers/:value?u=surveysUserId'
Response
{
"id": "surveyUserId",
"user_id": "uuid",
"survey_id": "uuid",
"value": value,
"created_at": "timestamp"
}
GET NPS
Request
GET /nps
curl --request GET \
--url http://localhost:3333/nps/:surveyId
Response
{
"detractors": 0,
"passives": 0,
"promotors": 0,
"totalAnswers": 0,
"nps": 0
}
📑 License
Made with ❤️ by Lucas Dantas 👋🏽 Get in Touch!