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

Teste #7

Open
wants to merge 7 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
7 changes: 7 additions & 0 deletions .TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ ] possibilitar importar usando @ para ter atalhos
[ ] variável de ambiente para usar mocks em vez de prisma
[ ] reestruturar os comandos do package.json
[ ] melhorar ordem de execução de testes em hook de pre-commit
[ ] adicionar mais exemplos para o schemathesis usar
[ ] adicionar mais testes unitários e de integração da infra
[x] adicionar banco de dados sqlite
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
yarn.lock
coverage

#.env*
!.env.vault
50 changes: 50 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# GENERAL CONFIGURATION
NODE_ENV='local'
DOMAIN_ADDRESS='http://localhost'
API_PATH='/api/v1'
API_NAME='petropolis-circularidade'
WILL_DISABLE_AUTHENTICATION=true
API_VERSION='0.1.0'
TCP_PORT=3000

TCP_PORT1=000

# DATABASE CONFIGURATION
DATABASE_URL="postgresql://user:[email protected]:5433/db_name?schema=public"

# LOGGING CONFIGURATION
LOG_LEVEL='debug' # @see https://github.com/winstonjs/winston?tab=readme-ov-file#logging-levels

# CORS CONFIGURATION
CORS_METHODS='GET','PUT','POST','DELETE','HEAD','OPTIONS'
CORS_ORIGINS='*'
CORS_MAX_AGE=600 # @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age

# CONTENT SECURITY POLICY
CONTENT_SECURITY_SCRIPT_SRC="'self'"

# SESSION CONFIGURATION
SESSION_NAME='PETROPOLIS-CIRCULARIDADE'
SESSION_SECRET='g9uA81SCuWbqqg5TfGIbwffRrcXhfgfwlDn3I1plNxAg5bcfgV'
SESSION_MAX_AGE_MS=3600000

# OPENAPI SWAGGER CONFIGURATION
SWAGGER_PATH='/docs/v1'
SWAGGER_RAW_PATH='/openapi/v1/'
SWAGGER_TITLE='API da Petrópolis de Circularidade do Vidro'
SWAGGER_DESCRIPTION='API para o app responsivo de circularidade do Vidro'
SWAGGER_VERSION='3.0.0'

# OIDC
OIDC_JWKS_URL=https://keycloak.example.com/realms/your-realm/protocol/openid-connect/certs
OIDC_ISSUER=https://keycloak.example.com/realms/your-realm
OIDC_AUDIENCE=client-petro
OIDC_DISABLE=True

# KEYCLOAK
KEYCLOAK_CLIENT_ID=client-petro
KEYCLOAK_CLIENT_SECRET=6CLRjcRbuDoUiw7bUOneERsyB4x3YzVT
KEYCLOAK_GRANT_TYPE=password
KEYCLOAK_ADMIN_USERNAME=admin
KEYCLOAK_ADMIN_PASSWORD=1
KEYCLOAK_DOMAIN=http://localhost:8080
20 changes: 20 additions & 0 deletions .github/workflows/schemathesis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Schemathesis Test

on: [pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Start containers
run: docker compose up -d --build

- uses: schemathesis/action@v1
with:
schema: "http://127.0.0.1:5123/openapi.json"

- name: Stop containers
if: always()
run: docker-compose down
228 changes: 228 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
# Created by https://www.toptal.com/developers/gitignore/api/node,visualstudiocode,macos,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=node,visualstudiocode,macos,windows

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

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

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

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

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

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

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode,macos,windows

.hypothesis
database.db
database.db-journal
db.sqlite
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn commitlint --edit $1
33 changes: 33 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Análise do Código
yarn lint
yarn style
yarn typecheck
yarn compliance

# Teste smoke
yarn test:smoke

# Testes unitários
yarn test:unit

# Migração do banco de dados
yarn migrate:local
yarn migrate:local:reset --force

# Testes fim a fim
yarn test:e2e

# Limpar banco para teste de API
yarn migrate:local:reset --force

# Testes de API
#!/bin/bash

if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "win32" ]] || [[ "$MSYSTEM" == MINGW* ]]; then
yarn e2e:run:win
else
yarn e2e:run
fi

# Limpar banco no final de tudo
yarn migrate:local:reset --force
17 changes: 17 additions & 0 deletions .license-compliancerc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
allow: [
'MIT',
'ISC',
'BSD-3-Clause',
'BSD-2-Clause',
'Apache-2.0',
'BlueOak-1.0.0',
'CC0-1.0',
'CC-BY-4.0',
'0BSD',
'MIT-0',
],
format: 'text',
production: true,
report: 'summary',
};
25 changes: 25 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"recommendations": [
"bruno-api-client.bruno",
"formulahendry.code-runner",
"robertz.code-snapshot",
"vivaxy.vscode-conventional-commits",
"mikestead.dotenv",
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"mhutchie.git-graph",
"github.vscode-pull-request-github",
"eamodio.gitlens",
"lokalise.i18n-ally",
"bierner.jsdoc-markdown-highlighting",
"ritwickdey.liveserver",
"ms-vsliveshare.vsliveshare",
"pkief.material-icon-theme",
"cweijan.vscode-postgresql-client2",
"esbenp.prettier-vscode",
"prisma.prisma",
"foxundermoon.shell-format",
"vitest.explorer",
"kingwl.vscode-vitest-runner"
]
}
Loading