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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode/
.pytest_cache/
8 changes: 0 additions & 8 deletions .htaccess

This file was deleted.

575 changes: 575 additions & 0 deletions .vscode/PythonImportHelper-v2-Completion.json

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions Carro.class.php

This file was deleted.

77 changes: 16 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,19 @@
Teste para desenvolvedor do Estadão
Teste para baga de Desenvolvedor Backend do Estadão
==============================

Olá candidato,

Esse teste consiste em 2 etapas para avaliarmos seu conhecimento em PHP e Front-End (HTML5, CSS e JavaScript)

Para realizar o teste, você deve dar um fork neste repositório e depois clona-lo na pasta <document_root> da máquina que está realizando o teste.

Crie um branch com seu nome, e quando finalizar todo o desenvolvimento, você deverá enviar um pull-request com sua versão.

Olá avaliador(a),

Para execução deste teste serão necessários alguns passos:
1. Primeiro instalamos as dependências com o comando: `$ cd crud_car/backend && composer install`;
1. Ainda na pasta `backend` levantamos o ambiente em docker: `$ ./vendor/bin/sail up -d`;
1. Rodamos as migrações: `$ ./vendor/bin/sail artisan migrate`;
1. Alimentamos o banco de dados executando o arquivo em python:
`$ docker exec -i -t backend-laravel.test-1 /bin/bash`
`$ python3 load_database.py`
`$ exit`;
1. Rodamos o frontend com:
`$ cd ../frontend && npm run` (caso esteja usando o mesmo terminal de ativação e configuração do `backend`)
ou `$ cd crud_car/frontend && npm run` caso tenha aberto um novo terminal.

Para consumo da API, pode-se importar o arquivo de <i>collections</i> `collection_crud_car.json` no seu cliente REST API de preferência.
O teste
--------

### Back-End/PHP

A primeira etapa será o desenvolvimento **backend/PHP**:

**Descrição:**

- Você deverá desenvolver uma 'mini api' para que seja possível realizar operações CRUD do objeto Carro.
> **Obs:**
> - Você pode usar arquivo (txt, json) como banco de dados.
> - Cada carro deve ter ID, Marca, Modelo, Ano.

Sugerimos o retorno dessa 'mini api' nas seguinte urls:

- `/carros` - [GET] deve retornar todos os carros cadastrados.
- `/carros` - [POST] deve cadastrar um novo carro.
- `/carros/{id}`[GET] deve retornar o carro com ID especificado.
- `/carros/{id}`[PUT] deve atualizar os dados do carro com ID especificado.
- `/carros/{id}`[DELETE] deve apagar o carro com ID especificado.

### Front-End

Para a segunda etapa do teste, você deverá desenvolver uma SPA (Single Page Application) e nela deve ser possível:

- Ver a lista de carros cadastrados
- Criar um novo carro
- Editar um carro existente
- Apagar um carro existente

> **Obs:**
> - A página deve ser responsiva.
> - A página deve funcionar 100% via AJAX, sem outros carregamentos de páginas.
> - Ao criar/editar um carro, o campo "marca" deverá ser um `SELECT`

### Ambiente

Esse teste com um ambiente Docker funcional, ou seja, basta rodar os comandos para subir o container da aplicação e acessar a URL do projeto no navegador.

Para rodar o ambiente, é necessário ter o Docker Compose instalado, e rodar o seguinte comando:
> docker-compose up -d nginx

Após o ambiente subir, basta acessar a URL abaixo e começar a desenvolver:
> http://localhost:8080

### Observações importantes:
- O teste só será considerado se rodar através do Docker.
- Caso seja necessário, você pode alterar **qualquer** configuração do Docker. Atente-se apenas para que o ambiente não precise de nenhuma configuração adicional.
- Você não deve se prender aos arquivos do repositório. Fique a vontade para criar outros.
- Você pode usar frameworks, tanto para o front-end, quanto para o back-end, mas um código limpo será melhor avaliado.
- Você pode usar ferramentas de automação (Grunt, Gulp), mas deverá informar o uso completo para funcionamento do teste.
- Será considerado ponto positivo no teste a utilização de JS puro, orientação a objetos, design patterns e rotinas para testes.
4 changes: 0 additions & 4 deletions api.php

This file was deleted.

1 change: 1 addition & 0 deletions collection_crud_car.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"client":"Thunder Client","collectionName":"crud_car","dateExported":"2022-12-01T18:58:23.892Z","version":"1.1","folders":[],"requests":[{"_id":"c00de80d-0ffc-48ae-a414-fa1125b616e7","colId":"0637fa3f-befb-4412-846f-40000c29f99d","containerId":"","name":"GET All Cars","url":"http://0.0.0.0/api/carros","method":"GET","sortNum":10000,"created":"2022-12-01T15:56:51.030Z","modified":"2022-12-01T16:04:40.821Z","headers":[],"params":[],"tests":[]},{"_id":"72f7b278-c48b-42d5-9621-93b873efdc13","colId":"0637fa3f-befb-4412-846f-40000c29f99d","containerId":"","name":"GET Car by ID","url":"localhost/api/carros/2","method":"GET","sortNum":15000,"created":"2022-12-01T16:04:15.685Z","modified":"2022-12-01T16:18:26.456Z","headers":[],"params":[],"tests":[]},{"_id":"223cd83b-be53-47a2-ba36-d4fdfa0736c7","colId":"0637fa3f-befb-4412-846f-40000c29f99d","containerId":"","name":"REGISTER a new Car","url":"http://0.0.0.0/api/carros","method":"POST","sortNum":20000,"created":"2022-12-01T15:57:28.183Z","modified":"2022-12-01T16:48:22.911Z","headers":[],"params":[],"body":{"type":"json","raw":"{\n \"model\": \"Up!\",\n \"brand\": \"VolksWagen\",\n \"year\": 2021\n}","form":[]},"tests":[]},{"_id":"74ba8c58-fcff-404e-a99f-8c94a97a80a0","colId":"0637fa3f-befb-4412-846f-40000c29f99d","containerId":"","name":"UPDATE Car by ID","url":"http://0.0.0.0/api/carros/2","method":"PUT","sortNum":30000,"created":"2022-12-01T16:30:19.774Z","modified":"2022-12-01T16:37:45.779Z","headers":[],"params":[],"body":{"type":"json","raw":"{\n \"model\": \"Siena\",\n \"brand\": \"FIAT\",\n \"year\": 2017\n}","form":[]},"tests":[]},{"_id":"d8fb6645-0d3e-4bb1-a341-670a698443c6","colId":"0637fa3f-befb-4412-846f-40000c29f99d","containerId":"","name":"DELETE Car by ID","url":"http://0.0.0.0/api/carros/3","method":"DELETE","sortNum":40000,"created":"2022-12-01T16:39:35.990Z","modified":"2022-12-01T16:39:52.884Z","headers":[],"params":[],"tests":[]}]}
18 changes: 18 additions & 0 deletions crud_car/backend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
58 changes: 58 additions & 0 deletions crud_car/backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
11 changes: 11 additions & 0 deletions crud_car/backend/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
18 changes: 18 additions & 0 deletions crud_car/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
66 changes: 66 additions & 0 deletions crud_car/backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>

<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>

## About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).

Laravel is accessible, powerful, and provides tools required for large, robust applications.

## Learning Laravel

Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.

If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

## Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).

### Premium Partners

- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**

## Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).

## Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).

## Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.

## License

The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
32 changes: 32 additions & 0 deletions crud_car/backend/app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
50 changes: 50 additions & 0 deletions crud_car/backend/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];

/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];

/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}
Loading