Coder Social home page Coder Social logo

todo-list-api's Introduction

TODO-LIST API ๐Ÿ“

The functionality of this api is to create tasks and display a list of the created tasks.

How to install ๐Ÿ› 

git clone [email protected]:AraManjon/todo-list-api.git

cd api

npm i

How to use ๐Ÿ’ผ

To up server from the terminal

npm run dev

Visti localhost:5000 or use some interface to star use endpoints as a Postman

Other scripts:

To run test unit and acceptance

npm run test

Endpoints

To create a task and edit an existing task:

PUT /tasks/:id

Request:

    body: {
        "id": string,
        "name": strirng,
        "description": string
    }

Response:

201 CREATE 422 Unprocessable Entity


To get list of tasks:

GET /tasks

Response:

200 OK Content:

    [ 
        {
            "id": string,
            "name": strirng,
            "description": string
        },
        {
            "id": string,
            "name": strirng,
            "description": string
        }
    ]

Aims ๐Ÿ

  • Practice builds an application with typescript, Node and mongo, applying concepts of DDD Architecture.

  • Use diferents libraries that helps to build an application applying conceepts of clean code.

Project distribution ๐Ÿ—ƒ

src folder -> production project

test folder -> test ( not in production )

backend folder -> the external layer ( more near of client )

shared folder -> content likely to be shared by other domains

tasks folder -> domain folder

Aproach project solution OUTSIDE IN ๐Ÿšฆ

Following a TDD Outside In aproach, the fisrt step of project was:

1.- Create acceptance test:

  • library used -> cucumber

  • The test should be created with a similar use that has the client with the application.

  • The language used in this test should to consider the client language and proposits when use the application.

2.- Integration and unit test

  • In TDD outside in flow, this test could be in red while we implement internal logic. Once the llogic is implemented, this test should be pass to green.

  • library used -> jest

Other considerations ๐Ÿ”

SIDE EFFECT

When we have a method that return void, it are telling us that this method trigger an effect in other application point.

We need to consider and validatee this behaviour, may be we need to test the comunication beetween two entities. (integration test)

TEST REPOSITORY

When we have a method save, we need to validate that the item that we want to save is now in the db. To validate this, we have two options, validate only the call to save, and the response of this call is that we wait, by the otheer hand,other option can be implement another method, as find, to validate that this item now is in db, if this method we should need in the application, we can consider this option.

MOCK TEST REPOSITORY

We create a mock for repeosoitory to not subject the test of services to the repository implementation.

VALIDATE REQUEST PARAMS

Validation of the request parameters, to make sure that it is called with the parameters that we expect. Validate before reaching domain and that responsibility does not have the domain.

Ex: If we use the api to create a task and we don't send a mandatory param body, we need to validate this in controller.

  • library used -> express-validator

VALUE OBJECTS

To make the modeling richer

OBJECT MOTHER

In test, to generate the values needed in test randomly.

Remove noise from tests.

Remove fragility from our tests.

  • library used -> faker

CI ๐Ÿšจ

The project is builded with CI with github workflows.

// TO-DO
  • Eliminar tareas
  • Editar tareas

todo-list-api's People

Contributors

aramanjon avatar

Watchers

James Cloos avatar  avatar

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.