Skip to content
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
8 changes: 6 additions & 2 deletions .env.exemple
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PORT=5000
STORAGE_TYPE="local ou s3" #escolher onde as imagens serão armazenadas, local para test ou s3 para o bucket
ENV_AMB="QA ou PROD" #escolher qual ambiente a ser trabalhado
ENV_AMB="QA, PROD ou LOCAL" #escolher qual ambiente a ser trabalhado
KEY_ID="key_id do bucket"
ACCESS_KEY="access_key do bucket"
BUCKET="nome do bucket"
Expand All @@ -10,4 +10,8 @@ mongoQA="url de conexão"

clientId=
clientSecret=
URL_AUTHORIZATION="url para realizar o longin e retornar o acess_token"
URL_AUTHORIZATION="url para realizar o longin e retornar o acess_token"

#somente local para o sonarqueb
S_TOKEN_ACESS=
S_NAME_PROJECT=
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/node_modules
/.pnpm-store
/tmp/uploads
.scannerwork
# Logs
logs
*.log
Expand All @@ -17,6 +18,7 @@ lerna-debug.log*

# Tests
/coverage
/test/coverage
/.nyc_output

# IDEs and editors
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.{ts,tsx}": "eslint --fix"
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.5.1
v20.11
20 changes: 19 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
{
"git.ignoreLimitWarning": true
"version": "0.2.0",
"configurations": [
{
"name": "Docker: Attach to Node",
"type": "node",
"request": "attach",
"port": 9229,
"address": "172.21.0.2",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/home/node/app",
"protocol": "inspector",
"restart": true,
"sourceMaps": true,
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
]
}
]
}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:20.5.1
FROM node:20.11

# RUN apk add --no-cache bash
RUN npm install -g pnpm
RUN npm install -g @nestjs/cli
USER node
USER root

WORKDIR /home/node/app
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,14 @@

[docker compose](https://docs.docker.com/compose/install/) install Docker Componse.

## automatic installation with docker
## Running the app with docker
```bash
# run local api
$ docker compose up or $ docker compose up --build
# DELETE THE CONTAINERS
$ docker compose down -v
```

## Running the app and Installation manual
```bash
$ npm install
# build
$ npm run build
# development
$ npm run start:dev
# production
$ npm run start:prod
```

# watch mode
```bash
$ npm run start:dev
Expand Down
91 changes: 91 additions & 0 deletions changelog.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
module.exports = {
disableEmoji: false,
format: "{type}{scope}: {emoji}{subject}",
list: [
"test",
"feat",
"fix",
"chore",
"docs",
"refactor",
"style",
"ci",
"perf",
],
maxMessageLength: 64,
minMessageLength: 3,
questions: [
"type",
"scope",
"subject",
"body",
"breaking",
"issues",
"lerna",
],
scopes: [],
types: {
chore: {
description: "Mudanças no processo de build ou ferramentas auxiliares",
emoji: "🤖",
value: "chore",
},
ci: {
description: "Mudanças relacionadas à CI (Integração Contínua)",
emoji: "🎡",
value: "ci",
},
docs: {
description: "Apenas mudanças na documentação",
emoji: "✏️",
value: "docs",
},
feat: {
description: "Uma nova funcionalidade",
emoji: "🎸",
value: "feat",
},
fix: {
description: "Correção de um bug",
emoji: "🐛",
value: "fix",
},
perf: {
description: "Uma mudança de código que melhora o desempenho",
emoji: "⚡️",
value: "perf",
},
refactor: {
description:
"Uma mudança de código que não corrige um bug ou adiciona uma funcionalidade",
emoji: "💡",
value: "refactor",
},
release: {
description: "Criar um commit de lançamento",
emoji: "🏹",
value: "release",
},
style: {
description:
"Marcação, espaços em branco, formatação, ponto e vírgula ausente...",
emoji: "💄",
value: "style",
},
test: {
description: "Adição de testes ausentes",
emoji: "💍",
value: "test",
},
messages: {
type: "Selecione o tipo de mudança que você está commitando:",
customScope: "Selecione o escopo que essa alteração afeta:",
subject: "Escreva uma descrição curta e imperativa da mudança:\n",
body: "Forneça uma descrição mais longa da mudança:\n ",
breaking:
"Liste quaisquer mudanças que possam quebrar a compatibilidade:\n",
footer: "Issues que esse commit resolve, por exemplo, #123:",
confirmCommit: "Os pacotes que este commit afetou\n",
},
},
};
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
};
27 changes: 27 additions & 0 deletions docker-compose-sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3'

services:
db:
image: postgres
environment:
POSTGRES_USER: sonartest
POSTGRES_PASSWORD: sonartest
POSTGRES_DB: sonar

SonarQube:
image: sonarqube:community
depends_on:
- db
ports:
- "9000:9000"
environment:
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
SONAR_JDBC_USERNAME: sonartest
SONAR_JDBC_PASSWORD: sonartest
volumes:
- SonarQube_data:/opt/SonarQube/data
- SonarQube_extensions:/opt/SonarQube/extensions

volumes:
SonarQube_data:
SonarQube_extensions:
44 changes: 44 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,54 @@
version: '3'

services:
mongodb:
image: mongo
container_name: mongodb
ports:
- "27017:27017"
volumes:
- .:/home/node/app
attach: false # desabilita ou habilita os logs do mongo
networks:
- api-fullsports
command: mongod --bind_ip_all

app:
build: .
depends_on:
- mongodb
entrypoint: .docker/entrypoint.sh
ports:
- "${PORT}:${PORT}"
volumes:
- .:/home/node/app
networks:
- api-fullsports
environment:
DBAAS_MONGODB_ENDPOINT: mongodb://mongodb:27017
VERCEL_GIT_COMMIT_REF: Local version
URL_AUTHORIZATION: http://localhost:${PORT}/auth/login-app/

mongodb-seed: # rodar esse container, importa os dados das materias(json) no mongodb local
image: mongo
container_name: mongodb-seed
depends_on:
- mongodb
volumes:
- .:/home/node/app
networks:
- api-fullsports
command:
- sh
- -c
- |
mongoimport --uri mongodb://mongodb:27017 --collection users --file home/node/app/src/mocks/user.mock.json --jsonArray
mongoimport --uri mongodb://mongodb:27017 --collection recommendations --file home/node/app/src/mocks/component_recommendation.mock.json --jsonArray
mongoimport --uri mongodb://mongodb:27017 --collection providers --file home/node/app/src/mocks/provider.mock.json --jsonArray
mongoimport --uri mongodb://mongodb:27017 --collection products --file home/node/app/src/mocks/product.mock.json --jsonArray
mongoimport --uri mongodb://mongodb:27017 --collection orders --file home/node/app/src/mocks/order.mock.json --jsonArray
mongoimport --uri mongodb://mongodb:27017 --collection models --file home/node/app/src/mocks/image.mock.json --jsonArray

networks:
api-fullsports:
driver: bridge
51 changes: 51 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Config } from "jest";
import { pathsToModuleNameMapper } from "ts-jest";
import { compilerOptions } from "./tsconfig.json";

const config: Config = {
moduleFileExtensions: ["js", "json", "ts"],
testRegex: ".*\\.spec\\.ts$",
transform: {
"^.+\\.(t|j)s$": "ts-jest",
},
collectCoverageFrom: ["**/*.(t|j)s"],
coverageDirectory: "./coverage",
coveragePathIgnorePatterns: [
"/node_modules/",
"/dist/",
".*model\\.ts$",
".*schema\\.ts$",
".*config\\.ts$",
".*module\\.ts$",
".*main\\.ts$",
".*dto\\.ts$",
"/dto/",
"\\.dto\\.ts$",
"/Schema/",
"\\.schema\\.ts$",
".*jwt-auth.guard\\.ts",
".*local-auth.guard\\.ts",
"/.vercel/",
".*tmp\\.ts$",
"/validator/",
"/test/",
"/mock/",
"/mocks/",
"/configs/",
"/config/",
"/interfaces/",
".eslintrc.js",
"commitlint.config.js",
"/coverage/",
"sonar-project.ts",
"/enums/",
".changelog.config.js",
],
preset: "@shelf/jest-mongodb",
testEnvironment: "node",
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: "<rootDir>/",
}),
};

export default config;
5 changes: 3 additions & 2 deletions nest-cli.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"sourceRoot": "src/modules",
"compilerOptions": {
"deleteOutDir": true
}
},
"entryFile": "src/main"
}
Loading