Code Monkey home page Code Monkey logo

challenge_backend-05_gostack-v2's Introduction

Rocket

Challenge 05: Databases and upload files with NodeJS

NodeJS

language version language version GitHub language count GitHub top language GitHub repo size in bytes

This project be a part of bootcamp: GoStack by RocketSeat

Links:

                 

💡 About Challenge:

In this challenge, new features and improvements were implemented in the previous project:

  • Database integration;
  • TypeOrm to creation and management of tables in the database;
  • Upload csv files;
  • New routes to delete transactions, and create new transactions to CSV files;

📐 Architecture:

In this project, the concept of dividing the project structure was improved, which removes all responsibility for route files, such as business rules and data validation. A structure with models, repositories and services was used to divide the tasks. New folders have been created to separate the error class and configs.

Folder's structure:

estrutura

🔥 Functionalities:

  • POST /transactions: This route receive title, value and type in the request body, being the type of transaction, which must be "income" for incoming (deposits) and "outcome" for outgoing (withdrawal). When registering a new transaction, it must be stored inside an object with the format as follows:
{
  "id": "uuid",
  "title": "Salário",
  "value": 3000,
  "type": "income"
}

When registering a new transaction, it must be stored within the database, having the fields id, title, value, type, category_id, created_at, updated_at. Before creating a new category, a check is made to see if a category with the same title already exists. If it exists, the id that already exists in the database is used.

  • GET /transactions: This route should return a list of all the transactions you have registered so far, together with the sum of the entries, withdrawals and total credit. This route must return an object with the following format:
{
  "transactions": [
    {
      "id": "uuid",
      "title": "Salário",
      "value": 4000,
      "type": "income",
      "category": {
        "id": "uuid",
        "title": "Salary",
        "created_at": "2020-04-20T00:00:49.620Z",
        "updated_at": "2020-04-20T00:00:49.620Z",
      },
      "created_at": "2020-04-20T00:00:49.620Z",
      "updated_at": "2020-04-20T00:00:49.620Z",
    },
    {
      "id": "uuid",
      "title": "Freela",
      "value": 2000,
      "type": "income",
      "category": {
        "id": "uuid",
        "title": "Others",
        "created_at": "2020-04-20T00:00:49.620Z",
        "updated_at": "2020-04-20T00:00:49.620Z",
      },
      "created_at": "2020-04-20T00:00:49.620Z",
      "updated_at": "2020-04-20T00:00:49.620Z",
    },
    {
      "id": "uuid",
      "title": "Pagamento da fatura",
      "value": 4000,
      "type": "outcome",
      "category": {
        "id": "uuid",
        "title": "Others",
        "created_at": "2020-04-20T00:00:49.620Z",
        "updated_at": "2020-04-20T00:00:49.620Z",
      },
      "created_at": "2020-04-20T00:00:49.620Z",
      "updated_at": "2020-04-20T00:00:49.620Z",
    },
    {
      "id": "uuid",
      "title": "Cadeira Gamer",
      "value": 1200,
      "type": "outcome",
      "category": {
        "id": "uuid",
        "title": "Recreation",
        "created_at": "2020-04-20T00:00:49.620Z",
        "updated_at": "2020-04-20T00:00:49.620Z",
      },
      "created_at": "2020-04-20T00:00:49.620Z",
      "updated_at": "2020-04-20T00:00:49.620Z",
    }
  ],
  "balance": {
    "income": 6000,
    "outcome": 5200,
    "total": 800
  }
}
  • DELETE /transactions/:id: This route must delete a transaction with the id present in the route params;

  • POST /transactions/import: The route should allow the import of a file in .csv format that contains the same information needed to create a transaction, id, title, value, type, category_id, created_at, updated_at, in which each line of the CSV file must be a new record for the database and finally return all transactions that have been imported into the database;

⚙️ Techs:

  • NodeJS;
  • Docker;
  • TypeORM
  • EsLint;
  • Prettier;
  • Express;
  • Nodemon;
  • Yarn;
  • Jest;

⛏ Tools:

🏁 Run this project:

To run on the first time, into your folder:

$ git clone https://github.com/Fred-Reis/challenge_backEnd-05_GoStack-v2

Into repo folder, to install Node_Modules run:

yarn

And to start the server:

yarn dev:server

Recommend using Insomnia to test routes and DBeaver to manager your databases.

😃 Now run this project and... BE HAPPY.

😍 Thanks for you interest!


"Stay hungry stay foolish!"



Author: Frederico Reis

challenge_backend-05_gostack-v2's People

Contributors

fred-reis avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

yuriduartedev

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.