GithubHelp home page GithubHelp logo

fintonic-code-challenge's Introduction

fintonic-code-challenge

Instrucciones


Prueba técnica:

Crear una api con Node.js que permita insertar, listar y eliminar productos.

Cada producto tiene:

  • identificador único
  • nombre(obligatorio)
  • descripción

Almacenar los datos en una base de datos mongodb

Extra: la acción de insertar y eliminar sólo se debería de poder hacer de manera autenticada(aplicando algún tipo de seguridad)

El entregable debe ser una url a un repositorio de github/gitlab/bitbucket

Se valorará:

  • Simplicidad de la solución: se intenta que se dedique a la prueba unas 3 horas como máximo. Se pueden aportar TODOs en un README para indicar que cosas se añadirían y como.
  • Ceñirse a lo requerido en el enunciado
  • Que la prueba sea coherente con las respuestas aportadas al cuestionario inicial

Autenticación


El usuario debe autenticarse utilizando Json Web Tokens. Esto se logra agregando el header tipo 'authorization' a cualquier request hecho a este API con el formato 'Bearer '. El token es obtenido cuando el usuario inicia sesión.

Rutas


POST /auth/login

Necesita Authenticación: No

Entrada:

{
  "email": "[email protected]",
  "password": "userpassword"
}

Salida:

{
  "user": {
    "email": "[email protected]",
    "updatedAt": "2019-04-15T14:39:52.960Z",
    "createdAt": "2019-04-15T14:39:52.960Z"
  },
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1Y2I0OTdiODNjZjg5ZDJkN2ExZTEwNGQiLCJpYXQiOjE1NTUzNDAzMjZ9.YtGf9yKJTsvo1ka5nJeT_t17Xig_k6v2cg40pPF6Qd4"
}

GET /auth/verify

Necesita Authenticación: Si

Salida:

{
  "user": {
    "email": "[email protected]",
    "updatedAt": "2019-04-15T14:39:52.960Z",
    "createdAt": "2019-04-15T14:39:52.960Z"
  },
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1Y2I0OTdiODNjZjg5ZDJkN2ExZTEwNGQiLCJpYXQiOjE1NTUzNDAzNTB9.KbMrR66OtuxtlqDKThkd3WeCV2oejGVMyFCZO-yoU0M"
}

GET /users/

Necesita Authenticación: No

Salida:

[
  {
    "email": "[email protected]",
    "updatedAt": "2019-04-15T14:06:34.460Z",
    "createdAt": "2019-04-15T14:06:34.460Z"
  },
  {
    "email": "[email protected]",
    "updatedAt": "2019-04-15T14:39:52.960Z",
    "createdAt": "2019-04-15T14:39:52.960Z"
  }
]

POST /users/

Necesita Authenticación: No

Entrada:

{
  "email": "[email protected]",
  "password": "userpassword"
}

Salida:

{
  "email": "[email protected]",
  "updatedAt": "2019-04-15T15:00:41.798Z",
  "createdAt": "2019-04-15T15:00:41.798Z"
}

GET /users/:id

Necesita Authenticación: No

Salida:

{
  "email": "[email protected]",
  "updatedAt": "2019-04-15T15:00:41.798Z",
  "createdAt": "2019-04-15T15:00:41.798Z"
}

PUT /users/:id

Necesita Authenticación: Si

Entrada:

{
  "email": "[email protected]"
}

Salida:

{
  "email": "[email protected]",
  "updatedAt": "2019-04-15T15:00:41.798Z",
  "createdAt": "2019-04-15T15:00:41.798Z"
}

DELETE /users/:id

Necesita Authenticación: Si

Salida:

{
  "email": "[email protected]",
  "updatedAt": "2019-04-15T15:00:41.798Z",
  "createdAt": "2019-04-15T15:00:41.798Z"
}

GET /products/

Necesita Authenticación: No

Salida:

[
  {
    "_id": "5cb49db8f02c753a570c2c92",
    "name": "Pera",
    "description": "Una fruta",
    "createdAt": "2019-04-15T15:05:28.266Z",
    "updatedAt": "2019-04-15T15:05:28.266Z",
    "__v": 0
  }
]

POST /products/

Necesita Authenticación: Si

Entrada:

{
  "name": "Pera",
  "description": "Una fruta"
}

Salida:

{
  "_id": "5cb49db8f02c753a570c2c92",
  "name": "Pera",
  "description": "Una fruta",
  "createdAt": "2019-04-15T15:05:28.266Z",
  "updatedAt": "2019-04-15T15:05:28.266Z",
  "__v": 0
}

GET /products/:id

Necesita Authenticación: No

Salida:

{
  "_id": "5cb49db8f02c753a570c2c92",
  "name": "Pera",
  "description": "Una fruta",
  "createdAt": "2019-04-15T15:05:28.266Z",
  "updatedAt": "2019-04-15T15:05:28.266Z",
  "__v": 0
}

PUT /products/:id

Necesita Authenticación: Si

Entrada:

{
  "name": "Manzana"
}

Salida:

{
  "_id": "5cb49db8f02c753a570c2c92",
  "name": "Manzana",
  "description": "Una fruta",
  "createdAt": "2019-04-15T15:05:28.266Z",
  "updatedAt": "2019-04-15T15:05:28.266Z",
  "__v": 0
}

DELETE /products/:id

Necesita Authenticación: Si

Salida:

{
  "_id": "5cb49db8f02c753a570c2c92",
  "name": "Pera",
  "description": "Una fruta",
  "createdAt": "2019-04-15T15:05:28.266Z",
  "updatedAt": "2019-04-15T15:05:28.266Z",
  "__v": 0
}

Librerias utilizadas


Las librerias @sugo fueron desarrolladas por mi, se puede encontrar el código fuente aqui:

Se utlizó mongoose para conectarse a la base de datos MongoDB. Se decidió utilizar mongoose ya que cuenta con capacidades para hacer validacion de modelos facilmente sin perder la flexibilidad de MongoDB.

Se utilizó jsonwebtoken para implementar la autenticación.

Iniciar Api

Con variables de entorno del archivo .env

npm run start-dev

Con variables de entorno del sistema

npm start

Con Dockercompose

docker-compose up

fintonic-code-challenge's People

Watchers

 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.