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
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
5 changes: 5 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PORT_NODE=3000

MONGODB_URL=mongodb://localhost/entrevista

API_VERSION=/V1
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
"extends": "standard",
"plugins": [
"standard",
"promise"
],
"rules":{
"no-tabs": 0,
"smarttabs": 0,
"indent": ["error", 4]
}
};
79 changes: 79 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# 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

# 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/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

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

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

data/

apidoc/

doc-html/
File renamed without changes.
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
# Processo Seletivo

Candidate: Israel Dantas Leite

# Install dependencies

- Dependencies Application: ` npm i `
- Dependencies Nodemon: `npm i nodemon`
- Dependencies Doc: `npm i apidoc live-server -g`
- create archive `cp .env-example .env`

# Import data for base

- Import from CSV for Mongo: `npm run mongo:import`

# Generate Documentation
` apidoc -e "(node_modules|public|_tester)" -o doc-html /apidoc `

# Machine Local
### Technologies needed
- Nodejs 8.10.0 or superior
- MongoDB 3.6 or superior

### Start Documentation
`npm run doc`

### Tester
` npm run test`

### Eslint
` npm run lint:fix `

### Start Application
`npm start`

### Access
- Api: *http://localhost:3000*
- Documentation: *http://localhost:8080*

# Docker
### Tecnologies needed
- Docker 18.06.1
- Docker Compose 1.22.0

## Start Application
`docker-compose up`

### Access
- Api: *http://localhost:3000*
- Documentation: *http://localhost:8080*



# Teste de Backend

Olá Dev! Tudo bem?
Expand Down Expand Up @@ -33,4 +86,4 @@ Após terminar o desafio, você pode solicitar um pull request para a branch mas

Só! Mas se quiser fazer a diferença, tente implementar um pouco de TDD e utilizar docker para execução do projeto.

Boa sorte! :)
Boa sorte! :)
8 changes: 8 additions & 0 deletions apidoct.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Api Teste RedFox",
"version": "1.0.0",
"description": "Api Teste RedFox",
"template": {
"forceLanguage": "pt-br"
}
}
38 changes: 38 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require('dotenv').load()
const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const http = require('http')
const path = require('path')
const validator = require('express-validator')
const helmet = require('helmet')
const compression = require('compression')

const { Logger } = require('./src/helpers/logger-info')

const { route404, logServer } = require('./src/errors/system')

const { errorFormatter } = require('./src/errors/validate')

require('./src/databases/mongodb')

const app = express()

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(validator(errorFormatter))
app.use(cors())
app.use(compression())
app.use(helmet())
app.disable('x-powered-by')

require('./routes')(app)

const port = process.env.PORT || 3000
const server = http.createServer(app)

app.use((_, res) => res.status(404).json([route404]))

server.listen(port, () => Logger.info(logServer(port)))

module.exports = app
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "2"
services:
mongo:
image: mongo:latest
container_name: "mongodb_entrevista"
backend:
image: node:8.11.4
restart: always
container_name: backend_entrevista
volumes:
- .:/backend
- /node_modules
ports:
- 3000:3000
depends_on:
- mongo
command: bash -c "cd /backend && node_modules/.bin/nodemon"
environment:
- PORT=3000
- MONGODB_URL=mongodb://mongodb_entrevista/entrevista
- API_VERSION = /v1
Loading