A Rest API for personal finance management, that allows users to track their expenses and incomes in a simple and secure way. With Dindin, users can have an overview of their financial situation, set goals and plan for the future. This project, part of a challenge proposed by Cubos Academy.
Follow these instructions to run the project in your local environment.
- You'll need Git and Node.js installed on your computer to build this app.
- Use Insomnia or Postman to perform the API requests.
- Additionally, having an editor like VSCode for coding is quite advantageous.
# Clone the project and access the folder
$ git clone https://github.com/hamomgs/dindin.git
$ cd dindin
# Install the dependencies
$ npm install
# Make a copy of file '.env.example' to '.env'
$ cp .env.example .env
# Acess the .env
$ code .env
# Fill it with your port, database and jwt config.
PORT=3000
# JWT Config
JWT_PASS=YourPassword
# Database Config
DB_HOST=YourDbHost
DB_PORT=YourDbPort
DB_USER=YourDbUser
DB_PASS=YourDbPassword
DB_NAME=YourDbName
Run the application in development mode.
$ npm run dev
# The application will be accessible on port:3000 by default via http://localhost:3000.
Import on Insomnia or Postman the request collection.
http://localhost:3000/
Create user | POST /usuario
Param | Type | Origin | Description |
---|---|---|---|
nome |
string |
Body | Required. User name. |
email |
string |
Body | Required. User email. |
senha |
string |
Body | Required. User password. |
// Example Response
// HTTP Status 201
{
"id": 1,
"nome": "JosΓ©",
"email": "jose@email.com"
}
User login | POST /login
Param | Type | Origin | Description |
---|---|---|---|
email |
string |
Body | Required. User email. |
senha |
string |
Body | Required. User password. |
// Example Response
// HTTP Status 200
{
"usuario": {
"id": 1,
"nome": "JosΓ©",
"email": "jose@email.com"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwiaWF0IjoxNjIzMjQ5NjIxLCJleHAiOjE2MjMyNzg0MjF9.KLR9t7m_JQJfpuRv9_8H2-XJ92TSjKhGPxJXVfX6wBI"
}
Get logged user details | GET /usuario
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
// Example Response
// HTTP Status 200
{
"id": 1,
"nome": "JosΓ©",
"email": "jose@email.com"
}
Edit user profile | PUT /usuario
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
nome |
string |
Body | Required. User name. |
email |
string |
Body | Required. User email. |
senha |
string |
Body | Required. User password. |
// Example Response
// HTTP Status 204
// No body response.
List all categories | GET /categoria
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
// Example Response
// HTTP Status 200
[
{
"id": 1,
"descricao": "Roupas"
},
{
"id": 2,
"descricao": "Mercado"
}
]
List all transactions | GET /transacao
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
// Example Response
// HTTP Status 200
[
{
"id": 1,
"tipo": "saida",
"descricao": "Sapato amarelo",
"valor": 15800,
"data": "2023-03-23T15:35:00.000Z",
"usuario_id": 5,
"categoria_id": 4,
"categoria_nome": "Roupas"
},
{
"id": 3,
"tipo": "entrada",
"descricao": "SalΓ‘rio",
"valor": 300000,
"data": "2023-03-24T15:30:00.000Z",
"usuario_id": 5,
"categoria_id": 6,
"categoria_nome": "SalΓ‘rios"
}
]
List all filtered transactions | GET /transacao?filtro[]=categoria1&filtro[]=categoria2
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
filtro[] |
array |
Query | Optional. Category name. |
// Example Response | GET /transacao?filtro[]=roupas&filtro[]=salΓ‘rios
// HTTP Status 200
[
{
"id": 1,
"tipo": "saida",
"descricao": "Sapato amarelo",
"valor": 15800,
"data": "2022-03-23T15:35:00.000Z",
"usuario_id": 5,
"categoria_id": 4,
"categoria_nome": "Roupas"
},
{
"id": 3,
"tipo": "entrada",
"descricao": "SalΓ‘rio",
"valor": 300000,
"data": "2022-03-24T15:30:00.000Z",
"usuario_id": 5,
"categoria_id": 6,
"categoria_nome": "SalΓ‘rios"
}
]
Get transaction details by id | GET /transacao/:id
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
id |
number |
Parameter | Required. Transaction id. |
// Example Response
// HTTP Status 200
{
"id": 3,
"tipo": "entrada",
"descricao": "SalΓ‘rio",
"valor": 300000,
"data": "2022-03-24T15:30:00.000Z",
"usuario_id": 5,
"categoria_id": 6,
"categoria_nome": "SalΓ‘rios"
}
Create transaction | POST /transacao
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
tipo |
string |
Body | Required. Transaction type. entrada or saida . |
descricao |
string |
Body | Required. Transaction description. |
valor |
number |
Body | Required. Transaction value. |
data |
timestamp |
Body | Required. Transaction date. |
categoria_id |
number |
Body | Required. Category id. |
// Example Response
// HTTP Status 204
{
"id": 3,
"tipo": "entrada",
"descricao": "SalΓ‘rio",
"valor": 300000,
"data": "2022-03-24T15:30:00.000Z",
"usuario_id": 5,
"categoria_id": 6,
"categoria_nome": "SalΓ‘rios"
}
Edit specific transacion | PUT /transacao/:id
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
id |
string |
Parameter | Required. Transaction id. |
tipo |
string |
Body | Required. Transaction type. entrada or saida . |
descricao |
string |
Body | Required. Transaction description. |
valor |
number |
Body | Required. Transaction value. |
data |
timestamp |
Body | Required. Transaction date. |
categoria_id |
number |
Body | Required. Category id. |
// Example Response
// HTTP Status 204
// No body response.
Remove transaction | DELETE /transacao/:id
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
id |
string |
Parameter | Required. Transaction id. |
// Example Response
// HTTP Status 204
// No body response.
Get transaction statement | GET /transacao/extrato
Param | Type | Origin | Description |
---|---|---|---|
token |
Beater |
Authentication | Required. Token returned to the user after logging in. |
// Example Response
// HTTP Status 200
{
"entrada": 300000,
"saida": 15800
}
dindin/
βββ node_modules
βββ sql
β βββ schema
β β βββ 1.sql
β βββ db-schema-diagram.png
βββ src
β βββ controllers
β β βββ categoryController.js
β β βββ transactionController.js
β β βββ userController.js
β βββ middlewares
β β βββ userAuth.js
β βββ routes
β β βββ categoryRouter.js
β β βββ index.js
β β βββ loginRouter.js
β β βββ transactionRouter.js
β β βββ userRouter.js
β βββ services
β β βββ database.js
β β βββ jwt.js
β βββ validations
β β βββ index.js
β βββ index.js
βββ .env
βββ .eslintrc.json
βββ .gitignore
βββ .prettierrc
βββ LICENCE
βββ package-lock.json
βββ package.json
βββ README.md
Tech | Version |
---|---|
Node.js | 4.18.2 |
Express.js | 4.18.2 |
Nodemon | 3.0.1 |
Pg | 8.11.3 |
Dotenv | 16.3.1 |
Json Web Token | 9.0.2 |
Bcrypt | 5.1.1 |
Eslint | 8.49.0 |
Prettier | 3.0.3 |
This project is under the license MIT.
Gabriel ApolinΓ‘rio π¨βπ» |
Hamom Silva π¨βπ» |