Skip to content

This is an API developed during the course "Rest API NodeJs using TDD, Clean Architecture and Typescript"

Notifications You must be signed in to change notification settings

renatops1991/clean-code-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Clean Code Node API

This is an API developed during the course "Rest API NodeJs using TDD, Clean Architecture and Typescript" by Rodrigo Manguinho, focusing on the development of a decoupled API using the best practices of TDD, Clean Architecture, DDD and Solid. Outside the course, I used some references like Clean Code TypeScript for better enjoyment and personal development.

Routes

Login API

  • [POST] - Create user: {{host}}/api/signup
  • [POST] - Sign in user: {{host}}/api/signin

Survey API

  • [POST] - Create Survey {{host}}/api/survey
  • [GET] - Search All Surveys {{host}}/api/surveys

Survey Result API

  • [PUT] - Save Survey Result {{host}}/api/surveys/{{survey-id}}/results
  • [GET] - Load Survey Result {{host}}/api/surveys/{{survey-id}}/results

GraphQL routes

URI: {{host}}/graphql

// Create User
mutation {
    signUp(name: "Jonh Foo Bar", email: "jonhfoobar@email.com", password: "12345", passwordConfirmation: "12345") {
        accessToken
        name
  }
}
//  Sign in user
query {
  signIn(email: "jonhfoobar@email.com", password: "12345"){
    accessToken
  }
}
// Create Survey
mutation {
  survey(question: "test?", answers: [{ image: "foo", answer: "foo" }])
}
// Search All Surveys
query {
  surveys {
    id
    question
    answers {
      image
      answer
    }
    createdAt 
  }
}
// Answer Survey
mutation {
  saveSurveyResult(surveyId: "6328d447c15003f6e6865391", answer: "foo") {
    surveyId
    question
    createdAt
    answers {
      image
      answer
      isCurrentAccountAnswer
      percent
      count
    }
  }
}
// Load Survey Result
query{
  surveyResult(surveyId: "6328d447c15003f6e6865391") {
    surveyId
    question
    createdAt
    answers {
      image
      answer
      isCurrentAccountAnswer
      percent
      count
    }
  }
}

API Docs

Swagger: {{host}}/api-docs

Stack

  • Node.js + Typescript
  • Express
  • Nodemon
  • Bcrypt
  • JWT(Json Web Token)
  • MongoDB
  • Design Pattern (Composite, Adapter, Builder and Factory)
  • Clean Architecture
  • SOLID
  • DDD
  • TDD
  • GraphQL

Docker Local Development

  • npm run start:dev

Installation

cp example.env .env
npm install

Watching the application

tsc -w

Running the Application

npm run start:dev // using docker

or

npm run build
npm run start // using node

Notice: This command is configured with debug in vsCode

Stopping the Application

npm run stop:dev //stop docker

Ports is running

  • REST: {{host}}:3003
  • Debug: {{host}}:9222

Running Test

# Running test without coverage
npm run test

# Unit test
npm run test:unit

# Integration test
npm run test:Integration

# Running all test with coverage
npm run test:ci

# Running all test and show errors
npm run test:verbose

About

This is an API developed during the course "Rest API NodeJs using TDD, Clean Architecture and Typescript"

Topics

Resources

Stars

Watchers

Forks

Languages