{"id":17651793,"url":"https://github.com/diegovictor/gofinances-api","last_synced_at":"2026-02-04T02:38:24.573Z","repository":{"id":39670788,"uuid":"271615248","full_name":"DiegoVictor/gofinances-api","owner":"DiegoVictor","description":"Project built during the Rocketseat Bootcamp #11","archived":false,"fork":false,"pushed_at":"2025-01-10T12:13:47.000Z","size":2614,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-05T08:42:43.985Z","etag":null,"topics":["api","coverage-report","database","editorconfig","eslint","gofinances","gostack","node","nodejs","postgres","prettier","rocketseat","ts","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DiegoVictor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-11T18:08:08.000Z","updated_at":"2025-01-10T12:13:51.000Z","dependencies_parsed_at":"2025-02-13T08:40:00.393Z","dependency_job_id":null,"html_url":"https://github.com/DiegoVictor/gofinances-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fgofinances-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fgofinances-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fgofinances-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fgofinances-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DiegoVictor","download_url":"https://codeload.github.com/DiegoVictor/gofinances-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247589835,"owners_count":20963022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","coverage-report","database","editorconfig","eslint","gofinances","gostack","node","nodejs","postgres","prettier","rocketseat","ts","typescript"],"created_at":"2024-10-23T11:43:41.183Z","updated_at":"2026-02-04T02:38:24.488Z","avatar_url":"https://github.com/DiegoVictor.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [API] GoFinances\n[![AppVeyor](https://img.shields.io/appveyor/build/diegovictor/gofinances-api?logo=appveyor\u0026style=flat-square)](https://ci.appveyor.com/project/DiegoVictor/gofinances-api)\n[![postgres](https://img.shields.io/badge/postgres-8.11.0-326690?style=flat-square\u0026logo=postgresql\u0026logoColor=white)](https://www.postgresql.org/)\n[![typescript](https://img.shields.io/badge/typescript-5.1.3-3178c6?style=flat-square\u0026logo=typescript)](https://www.typescriptlang.org/)\n[![eslint](https://img.shields.io/badge/eslint-8.43.0-4b32c3?style=flat-square\u0026logo=eslint)](https://eslint.org/)\n[![airbnb-style](https://flat.badgen.net/badge/style-guide/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)\n[![jest](https://img.shields.io/badge/jest-29.5.6-brightgreen?style=flat-square\u0026logo=jest)](https://jestjs.io/)\n[![coverage](https://img.shields.io/codecov/c/gh/DiegoVictor/gofinances-api?logo=codecov\u0026style=flat-square)](https://codecov.io/gh/DiegoVictor/gofinances-api)\n[![MIT License](https://img.shields.io/badge/license-MIT-green?style=flat-square)](https://raw.githubusercontent.com/DiegoVictor/gofinances-api/main/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\u003cbr\u003e\n[![Run in Insomnia}](https://insomnia.rest/images/run.svg)](https://insomnia.rest/run/?uri=https%3A%2F%2Fraw.githubusercontent.com%2FDiegoVictor%2Fgofinances-api%2Fmain%2FInsomnia_2024-11-27.json\u0026label=GoFinances)\n\nResponsible for provide data to the [`web`](https://github.com/DiegoVictor/gofinances-web) front-end. Allow users to register income and outcome transactions.\n\n## Table of Contents\n* [Installing](#installing)\n  * [Configuring](#configuring)\n    * [.env](#env)\n    * [Postgres](#postgres)\n      * [Migrations](#migrations)\n* [Usage](#usage)\n  * [Error Handling](#error-handling)\n    * [Errors Reference](#errors-reference)\n  * [X-Total-Count](#x-total-count)\n  * [Versioning](#versioning)\n  * [Routes](#routes)\n    * [Requests](#requests)\n* [Running the tests](#running-the-tests)\n  * [Coverage report](#coverage-report)\n\n# Installing\nEasy peasy lemon squeezy:\n```\n$ yarn\n```\nOr:\n```\n$ npm install\n```\n\u003e Was installed and configured the [`eslint`](https://eslint.org/) and [`prettier`](https://prettier.io/) to keep the code clean and patterned.\n\n## Configuring\nThe application use just one database: [Postgres](https://www.postgresql.org/).  For the fastest setup is recommended to use [docker-compose](https://docs.docker.com/compose/), you just need to up all services:\n```\n$ docker-compose up -d\n```\n\n### .env\nIn this file you may configure your Postgres database connection, the environment, app's port and a url to documentation (this will be returned with error responses, see [error section](#error-handling)). Rename the `.env.example` in the root directory to `.env` then just update with your settings.\n\n|key|description|default\n|---|---|---\n|APP_PORT|Port number where the app will run.|`3333`\n|NODE_ENV|App environment. The typeORM's database choice rely on this key value, so if the environment is `test` the database used will be `tests` otherwise the `POSTGRES_DATABASE` will set the database name.|`development`\n|POSTGRES_HOST|Postgres host.|`pg`\n|POSTGRES_PORT|Postgres port.|`5432`\n|POSTGRES_USER|Postgres user.| `postgres`\n|POSTGRES_PASSWORD|Postgres password.| -\n|POSTGRES_DATABASE|Application's database name.| gofinances\n|DOCS_URL|An url to docs where users can find more information about the app's internal code errors.|`https://github.com/DiegoVictor/gofinances-api#errors-reference`\n\n### Postgres\nResponsible to store all application data. If for any reason you would like to create a Postgres container instead of use `docker-compose`, you can do it by running the following command:\n```\n$ docker run --name gofinances-postgres -e POSTGRES_PASSWORD=docker -p 5432:5432 -d postgres\n```\n\u003e Then create two databases: `gofinances` and `tests` (in case you would like to run the tests).\n\n#### Migrations\nRemember to run the database migrations:\n```\n$ yarn ts-node-dev ./node_modules/typeorm/cli.js migration:run\n```\nOr:\n```\n$ yarn typeorm migration:run\n```\n\u003e See more information on [TypeORM Migrations](https://typeorm.io/#/migrations).\n\n# Usage\nTo start up the app run:\n```\n$ yarn dev:server\n```\nOr:\n```\nnpm run dev:server\n```\n\n## Error Handling\nInstead of only throw a simple message and HTTP Status Code this API return friendly errors:\n```json\n{\n  \"status\": \"error\",\n  \"message\": \"Transaction not found\",\n  \"code\": 144,\n  \"docs\": \"https://github.com/DiegoVictor/gofinances-api#errors-reference\"\n}\n```\n\u003e As you can see a url to error docs are returned too. To configure this url update the `DOCS_URL` key from `.env` file.\n\u003e In the next sub section ([Errors Reference](#errors-reference)) you can see the errors `code` description.\n\n### Errors Reference\n|code|message|description\n|---|---|---\n|140|Missing file|Was not provided a file to import transactions.\n|141|You don't have enough money to this transaction!|The said amount is greater than the available.\n|144|Transaction not found|The `id` sent not references an existing transaction in the database.\n\n## X-Total-Count\nAnother header returned in routes with pagination, this bring the total records amount.\n\n## Versioning\nA simple versioning was made. Just remember to set after the `host` the `/v1/` string to your requests.\n```\nGET http://localhost:3333/v1/transactions\n```\n\n## Routes\n|route|HTTP Method|params|description\n|:---|:---:|:---:|:---:\n|`/transactions`|GET| - |Return transactions and balance.\n|`/transactions`|POST|Body with transaction `title`, `value`, `type` and `category`.|Create a new transaction.\n|`/transactions/:id`|DELETE|`:id` of the transaction.|Remove a transaction.\n|`/transactions/import`|POST|Multipart payload with a `file` field with a `csv` file.|Import transactions from file.\n\n### Requests\n* `POST /transactions`\n\nRequest body:\n```json\n{\n  \"title\": \"Internet\",\n  \"value\": 120,\n  \"type\": \"outcome\",\n  \"category\": \"Others\"\n}\n```\n\n* `POST /transactions/import`\n\nCSV file, example:\n```\ntitle, type, value, category\nLoan, income, 1500, Others\nWebsite Hosting, outcome, 50, Others\nIce cream, outcome, 3, Food\n```\n\n# Running the tests\n[Jest](https://jestjs.io/) was the choice to test the app, to run:\n```\n$ yarn test\n```\nOr:\n```\n$ npm run test\n```\n\u003e For tests run create a database called `tests`.\n\n## Coverage report\nYou can see the coverage report inside `tests/coverage`. They are automatically created after the tests run.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegovictor%2Fgofinances-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiegovictor%2Fgofinances-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegovictor%2Fgofinances-api/lists"}