Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
trybe-tech-ops authored Feb 13, 2023
0 parents commit b1b1332
Show file tree
Hide file tree
Showing 25 changed files with 16,042 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGO_DB_URL=mongodb://localhost:27017/CarShop
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
dist
__tests__
nyc.config.js
.nyc_output
.vscode
coverage
96 changes: 96 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"root": true,
"env": {
"browser": false,
"node": true,
"es2021": true,
"jest": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"airbnb-base",
"plugin:editorconfig/noconflict",
"plugin:mocha/recommended",
"airbnb-typescript/base"
],
"parser": "@typescript-eslint/parser",
"overrides": [
{
"files": ["*.ts", "tests/**/*.tests.js"],
"rules": {
"prefer-arrow-callback": "off",
"func-names": "off",
"max-lines-per-function": "off"
}
}
],
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "sonarjs", "editorconfig", "mocha"],
"rules": {
"class-methods-use-this": [0],
"no-underscore-dangle": "off",
"no-console": 1,
"camelcase": "warn",
"arrow-parens": [2, "always"],
"quotes": [2, "single"],
"implicit-arrow-linebreak": "off",
"consistent-return": "off",
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"object-curly-newline": "off",
"max-params": ["error", 6],
"max-lines": ["error", 250],
"max-lines-per-function": [
"error",
{
"max": 20,
"skipBlankLines": true,
"skipComments": true
}
],
"max-len": [
"error",
100,
{
"ignoreComments": true
}
],
"complexity": ["error", 5],
"import/no-extraneous-dependencies": ["off"],
"sonarjs/cognitive-complexity": ["error", 5],
"sonarjs/no-one-iteration-loop": ["error"],
"sonarjs/no-identical-expressions": ["error"],
"sonarjs/no-use-of-empty-return-value": ["error"],
"sonarjs/no-extra-arguments": ["error"],
"sonarjs/no-identical-conditions": ["error"],
"sonarjs/no-collapsible-if": ["error"],
"sonarjs/no-collection-size-mischeck": ["error"],
"sonarjs/no-duplicate-string": ["error"],
"sonarjs/no-duplicated-branches": ["error"],
"sonarjs/no-identical-functions": ["error"],
"sonarjs/no-redundant-boolean": ["error"],
"sonarjs/no-unused-collection": ["error"],
"sonarjs/no-useless-catch": ["error"],
"sonarjs/prefer-object-literal": ["error"],
"sonarjs/prefer-single-boolean-return": ["error"],
"sonarjs/no-inverted-boolean-check": ["error"],
"lines-between-class-members": "off",
"@typescript-eslint/lines-between-class-members": ["off"]
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
coverage
.nyc_output
.env
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:16.14

WORKDIR /app

COPY package*.json ./

RUN ["npm", "i"]

COPY . .

RUN chown node:node /app

USER node

CMD ["npm", "run", "dev"]
66 changes: 66 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
version: "3"

services:
# Serviço que irá rodar o node
node:
# Imagem base do container
image: node:16.14
# Nome do container para facilitar execução
container_name: car_shop
# Caminho da Dockerfile
build: ./
# Mesmo que `docker run -t`
tty: true
# Mesmo que `docker run -i`
stdin_open: true
# Substitui o comando padrão da imagem do node
command: bash
# Restarta a imagem caso algo a faça parar
restart: always
# Diretório padrão de execução
working_dir: /app
# Lista de volumes (diretórios) mapeados de fora para dentro do container
volumes:
# Monta o diretório atual, com todos os dados do projeto,
# dentro do diretório /app
- ./:/app
# Lista de serviços do qual este serviço depende
depends_on:
# Precisa do mongo funcionando antes de subir o node
- mongodb
# Lista de portas mapeadas de dentro para fora do container
# na notação porta_de_fora:porta_de_dentro
ports:
# Expõe a porta padrão da aplicação: altere aqui caso use outra porta
- 3001:3001
environment:
- MONGO_URI=mongodb://mongodb:27017/CarShop

# Serviço que irá rodar o mongodb
mongodb:
image: mongo:5.0.7
container_name: car_shop_db
volumes:
- ./:/app
restart: always
ports:
# Garanta que não haverá conflitos de porta com um mongodb que esteja
# rodando localmente
- 27017:27017

# Lista de redes que os containeres irão utilizar
networks:
# Rede padrão, criada automaticamente
default:
# Dá um nome específico à rede padrão
name: car_shop_net

# As chaves `tty`, `stdin_open` e `command` fazem com que o container fique
# rodando em segundo plano, bem como tornam possível o uso do comando
# `docker attach`, já deixando o terminal atual acoplado ao container, direto
# no bash. Apesar disso, utilizar o attach mais de uma vez irá replicar o
# terminal, portanto é melhor utilizar o comando `docker exec`.

# A renomeação da rede padrão é feita pois caso contrário o nome da rede será
# o nome do diretório onde o arquivo atual se encontra, o que pode dificultar
# a listagem individual.
15 changes: 15 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
rootDir: './__tests__',
setupFilesAfterEnv: ['./setup.js'],
testSequencer: './testSequencer.js',
modulePathIgnorePatterns: [
'<rootDir>/utils',
'<rootDir>/sources',
'<rootDir>/setup.js',
'<rootDir>/testSequencer.js',
],
testTimeout: 60000,
};
7 changes: 7 additions & 0 deletions jest.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare namespace jest {
interface Matchers<R> {
toCompile(emit: boolean = true): R;
notToCompile(): R;
toCompileAndBeEqualTo(expected): R;
}
}
16 changes: 16 additions & 0 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
"extends": "@istanbuljs/nyc-config-typescript",
"include": [
"src/Models",
"src/Services",
"src/Controllers"
],
"reporter": [
"text",
"text-summary",
"json-summary",
"html",
"lcov"
],
"all": true
}
Loading

0 comments on commit b1b1332

Please sign in to comment.