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
85 changes: 29 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,32 @@
# Teste II - Fullstack Development
# Teste II

## Um pouco sobre nós
## Resolução
O teste foi resolvido utilizando as seguintes tecnologias:

Estamos procurando uma pessoa desenvolvedora que possa agregar em nosso time, principalmente quem gosta de propor soluções e inovações. Estamos montando nosso novo time de Produtos e pra isso precisamos de pessoas que conheçam:

- Front-end: Angular, React ou VueJS ♥️
- Front-end: Angular
- Backend: NodeJS
- Banco de Dados: SQL / Um pouco de NoSQL
- GIT
- Ter trabalhado antes em equipes ágeis e multidisciplinares


Mas também será ótimo se você conhecer:

- Docker e Docker-compose
- Jenkins
- RabbitMQ

Acha que se enquadra no perfil? Temos um teste abaixo para entendermos mais seu conhecimento.


## Problema

Um cliente deseja criar 5 campos de forma parametrizável, sendo que ele vai definir:
- Label a ser exibido
- Id do campo
- Tipo de campo (texto simples, texto grande, ou combo)

**Restrições:**
- Se o tipo de campo for texto, o máximo de caracteres é 30;
- Se o tipo de campo for texto grande, o máximo de caracteres é 100;
- Se o tipo de campo for combo, ele pode cadastrar até 3 opções.

**Proposta**:

Renderizar os campos que foram parametrizados previamente e o usuário conseguir preencher os campos e salvar (em uma base de dados*)

**Tecnologias que esperamos**:

**Front:**
- Algum framework JS (Angular, React, Vue ♥️)
- Pré-processador de estilo (SASS, Stylus, SCSS, etc)

**Back:**
- NodeJS

**Armazenamento:**
- A sua escolha (NoSQL, SQL, Cache): MySQL, MongoDB, ElasticSearch, Postgres, Node-cache, Redis, etc.

**Docker**:
- Dockerfile
- Docker-compose


## Submissão
Para iniciar o teste, faça um fork deste repositório, crie uma branch com o seu nome completo e depois envie-nos o pull request. Se você apenas clonar o repositório não vai conseguir fazer push e depois vai ser mais complicado fazer o pull request. **Importante**: Após finalizar o teste, revisaremos e informaremos sua aprovação ou não. Se for aprovado, mandar um email para rh@icolabora.com com o seu currículo e pretensão 😄

Boa sorte! =D
- Banco de Dados: MySQL utilizando Sequelize como ORM
- SCSS e Bootstrap para estilizar
- Github para versionamento


## Como usar
### Backend
O driver de dados utilizado é o MySQL e as
credenciais utilizadas estão no arquivo **.env** junto com a porta utilizada pelo express.
O nome do banco de dados utilizado é ``teste_developer_II``.
> ## .env
>
>- port=8080
>- db_name=teste_developer_II
>- db_user=root
>- db_pass=

Para iniciar o servidor, basta iniciar o cmd na pasta **/backend** e digitar ``npm start``.

### Frontend
Para iniciar o Angular, basta iniciar o cmd na pasta **/frontend-angular** e digitar ``ng serve``.

**PS:** Não se esqueça de rodar o comando ``npm update`` em cada pasta para baixar as dependências do NodeJS e do Angular!!
** **
**Espero que goste!** 😊
4 changes: 4 additions & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
port=8080
db_name=teste_developer_II
db_user=root
db_pass=
4 changes: 4 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
port=8080
db_name=teste_developer_II
db_user=root
db_pass=
3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Node
/node_modules/
package-lock.json
11 changes: 11 additions & 0 deletions backend/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const app = require('./server');
const bodyParser = require('body-parser');
const cors = require('cors');

// MIDDLEWARES
app.use(bodyParser.json());
app.use(cors());

// API ROUTES
const postagemRouter = require('./routes/postagem.routes');
app.use('/api', postagemRouter);
40 changes: 40 additions & 0 deletions backend/app/controllers/postagem.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const Post = require('../models/post.model');

const criarPostagem = async (req, res, next) => {
var status = 0;
var message = "";
var corpo = {};
if(req.body !== null) {
var nomeFormulario;
for(let i=0;i<req.body.length;i++) {
if(req.body[i].idCampo !== null && req.body[i].resposta !== null && req.body[i].nomeFormulario !== null) {
let idCampo = req.body[i].idCampo;
let resposta = req.body[i].resposta;
nomeFormulario = req.body[i].nomeFormulario;
corpo[idCampo] = resposta;
}
}
console.log(nomeFormulario);
console.log(corpo);
await Post.create({
nomeForm: nomeFormulario,
respostas: corpo
}).then(data => {
status = 200;
message = "Sucesso";
}).catch(err => {
console.log(err);
status = 500;
message = "Erro interno";
})

} else {
status = 400;
message = "Corpo vazio";
}
console.log(corpo);
console.log(`${status}: ${message}`);
return res.status(status).json({'message': message});
};

module.exports = {criarPostagem};
5 changes: 5 additions & 0 deletions backend/app/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Database
const Sequelize = require('sequelize');
const sequelize = new Sequelize(process.env.db_name, process.env.db_user, process.env.db_pass, {dialect: 'mysql', host: 'localhost'});

module.exports = sequelize;
19 changes: 19 additions & 0 deletions backend/app/models/post.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const Sequelize = require('sequelize');
const database = require('../database');

const Post = database.define('post', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
allowNull: false,
primaryKey: true
},
nomeForm: {
type: Sequelize.STRING
},
respostas: {
type: Sequelize.JSON
}
});

module.exports = Post;
6 changes: 6 additions & 0 deletions backend/app/routes/postagem.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const router = require('express').Router();
const postagemController = require('../controllers/postagem.controller');

router.post('/postagem', postagemController.criarPostagem);

module.exports = router;
26 changes: 26 additions & 0 deletions backend/app/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const express = require('express');
require('dotenv-safe').config({
allowEmptyValues: true
});
const app = express();
const port = process.env.port;

const server = app.listen(port, (err, callback) => {
if(err) {
console.log(err);
return;
}
(async() => {
const database = require('./database');
const Post = require('./models/post.model');

try {
const result = await database.sync();
console.log(`Running on port ${port}`);
} catch(error) {
console.log(error);
}
})();
});

module.exports = app;
Empty file added backend/index.js
Empty file.
22 changes: 22 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app/app.js",
"dev": "nodemon app/app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"dotenv-safe": "^8.2.0",
"express": "^4.18.2",
"mysql2": "^3.2.0",
"nodemon": "^2.0.22",
"sequelize": "^6.30.0"
}
}
16 changes: 16 additions & 0 deletions frontend-angular/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
42 changes: 42 additions & 0 deletions frontend-angular/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
4 changes: 4 additions & 0 deletions frontend-angular/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}
20 changes: 20 additions & 0 deletions frontend-angular/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "pwa-chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}
42 changes: 42 additions & 0 deletions frontend-angular/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
}
]
}
Loading