Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions .insomnia.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"settingRebuildPath": true,
"settingSendCookies": true,
"settingStoreCookies": true,
"url": "https://www.tesourodireto.com.br/json/br/com/b3/tesourodireto/service/api/treasurybondsinfo.json",
"url": "https://www.tesourodireto.com.br/json/br/com/b3/tesourodireto/service/api/treasurybondinfo.json",
"_type": "request"
},
{
Expand Down Expand Up @@ -90,7 +90,7 @@
"metaSortKey": -1598209090094,
"method": "PUT",
"modified": 1598212311229,
"name": "Update all treasury bonds",
"name": "Update all treasury bond",
"parameters": [],
"parentId": "fld_2a24df81d4fc40299c24389a4fedc93b",
"settingDisableRenderRequestBody": false,
Expand All @@ -99,7 +99,7 @@
"settingRebuildPath": true,
"settingSendCookies": true,
"settingStoreCookies": true,
"url": "{{baseURL}}/treasurybonds/updateAll",
"url": "{{baseURL}}/treasurybond/updateAll",
"_type": "request"
},
{
Expand All @@ -110,7 +110,7 @@
"environmentPropertyOrder": null,
"metaSortKey": -1598048831768,
"modified": 1598048831768,
"name": "TreasuryBonds",
"name": "TreasuryBond",
"parentId": "wrk_37eef8ddc0034da5a3331d14411851a0",
"_type": "request_group"
},
Expand All @@ -134,7 +134,7 @@
"settingRebuildPath": true,
"settingSendCookies": true,
"settingStoreCookies": true,
"url": "{{baseURL}}/treasurybonds",
"url": "{{baseURL}}/treasurybond",
"_type": "request"
},
{
Expand Down Expand Up @@ -166,7 +166,7 @@
"settingRebuildPath": true,
"settingSendCookies": true,
"settingStoreCookies": true,
"url": "{{baseURL}}/treasurybonds",
"url": "{{baseURL}}/treasurybond",
"_type": "request"
},
{
Expand All @@ -180,7 +180,7 @@
"metaSortKey": -1598048869452,
"method": "GET",
"modified": 1598199043855,
"name": "List Treasury bonds",
"name": "List Treasury bond",
"parameters": [],
"parentId": "fld_2a24df81d4fc40299c24389a4fedc93b",
"settingDisableRenderRequestBody": false,
Expand All @@ -189,12 +189,15 @@
"settingRebuildPath": true,
"settingSendCookies": true,
"settingStoreCookies": true,
"url": "{{baseURL}}/treasurybonds",
"url": "{{baseURL}}/treasurybond",
"_type": "request"
},
{
"_id": "req_fe9dd271bc4d433d92927f3e0297df15",
"authentication": { "token": "", "type": "bearer" },
"authentication": {
"token": "",
"type": "bearer"
},
"body": {
"mimeType": "application/json",
"text": "{\n\t\"email\": \"[email protected]\",\n\t\"password\": \"12345678\"\n}"
Expand Down Expand Up @@ -609,8 +612,14 @@
"_id": "env_30b2fa03c7c14c6193209f0a7ed69b3f",
"color": "#00aa60",
"created": 1597617822940,
"data": { "baseURL": "http://localhost:3333" },
"dataPropertyOrder": { "&": ["baseURL"] },
"data": {
"baseURL": "http://localhost:3333"
},
"dataPropertyOrder": {
"&": [
"baseURL"
]
},
"isPrivate": false,
"metaSortKey": 1597617822940,
"modified": 1597617915367,
Expand Down
41 changes: 0 additions & 41 deletions .pre-commit-config.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ A web application that notifies you about Brazilian treasury bond rates.

# 💻 Project

AlertaDoTesouro is a project elaborated with the intent of automatically monitoring Brazilian government bonds and alerting users about them according to their preferences of rates. Tools such as Node.js, Express, PostgreSQL, Docker, Redis, linting and debugging tools, mail delivery systems, among others, were employed to build this system.
AlertaDoTesouro is a project elaborated with the intent of automatically monitoring Brazilian government bond and alerting users about them according to their preferences of rates. Tools such as Node.js, Express, PostgreSQL, Docker, Redis, linting and debugging tools, mail delivery systems, among others, were employed to build this system.
Furthermore, this project was also presented as required academic work for the Integrated Project classes during the 2022/1 semester.

The application allows users to set one value per treasury bond, so they can get notified whenever its rate goes above or below that value. Users should be able to be* notified by email or browser notifications.
Expand Down Expand Up @@ -76,9 +76,9 @@ All files related exlusively to the back-end server are located in `/server`.

The back-end REST API is fully functional and was made with Express. Multiple endpoints have been defined and they can be explored extensively by referring to the `.insomnia.json` file, which can be imported into [Insomnia](https://insomnia.rest/) itself or possibly other REST clients.

#### Example: listing treasury bonds
#### Example: listing treasury bond

A typical request would be a simple `GET` request to the `/treasurybonds` endpoint. Response example:
A typical request would be a simple `GET` request to the `/treasurybond` endpoint. Response example:

```bash
[
Expand Down
33 changes: 22 additions & 11 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ services:
- dev
env_file: web/.env
environment:
- NODE_ENV=development
- BACKEND_BASE_URL=http://server-dev:3333
- REACT_APP_BASE_URL=http://server-dev:3000
NODE_ENV: development
BACKEND_BASE_URL: http://server-dev:3333
REACT_APP_BASE_URL: http://server-dev:3000
restart: on-failure
networks:
- backend
Expand Down Expand Up @@ -38,11 +38,12 @@ services:
- dev
depends_on:
- postgres
- postgres_test
- redis
env_file: server/.env
environment:
- NODE_ENV=development
- PORT=3333
NODE_ENV: development
PORT: 3333
restart: on-failure
ports:
- '${PORT:-3333}:3333'
Expand All @@ -52,7 +53,7 @@ services:
- ./server:/app
- ./.prettierrc.yaml:/.prettierrc.yaml
working_dir: /app
command: sh -c 'yarn install && yarn typeorm migration:run && (yarn dev:queue & yarn dev:server)'
command: sh -c 'yarn install && yarn typeorm migration:run && yarn typeorm migration:run --connection test && echo "##MIGATIONS RAN ON TEST DB##" || echo "##MIGATIONS FAILED TO RUN ON TEST DB. If you want to deploy the test database, pass the `--profile test` flag##" ; (yarn dev:queue & yarn dev:server)'

# server:
# image: node:lts-alpine
Expand All @@ -61,7 +62,7 @@ services:
# env_file: server/.env
# environment:
# - NODE_ENV=production
# # Treasury bonds database
# # Treasury bond database
# - DB_TYPE=postgres
# - DB_HOST=postgres
# - DB_PORT=5432
Expand All @@ -75,7 +76,7 @@ services:
# - JWT_SECRET=${JWT_SECRET} # Change to required without breaking dev build
# # - JWT_SECRET=${JWT_SECRET?}
# - JWT_EXPIRES_IN="1d"
# # Cron schedule for update-all-treasury-bonds task
# # Cron schedule for update-all-treasury-bond task
# - UPDATE_CRON=${UPDATE_CRON:-"*/2 * * * *"}
# # Cron schedule for check-all-notifications task
# - NOTIFICATIONS_CRON=${SEVER_NOTIFICATIONS_CRON:-"*/2 * * * *"}
Expand All @@ -102,15 +103,24 @@ services:

postgres:
image: postgres:alpine
environment:
POSTGRES_USER: alertadotesouro
POSTGRES_PASSWORD: your_postgres_password
env_file: server/.env
networks:
- backend
volumes:
- db-data:/var/lib/postgresql/data
restart: unless-stopped

postgres_test:
image: postgres:alpine
profiles:
- test
env_file: server/.env.test
networks:
- backend
volumes:
- db-data-test:/var/lib/postgresql/data
restart: unless-stopped

redis:
image: redis:alpine
networks:
Expand All @@ -122,3 +132,4 @@ networks:

volumes:
db-data:
db-data-test:
11 changes: 5 additions & 6 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Treasury bonds database
DB_TYPE=postgres
# Treasury bond database
DB_HOST=postgres
DB_PORT=5432
DB_USERNAME=alertadotesouro
DB_PASSWORD=your_postgres_password
DB_DATABASE=alertadotesouro
POSTGRES_USER=alertadotesouro
POSTGRES_PASSWORD=your_postgres_password
POSTGRES_DB=alertadotesouro

# JWT secret for password hashing
JWT_SECRET=secret_passphrase
Expand All @@ -14,7 +13,7 @@ JWT_EXPIRES_IN="1d"
# Port to run the server on
PORT=3333

# Cron schedule for update-all-treasury-bonds task
# Cron schedule for update-all-treasury-bond task
UPDATE_CRON="*/15 * * * *"
# Cron schedule for check-all-notifications task
NOTIFICATIONS_CRON="*/15 * * * *"
Expand Down
6 changes: 6 additions & 0 deletions server/.env.test.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Tests database. Other variables are set to the same values as the production database.
DB_HOST=postgres_test
DB_PORTT=5432
POSTGRES_USER=alertadotesouro_test
POSTGRES_PASSWORD=your_postgres_password
POSTGRES_DB=alertadotesouro
77 changes: 77 additions & 0 deletions server/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
module.exports = {
root: true,
env: {
es2020: true,
node: true,
"jest/globals": true,
},
extends: [
"airbnb-base",
"plugin:import/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:jest/recommended",
"plugin:jest/style",
"plugin:prettier/recommended" // This comes last
],
parserOptions: {
project: require("path").join(__dirname, 'tsconfig.json')
},
plugins: [
"prettier",
"@typescript-eslint",
"jest",
],
settings: {
"import/resolver": {
typescript: {}
}
},
rules: {
"no-underscore-dangle": "off",
"class-methods-use-this": "off",
"camelcase": "off",
"prettier/prettier": "error",
"no-unused-vars": "off",
"no-console": "off",
"jest/no-disabled-tests": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{

varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
ignoreRestSiblings: true
}
],
"@typescript-eslint/naming-convention": [
"error",
{
format: [
"camelCase",
"PascalCase",
"UPPER_CASE"],
selector: "default",
leadingUnderscore: "allow"
}
],
"import/no-extraneous-dependencies":
["error", {
devDependencies: [
"**/*.test.js",
"**/*.test.ts",
"**/*.spec.js",
"**/*.spec.ts",
]
}],
"import/extensions":
[
"error",
"ignorePackages",
{
ts: "never",
}
],
}
}
36 changes: 0 additions & 36 deletions server/.eslintrc.yaml

This file was deleted.

Loading