Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
c9d6f5a
first commit
juniorsilvacc Jan 17, 2022
c7deb60
refactor: home folder architecture and refactoring code
juniorsilvacc Jan 17, 2022
11176b7
chore: fixing application start
juniorsilvacc Jan 18, 2022
ed1d273
chore: adding user migration
juniorsilvacc Jan 18, 2022
c33b491
chore: adding eslint and prettier
juniorsilvacc Jan 18, 2022
b2b28d4
feat: adding entity and interface
juniorsilvacc Jan 18, 2022
7afd616
feat: creating users
juniorsilvacc Jan 18, 2022
2442331
chore: adding tsyringe
juniorsilvacc Jan 18, 2022
d78da9b
chore: enabling tsconfig function
juniorsilvacc Jan 18, 2022
e517f66
feat: user creation validation
juniorsilvacc Jan 18, 2022
7ec97fe
chore: adding celebrate
juniorsilvacc Jan 18, 2022
3a90b29
feat: bcrypt hash providers
juniorsilvacc Jan 18, 2022
f457fbb
chore: adding bcrypt
juniorsilvacc Jan 18, 2022
55e9f31
feat: encrypting user password
juniorsilvacc Jan 18, 2022
b8dd921
chore: adding expres async errors
juniorsilvacc Jan 18, 2022
fb03e18
feat: user authentication
juniorsilvacc Jan 18, 2022
4d25426
refactor: refactoring and changing user creation
juniorsilvacc Jan 18, 2022
c8677b2
feat: user authentication session with jwt token
juniorsilvacc Jan 18, 2022
57d0dd2
chore: adding jsonwebtoken
juniorsilvacc Jan 18, 2022
190431a
feat: user authentication middleware
juniorsilvacc Jan 18, 2022
864f17e
feat: list of all users
juniorsilvacc Jan 18, 2022
dd53b5b
chore: enabling typeroots
juniorsilvacc Jan 18, 2022
e6a4ab0
feat: admin user creation
juniorsilvacc Jan 18, 2022
6dcee78
refactor: admin route
juniorsilvacc Jan 18, 2022
a323ad2
feat: middleware ensure admin
juniorsilvacc Jan 18, 2022
8940516
chore: adding send:admin
juniorsilvacc Jan 18, 2022
bcac116
feat: update user profile data
juniorsilvacc Jan 19, 2022
72c2280
feat: delete user
juniorsilvacc Jan 19, 2022
b2f0462
refactor: applying the class transformer to the controllers
juniorsilvacc Jan 19, 2022
d79f0cc
chore: adding dotenv
juniorsilvacc Jan 19, 2022
d11a637
feat: upload configuration
juniorsilvacc Jan 19, 2022
11752a4
chore: adding multer
juniorsilvacc Jan 19, 2022
10cf991
feat: avatar upload
juniorsilvacc Jan 19, 2022
74a0db9
chore: adding routes static
juniorsilvacc Jan 19, 2022
7d6e715
chore: adding migration user tokens
juniorsilvacc Jan 19, 2022
0af3e05
feat: entities and repositories user token
juniorsilvacc Jan 19, 2022
fcae5e1
feat: send forgot password and reset password services
juniorsilvacc Jan 19, 2022
2a1c5d1
chore: adding date fns
juniorsilvacc Jan 19, 2022
25d3530
refactor: changing usertokens class names
juniorsilvacc Jan 19, 2022
2064c42
feat: send forgot and reset password controllers and routes
juniorsilvacc Jan 19, 2022
99a57b4
chore: adding column in usertokens migration
juniorsilvacc Jan 19, 2022
2d0edaf
feat: ethereal fake email service and tamplate handlebars
juniorsilvacc Jan 20, 2022
99dfca9
chore: adding dependencies for fake email
juniorsilvacc Jan 20, 2022
540a6a2
chore: create migration categories
juniorsilvacc Jan 20, 2022
6011971
feat: create category
juniorsilvacc Jan 20, 2022
a0fa8a9
feat: list categories
juniorsilvacc Jan 20, 2022
b886580
feat: delete category
juniorsilvacc Jan 20, 2022
dd91ccb
feat: update category
juniorsilvacc Jan 20, 2022
8cfef41
chore: adding migration objetcs
juniorsilvacc Jan 21, 2022
28a10ba
feat: create object
juniorsilvacc Jan 21, 2022
4d88fc4
feat: create display a user
juniorsilvacc Jan 21, 2022
2d60257
feat: list all objects
juniorsilvacc Jan 21, 2022
9ad32e8
refactor: adding user id of objects
juniorsilvacc Jan 21, 2022
41158f1
refactor: object refactoring
juniorsilvacc Jan 21, 2022
16e9830
chore: adding migration object images
juniorsilvacc Jan 21, 2022
92d3128
feat: create upload images object
juniorsilvacc Jan 21, 2022
74a0baa
feat: listing objects by filter
juniorsilvacc Jan 21, 2022
289d7fa
chore: validation created objects
juniorsilvacc Jan 21, 2022
4d0f410
chore: adding jest
juniorsilvacc Jan 21, 2022
333b57f
test: ensure the creation category returns 201
juniorsilvacc Jan 21, 2022
8671b94
test: ensure the category returns 400 if created with the same name
juniorsilvacc Jan 21, 2022
4690ca7
test: ensure that listing all categories returns 200
juniorsilvacc Jan 21, 2022
c070815
test: ensure user creation returns 201
juniorsilvacc Jan 22, 2022
30d1371
test: ensure the user returns 400 if created with the same email
juniorsilvacc Jan 22, 2022
99fecc5
test: ensure login authentication
juniorsilvacc Jan 22, 2022
1d5e444
ensure it returns 401 if it tries to authenticate with non-existent user
juniorsilvacc Jan 22, 2022
97c9512
test: ensure it returns 401 if it tries to authenticate with wrong pa…
juniorsilvacc Jan 22, 2022
e98bec0
test: ensure category is excluded
juniorsilvacc Jan 22, 2022
4990b54
test: ensure object creation returns 201
juniorsilvacc Jan 22, 2022
92d91cc
chore: adding relations
juniorsilvacc Jan 22, 2022
4460219
chore: repository fake objects
juniorsilvacc Jan 22, 2022
c5ece27
refactor: category delete test
juniorsilvacc Jan 22, 2022
4f98b62
test: ensure that the listing of all objects returns 200
juniorsilvacc Jan 22, 2022
efa2038
test: ensure that the listing of all accessible objects returns 200
juniorsilvacc Jan 22, 2022
66e6b9d
test: ensure that listing all objects accessible by name returns 200
juniorsilvacc Jan 22, 2022
0d86d21
test: ensure that listing all objects accessible by category returns 200
juniorsilvacc Jan 22, 2022
9d82b95
test: ensure that the listing of all users returns 200
juniorsilvacc Jan 22, 2022
ee76205
test: ensure the user is deleted
juniorsilvacc Jan 22, 2022
09f571a
chore: adding migration messages
juniorsilvacc Jan 24, 2022
fd00af4
feat: object messages
juniorsilvacc Jan 24, 2022
3eebf64
chore: implementation of a findbyid in objscts
juniorsilvacc Jan 24, 2022
889b9c9
refactor: adding attributes and making entity relationship
juniorsilvacc Jan 25, 2022
39edf3c
fix: bug tests
juniorsilvacc Jan 25, 2022
83e585e
feat: adding column in users table
juniorsilvacc Jan 25, 2022
d28e530
chore: readme.md
juniorsilvacc Jan 25, 2022
e8af379
feat: object will be unavailable when admin message is sent
juniorsilvacc Jan 25, 2022
54c3bbe
fix: fixing bugs in tests
juniorsilvacc Jan 25, 2022
7b37eac
feat: implementation redis
juniorsilvacc Jan 25, 2022
1a9bc88
feat: implementation middleware rate limiter
juniorsilvacc Jan 25, 2022
fdedd60
refactor: radis cache
juniorsilvacc Jan 25, 2022
0274efd
chore: update readme
juniorsilvacc Jan 26, 2022
e68c634
chore: validation message and readme
juniorsilvacc Jan 26, 2022
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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PORT = 3333
APP_SECRET = 91cf4aa79dbb713fbf551ce3efa9c12d
APP_API_URL = http://localhost:3333
APP_WEB_URL = http://localhost:3000
REDIS_HOST = localhost
REDIS_PORT = 6379
REDIS_PASS =
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
build
/*.js
19 changes: 19 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"prettier"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"rules": {
"no-console": "warn",
"prettier/prettier": "error"
}
}
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.idea/
.vscode/
node_modules/
build/
temp/
.env
coverage
ormconfig.json
dist

uploads/*
!uploads/.gitkeep
.DS_Store
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"arrowParens": "avoid"
}
59 changes: 29 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
## Accurate Software
## Objetivo Geral

<img src="https://accurate.com.br/wp-content/uploads/2020/06/logo-accurate-300.svg" alt="drawing" width="200"/>
- API Restful para realizar o gerenciamento de objetos achados e perdidos.

Seja bem-vindo a [Accurate Software](https://accurate.com.br).
## Funcionalidades do Sistema

Temos diversas vagas para desenvolvedores: Frontend, Backend e Fullstack!
- Deve ser possível usuário se cadastrar, ler, atualizar e deletar seus dados pessoais. Visando também o controle sobre sua conta. Os usuários são dividios em usuários comuns com funcionalidades restritas para seu cadastro e usuário administrador com acesso a todas as funcionalidades do sistema. Os usuários comuns não poderam excluir suas contas.

> Para conhecer melhor os candidatos, preparamos um desafio técnico. Não se preocupe em cumprir todos os requisitos propostos no desafio, este teste visa avaliar a sua capacidade de resolução de problemas. Abaixo serão apresentados dois desafios direcionados aos perfis frontend e backend, caso o seu perfil for voltado para fullstack fique a vontade em nos enviar uma solução completa abordando tanto frontend quanto backend!
- Deve ser possível que usuário faça upload do seu avatar de usuário.

## Instruções
- Deve ser possível que usuário faça a recuperação de senha informando o email que será enviado um token de autorização.

1. Para começar o desafio, realize um fork no repositório: https://github.com/accurate-software/accurate-software.github.io
- Deve ser possível que usuário logado faça a troca de senha.

2. O desafio deverá set commitado no fork.
- Deve ser possível que usuário administrador cadastre, exclua, atualiza e liste categorias de objetos.

3. Após a finalização do desafio, solicite um pull request do fork no nosso repositório ;)
- Deve ser possível que usuário administrador liste todos os usuários cadastrados.

### Desafio Frontend
- Deve ser possível que o usuário, desde que logado no sistema, cadastrar um objeto perdido e/ou encontrado. O usuário administrador tem acesso pleno aos objetos criados por outros usuários.

O seu desafio é realizar um desenvolvimento de uma aplicação frontend que compra os requisitos:
- Deve ser possível que o usuário faça upload de fotos dos objetos perdidos e/ou encontrados.

+ Consumo de API REST
+ CRUD ou listagem de algum recurso da API
+ Utilizar alguma API pública, podendo ser alguma do site: https://public-apis.xyz/
- Deve ser possível que o usuário filtre todos os objetos disponíveis por categorias e nome.

Vamos avaliar a sua capacidade como desenvolvedor frontend, observando os critérios:
- Deve ser possível que o usuário administrador envie uma mensagem ao usuário que criou o objeto perdido, avisando-o que o objeto foi encontrado, com isso o objeto ficará indisponível automaticamente. O dono pode se dirigir ao setor responsável para retirá-lo.

+ Uso semântico do HTML
+ Estruturação do layout e tags CSS
+ Layout acessível e responsivo
+ Utilização de frameworks da atualizade, como: React, Vue, Angular ou algum outro de sua preferência.
+ Lembre-se de documentar a solução com um README.MD :)
- Deve ser possível a listagem de todos os objetos, antes de fazer o cadastro de usuário.

### Desafio Backend
## Ferramentas e Tecnologias Utilizadas

O seu desafio é realizar um desenvolvimento de uma API Rest para um site de achados e perfidos. Sua API deve conter as seguintes funcionalidades:
- Conceitos de boas práticas e qualidade no código, usando Design Patterns, Clean Architecture, Domain Driven Design (DDD) e Princípios SOLID, além de introduzir Testes Automatizados com o framework Jest e autenticação via JWT Token.

+ Cadastro de um "Achado"/"Perdido"
+ Atualização de histórico de um "Achado"/"Perdido"
+ Busca com opção de filtros, como por exemplo: Categoria
+ Relatório de cruzamento de informações "Achados"/"Perdidos", dado um categoria e um raio.
- Node.js com Typescript;

Fique a vontade para usar a linguagem e framework de sua preferência, como: Java, C# e Node! Porém se atente aos seguintes pontos:
- Express;

+ Tratamento de erros e exceções
+ Clareza e clean code no desenvolvimento da solução
+ Documentação da solução - README.MD :)
- TypeORM;

- PostgreSQL;

- Redis;

- Docker;

- Celebrate Validation;

- Rate Limiter;
191 changes: 191 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/

export default {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
bail: true,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "/tmp/jest_rs",

// Automatically clear mock calls, instances and results before every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,

// The directory where Jest should output its coverage files
// coverageDirectory: undefined,

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'v8',

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,

// A path to a custom dependency extractor
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "jsx",
// "ts",
// "tsx",
// "json",
// "node"
// ],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
preset: 'ts-jest',

// Run tests from one or more projects
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state before every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: undefined,

// Automatically restore mock state and implementation before every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
// testEnvironment: "jest-environment-node",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
testMatch: ['**/*.spec.ts'],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: undefined,

// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",

// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};
15 changes: 15 additions & 0 deletions ormconfig.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"type": "postgres",
"port": 5432,
"host": "localhost",
"username": "postgres",
"password": "root",
"database": "lost-and-found",
"entities": [
"./src/modules/**/infra/typeorm/entities/*.ts"
],
"migrations": ["./src/shared/infra/typeorm/migrations/*.ts"],
"cli": {
"migrationsDir": "./src/shared/infra/typeorm/migrations"
}
}
15 changes: 15 additions & 0 deletions ormconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"type": "postgres",
"port": 5432,
"host": "localhost",
"username": "postgres",
"password": "root",
"database": "lost-and-found",
"entities": [
"./src/modules/**/infra/typeorm/entities/*.ts"
],
"migrations": ["./src/shared/infra/typeorm/migrations/*.ts"],
"cli": {
"migrationsDir": "./src/shared/infra/typeorm/migrations"
}
}
Loading