Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create API #5

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Tpessia
33 changes: 33 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# https://github.com/apps/settings

repository:
default_branch: main
name: dados-financeiros
description: Repositório de Fontes de Dados Financeiros
topics: finance, stock-market, market-data, brasil, financial-data
homepage: https://InvestTester.com/api
private: false
has_issues: true
has_wiki: false
has_projects: false
has_downloads: true
delete_branch_on_merge: true
allow_squash_merge: true
allow_merge_commit: false
allow_rebase_merge: false

branches:
- name: main
protection:
enforce_admins: false
allow_force_pushes: true
required_linear_history: true
restrictions: null
allow_deletions: false
required_pull_request_reviews:
dismiss_stale_reviews: true
require_code_owner_reviews: true
required_approving_review_count: 1
required_status_checks:
strict: true
contexts: [ 'test' ]
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test

on:
workflow_dispatch: {}
pull_request:
branches: [ 'main' ]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.12.2'
- name: Test
shell: bash
run: |
cd api
npm install
npm run build
npm run test
16 changes: 16 additions & 0 deletions api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Node.js .dockerignore

**/dist
**/logs
**/*.log
**/node_modules/
**/npm-debug.log
**/.git
**/.vscode
**/.gitignore
**/.dockerignore
**/README.md
**/LICENSE
**/.editorconfig
**/Dockerfile
**/docker-compose.yml
3 changes: 3 additions & 0 deletions api/.env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NODE_ENV=dev
PORT=3000
TZ=UTC
3 changes: 3 additions & 0 deletions api/.env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NODE_ENV=prod
PORT=3000
TZ=UTC
3 changes: 3 additions & 0 deletions api/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NODE_ENV=test
PORT=3000
TZ=UTC
25 changes: 25 additions & 0 deletions api/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
56 changes: 56 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
# .env
# .env.development.local
# .env.test.local
# .env.production.local
# .env.local

# temp directory
.temp
.tmp

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
4 changes: 4 additions & 0 deletions api/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
10 changes: 10 additions & 0 deletions api/.semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
- id: hardcoded-api-key
pattern-either:
- pattern-regex: '(?i)\b(api[\._-]?)?(key|token|secret|password|pass|passwd|pswd|auth|credentials)[=:][0-9a-zA-Z+/=]{6,64}\b'
- pattern-regex: '(?i)\b[0-9a-zA-Z]{30,}\b'
message: "Potential API key or token detected"
languages: [generic]
severity: ERROR
metadata:
category: security
23 changes: 23 additions & 0 deletions api/.semgrepignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Common large paths
node_modules/
build/
dist/
vendor/
.env/
.venv/
.tox/
*.min.js
.npm/
.yarn/
package-lock.json

# Common test paths
test/
tests/
*_test.go

# Semgrep rules folder
.semgrep*

# Semgrep-action log folder
.semgrep_logs/
49 changes: 49 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Build

FROM node:20.12.2-bullseye AS build

ARG NODE_OPTIONS

WORKDIR /app

COPY package*.json .
RUN npm install

COPY . .
RUN ls -la .

RUN npm run build

# Run

FROM node:20.12.2-bullseye AS run

ARG ENV=dev
ENV NODE_ENV=${ENV}
ARG NODE_OPTIONS
ENV NODE_OPTIONS=${NODE_OPTIONS}

WORKDIR /app

RUN apt-get update
RUN apt-get install -y net-tools nano
RUN rm -rf /var/lib/apt/lists/*

RUN groupadd -r appuser
RUN useradd -r -g appuser -m -d /app -s /bin/bash --uid 2000 appuser

COPY package*.json .
RUN npm install --omit=dev

COPY --from=build /app/dist /app/dist
COPY .env.${ENV} .

RUN chown -R appuser:appuser /app

RUN ls -la .

USER appuser

EXPOSE 3000

CMD ["npm", "run", "start:prod"]
21 changes: 21 additions & 0 deletions api/LISENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Tpessia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Financial Data API

API that centralizes financial data, focusing on the data available in the [financial data repository](https://github.com/Tpessia/dados-financeiros).

## Features

- Financial data search by asset codes.
- Support for different types of assets, including interest rates, inflation indices, stocks, and currencies.
- Data conversion and leveraging as specified in the asset codes.

## Docker

```
npm run docker:build
npm run docker:run
```
8 changes: 8 additions & 0 deletions api/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
Loading