Giter Site home page Giter Site logo

ilia-nodejs-challenge's Introduction

Hi there 👋

ilia-nodejs-challenge's People

Contributors

andre991 avatar bigsonlvrocha avatar ivanhoinacki-ilia avatar lucaseneasneves avatar

ilia-nodejs-challenge's Issues

Implement user auth

Must check the password for an e-mail and return true or false, jwt auth must be done in interface layer

Implement user deletion

Can only delete
Delete in a paranoid way
Must use transactions microsservice to check if user has 0 balance - will be done in a latter card

Implement route `GET /balance`

Swagger definition

paths:
  [...]
  /balance:
    get:
      description: Esse endpoint deve retornar um consolidado das transações de CREDITO e DEBITO, fazendo o calculo do valor, de prefência que seja uma query fazendo o calculo
      tags:
        - Transactions
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BalanceResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
      security: 
        - bearerAuth: []
components:
  schemas:
    [...]
    BalanceResponse:
      type: object
      properties:
        amount:
          type: integer
        
  responses:
    UnauthorizedError:
      description: Access token is missing or invalid    

Implement transaction listing

Implement reading from the database
Parameters that can be passed:

  • userId: string, required
  • type: CREDIT or DEBIT

Implement transaction domain

Implement a class that represents a transaction
The transaction must implement the following fields:

  • id
  • userId, string
  • type, CREDIT or DEBIT
  • amount, non null number

Implement balance reading

Implement reading the consolidation of the user's balance, try to use calculation bia database
Parameters:

  • userId
    Returns:
  • value

Implement transaction creation

Implement database creation of transaction
The document must implement the following fields

  • id: string not null, indexed
  • userId: string not null, indexed
  • variation: Decimal128 for value

Implement route `GET /transactions`

Implementação swagger:

paths:
  /transactions:
    [...]
    get:
      tags:
        - Transactions
      security: 
        - bearerAuth: []
      parameters:
        - in: query
          name: type
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/TransactionsModel'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
         [...]
components:
  schemas:
    [...]
    TransactionsModel:
      type: object
      required:
      - user_id
      - type
      - amount
      properties:
        id: 
          type: string
        user_id:
          type: string
        amount:
          type: integer
        type:
          type: string
          enum:
          - CREDIT
          - DEBIT
    [...]    

implement route `GET /users/:id`

swagger definition

paths:
  /users/:id:
    get:
      tags:
        - Users
      security: 
        - bearerAuth: []
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsersResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'

Implement docker-compose for transactions

Implement a docker compose configuration that will setup

  • a mongodb
  • the microsservice

Important: the network of the service must be ilia_code_challenge to allow connection between the services

implement route `POST /auth`

  /auth:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuthRequest'
      tags:
        - Auth
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthResponse'
          description: Response
        '401':
          $ref: '#/components/responses/UnauthorizedError'

implement user domain logic

User must have fields

  • id
  • firstName
  • lastName
  • email
  • passwordHash

New users must be created via an auth domain service, so plain text password will not be stored in this entity

Implement route `POST /users`

Swagger definition:

paths:
  # Users
  /users:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserRequest'
      tags:
        - Users
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsersResponse'
          description: Response
        '401':
          $ref: '#/components/responses/UnauthorizedError'

Implement user update

Must be able to update fields

  • first name
  • last name
  • email
  • password

Must allow to update only the logged in user

implement route `PATCH /users/:id`

Swagger definition:

paths:
  /users/:id:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserRequest'
      tags:
        - Users
      security: 
        - bearerAuth: []
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsersResponse'
          description: Response
        '401':
          $ref: '#/components/responses/UnauthorizedError'

Implement route `POST /transactions`

Implement and test interface of POST /transactions

Swagger definition

[...]
paths:
  # Transactions
  /transactions:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Transactions'
      tags:
        - Transactions
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionsModel'
          description: Response
        '401':
          $ref: '#/components/responses/UnauthorizedError'
      security: 
        - bearerAuth: []
 [...]
 components:
  schemas:
    Transactions:
      type: object
      required:
      - user_id
      - type
      - amount
      properties:
        user_id:
          type: string
        amount:
          type: integer
        type:
          type: string
          enum:
          - CREDIT
          - DEBIT
    TransactionsModel:
      type: object
      required:
      - user_id
      - type
      - amount
      properties:
        id: 
          type: string
        user_id:
          type: string
        amount:
          type: integer
        type:
          type: string
          enum:
          - CREDIT
          - DEBIT
  securitySchemes:
    bearerAuth:            # arbitrary name for the security scheme
      type: http
      scheme: bearer
      bearerFormat: JWT
  responses:
    UnauthorizedError:
      description: Access token is missing or invalid    

Implement CI pipeline

Implement with docker or docker-compose for caching depedencies
The pipeline will

  • Build dependencies with docker
  • Run tests in transactions service
  • Run tests in user service

Implement user creation

Implement the db persistency of users entity

User must have the fields:

  • id
  • first_name
  • last_name
  • password
  • email

Beware that password must be stored encrypted

Implement route `GET /users`

Swagger definition

paths:
  # Users
  /users:
    get:
      tags:
        - Users
      security: 
        - bearerAuth: []
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/UsersResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.