-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d3290a
commit 2a03e82
Showing
7 changed files
with
191 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,82 @@ | ||
# Node Clean Architecture | ||
|
||
[![Build Status](https://travis-ci.org/alan-nascimento/node-api-clean-architecture.svg?branch=master)](https://travis-ci.org/alan-nascimento/node-api-clean-architecture) | ||
|
||
[![Coverage Status](https://coveralls.io/repos/github/alan-nascimento/node-api-clean-architecture/badge.svg?branch=master)](https://coveralls.io/github/alan-nascimento/node-api-clean-architecture?branch=master) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/alan-nascimento/node-api-clean-architecture/badge.svg)](https://snyk.io/test/github/alan-nascimento/node-api-clean-architecture) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com) | ||
[![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/) | ||
|
||
# **Node API Clean Architecture** | ||
|
||
The purpose of this application was to build a well-defined and decoupled architecture, using TDD as the working methodology, Clean Architecture to distribute responsibilities in layers, always following the principles of SOLID and, whenever possible, applying Design Patterns to solve some common problems. | ||
|
||
## [**Documentation**](https://node-api-clean-architecture.herokuapp.com/api-docs) | ||
|
||
> ### Services | ||
1. [Register](./requirements/signup.md) | ||
2. [Login](./requirements/login.md) | ||
3. [Create Survey](./requirements/add-survey.md) | ||
4. [List Surveys](./requirements/load-surveys.md) | ||
5. [Answer Survey](./requirements/save-survey-result.md) | ||
6. [Survey Result](./requirements/load-survey-result.md) | ||
|
||
> ### Principles | ||
* Single Responsibility Principle (SRP) | ||
* Open Closed Principle (OCP) | ||
* Liskov Substitution Principle (LSP) | ||
* Interface Segregation Principle (ISP) | ||
* Dependency Inversion Principle (DIP) | ||
* Separation of Concerns (SOC) | ||
* Don't Repeat Yourself (DRY) | ||
* You Aren't Gonna Need It (YAGNI) | ||
* Keep It Simple, Silly (KISS) | ||
* Composition Over Inheritance | ||
* Small Commits | ||
|
||
> ### Design Patterns | ||
* Factory | ||
* Adapter | ||
* Composite | ||
* Decorator | ||
* Proxy | ||
* Dependency Injection | ||
* Abstract Server | ||
* Composition Root | ||
* Builder | ||
|
||
> ### Metodologies and Designs | ||
* TDD | ||
* Clean Architecture | ||
* DDD | ||
* Conventional Commits | ||
* GitFlow | ||
* Modular Design | ||
* Dependency Diagrams | ||
* Use Cases | ||
* Continuous Integration | ||
* Continuous Delivery | ||
* Continuous Deployment | ||
|
||
> ### TypeScript Features | ||
* Advanced OOP | ||
* Interface | ||
* Type Alias | ||
* Utility Types | ||
* Paths Modularization | ||
* Build | ||
* Deploy | ||
* Breakpoints | ||
|
||
> ### Tests Features | ||
* Unit Tests | ||
* Integration Tests | ||
* Test Coverage | ||
* Test Doubles | ||
* Mocks | ||
* Stubs | ||
* Spies | ||
* Fakes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Create survey | ||
|
||
> ## Success story | ||
1. ✅ Receive a **POST** request on route **/api/surveys** | ||
2. ✅ Validates if the request was made by an **admin** | ||
3. ✅ Validates mandatory data **question** and **answers** | ||
4. ✅ **Create** a survey with the data provided | ||
5. ✅ Returns **204**, without data | ||
|
||
> ## Exceptions | ||
1. ✅ Returns error **404** if the API does not exist | ||
2. ✅ Returns error **403** if the user is not admin | ||
3. ✅ Returns error **400** if question or answers are not provided by the client | ||
4. ✅ Returns error **500** if there is an error when trying to create the survey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Survey result | ||
|
||
> ## Success story | ||
1. ✅ Receive a **GET** request on route **/api/surveys/{survey_id}/results** | ||
2. ✅ Validates if the request was made by a **user** | ||
3. ✅ Returns **200** with survey result data | ||
|
||
> ## Exceptions | ||
1. ✅ Returns error **404** if the API does not exist | ||
2. ✅ Returns error **403** if not a user | ||
3. ✅ Returns error **500** if there is an error when trying to list the survey result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# List surveys | ||
|
||
> ## Success story | ||
1. ✅ Receive a **GET** request on route **/api/surveys** | ||
2. ✅ Validates if the request was made by a **user** | ||
3. ✅ Returns **204** if you have no survey | ||
4. ✅ Returns **200** with survey data | ||
|
||
> ## Exceptions | ||
1. ✅ Returns error **404** if the API does not exist | ||
2. ✅ Returns error **403** if not a user | ||
3. ✅ Returns error **500** if there is an error when trying to list the surveys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Login | ||
|
||
> ## Success story | ||
1. ✅ Receive a **POST** request on route **/api/login** | ||
2. ✅ Validates mandatory data **email** and **password** | ||
3. ✅ Validate that the **email** field is a valid email | ||
4. ✅ **Search** the user with the provided email and password | ||
5. ✅ Generates an **access token** from the user ID | ||
6. ✅ **Updates** user data with the generated access token | ||
7. ✅ Returns **200** with access token and user name | ||
|
||
> ## Exceptions | ||
1. ✅ Returns error **404** if the API does not exist | ||
2. ✅ Returns error **400** if email or password is not provided by the client | ||
3. ✅ Returns error **400** if the email field is an invalid email | ||
4. ✅ Returns error **401** if it does not find a user with the data provided | ||
5. ✅ Returns error **500** if there is an error when trying to generate the access token | ||
6. ✅ Returns error **500** if there is an error when trying to update the user with the generated access token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Reply survey | ||
|
||
> ## Success story | ||
1. ✅ Receive a **PUT** request on route **/api/surveys/{survey_id}/results** | ||
2. ✅ Validates if the request was made by a **user** | ||
3. ✅ Validates the **survey_id** parameter | ||
4. ✅ Validates that the **answer** field is a valid answer | ||
5. ✅ **Create** a survey result with the data provided if you do not have a record | ||
6. ✅ **Updates** a survey result with the data provided if you already have a record | ||
7. ✅ Returns **200** with survey result data | ||
|
||
> ## Exceptions | ||
1. ✅ Returns error **404** if the API does not exist | ||
2. ✅ Returns error **403** if not a user | ||
3. ✅ Returns error **403** if the survey_id passed in the URL is invalid | ||
4. ✅ Returns error **403** if the response sent by the client is an invalid response | ||
5. ✅ Returns error **500** if there is an error when trying to create the survey result | ||
6. ✅ Returns error **500** if there is an error when trying to update the survey result | ||
7. ✅ Returns error **500** if there is an error when trying to load the survey | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Register | ||
|
||
> ## Success story | ||
1. ✅ Receive a **POST** request on route **/api/signup** | ||
2. ✅ Validates mandatory data **name**, **email**, **password** and **passwordConfirmation** | ||
3. ✅ Validates that **password** and **passwordConfirmation** are the same | ||
4. ✅ Validate that the **email** field is a valid email | ||
5. ✅ **Validates** if a user already exists with the email provided | ||
6. ✅ Generates a password **encrypted** (this password cannot be decrypted) | ||
7. ✅ **Create** an account for the user with the data entered, **replacing** the password with the encrypted password | ||
8. ✅ Generates an **access token** from the user ID | ||
9. ✅ **Updates** user data with the generated access token | ||
10. ✅ Returns **200** with access token and user name | ||
|
||
> ## Exceptions | ||
1. ✅ Returns error **404** if the API does not exist | ||
2. ✅ Returns error **400** if name, email, password or passwordConfirmation are not provided by the client | ||
3. ✅ Returns error **400** if password and passwordConfirmation are not the same | ||
4. ✅ Returns error **400** if the email field is an invalid email | ||
5. ✅ Returns error **403** if the email provided is already in use | ||
6. ✅ Returns error **500** if an error occurs when trying to generate an encrypted password | ||
7. ✅ Returns error **500** if an error occurs when trying to create the user account | ||
8. ✅ Returns error **500** if there is an error when trying to generate the access token | ||
9. ✅ Returns error **500** if there is an error when trying to update the user with the generated access token |