Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.
Open

teste #122

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
1 change: 1 addition & 0 deletions .docker/cronjobs/crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* * * * * root php /usr/share/nginx/artisan schedule:run >> /var/log/cron.log 2>&1
1 change: 1 addition & 0 deletions .docker/cronjobs/crontabs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* * * * * root php /usr/share/nginx/artisan schedule:run >/var/log/gustavoppk 2>&1
33 changes: 33 additions & 0 deletions .docker/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/public;

charset utf-8;

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

access_log off;
error_log /usr/share/nginx/malte.italoborg.es-error.log error;
error_page 404 /index.php;
sendfile off;

# Point index to the Laravel front controller.
index index.php;

location ~ \.php$ {
try_files $uri $uri/ /index.php?$query_string;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}

location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

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

[*.md]
trim_trailing_whitespace = false

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

[docker-compose.yml]
indent_size = 4
52 changes: 52 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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=pgsql
DB_HOST=testdb
DB_PORT=5432
DB_DATABASE=afiliadomax
DB_USERNAME=afiliadomax
DB_PASSWORD='maximize#1'

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="[email protected]"
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_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* 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
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.idea
/.vscode
12 changes: 12 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
php:
preset: laravel
disabled:
- no_unused_imports
finder:
not-name:
- index.php
js:
finder:
not-name:
- webpack.mix.js
css: true
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# Desafio técnico para desenvolvedores
## Definição de Estruturas foi feita

Construa uma nova aplicação, utilizando o framework de sua preferência (Ruby on Rails, Elixir Phoenix, Python Django ou Flask, NodeJS Sails, Java Spring, ASP.NET ou outro), a qual deverá conectar na API do GitHub e disponibilizar as seguintes funcionalidades:
- Docker/Compose.
- PHP 8.1.
- AngularJS.
- Banco Dados - PostgreSQL.
- Laravel 9x.
- DDD (driven domain design) - App\Domain

- Botão para buscar e armazenar os repositórios destaques de 5 linguagens à sua escolha;
- Listar os repositórios encontrados;
- Visualizar os detalhes de cada repositório.
## Como Instalar - Passos a Passos

Alguns requisitos:
- 1 - Faça um clone nesse projeto - [git clone https://github.com/gustavossouza/teste.git]
- 2 - Inicialize o docker utilizando nesse comando [docker-compose up -d --build] e aguarde...
- 3 - Agora iremos entrar dentro da imagem para usar terminal [docker exec -it testapi sh] e aguarde...
- 4 - Agora iremos navegar até a pasta do projeto [cd /usr/share/nginx] e aguarde...
- 5 - Agora iremos instalar as bibliotecas(composer) [composer install] e aguarde...
- 6 - Agora iremos criar um arquivo de variaveis [cp .env-example .env] e aguarde...
- 7 - Agora iremos criar novas tabelas para Banco Dados [php artisan migrate --seed] e aguarde...
- 8 - Agora iremos gerar uma nova key [php artisan key:generate] e aguarde...
- 9 - Agora iremos criar uma nova aba navegador favorito.. [http://localhost:8080]
- 10 - Prontinho!

- Deve ser uma aplicação totalmente nova;
- A solução deve estar em um repositório público do GitHub;
- A aplicação deve armazenar as informações encontradas;
- Utilizar PostgreSQL, MySQL ou SQL Server;
- O deploy deve ser realizado, preferencialmente, no Heroku, AWS ou no Azure;
- A aplicação precisa ter testes automatizados;
- Preferenciamente dockerizar a aplicação;
- Por favor atualizar o readme da aplicação com passo a passo com instrução para subir o ambiente.
## Rotas

Quando terminar, faça um Pull Request neste repo e avise-nos por email.

**IMPORTANTE:** se você não conseguir finalizar o teste, por favor nos diga o motivo e descreva quais foram as suas dificuldades. Você pode também sugerir uma outra abordagem para avaliarmos seus skills técnicos, vender seu peixe, mostrar-nos do que é capaz.
- [http://localhost:8080/api/github] - API Cidade
- [http://localhost:8080/api/topics] - API Grupos
32 changes: 32 additions & 0 deletions 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');
}
}
40 changes: 40 additions & 0 deletions app/Domain/Github/Controller/GithubController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Domain\Github\Controller;

use App\Domain\Github\Service\GithubService;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class GithubController extends Controller
{
private GithubService $service;

public function __construct(GithubService $githubService)
{
$this->service = $githubService;
}

public function index(Request $request): JsonResponse
{
try {
$request->validate([
'topics' => 'required|exists:topics,name'
], [
'topics.required' => "O campo tópico é obrigatório",
'topics.exists' => "Tópico incorreto",
]);

return response()->json([
'data' => $this->service->listRepository($request->get('topics'))
], Response::HTTP_OK);

} catch (\Exception $e) {
return response()->json([
'errors' => $e->getMessage()
], Response::HTTP_BAD_GATEWAY);
}
}
}
49 changes: 49 additions & 0 deletions app/Domain/Github/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App\Domain\Github\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/github';

/**
* Define your route model bindings, pattern filters, and other route configuration.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();

$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('app/Domain/Github/routes/api.php'));
});
}

/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
}
30 changes: 30 additions & 0 deletions app/Domain/Github/Service/GithubService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Domain\Github\Service;

use GrahamCampbell\GitHub\GitHubManager;

class GithubService
{
private GitHubManager $github;

public function __construct(GitHubManager $github)
{
$this->github = $github;
}

public function button()
{

}

public function listRepository(string $programming): array
{
return $this->github->search()->repositories($programming, null);
}

public function viewRepository()
{

}
}
8 changes: 8 additions & 0 deletions app/Domain/Github/routes/api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use App\Domain\Github\Controller\GithubController;
use Illuminate\Support\Facades\Route;

Route::controller(GithubController::class)->group(function () {
Route::get('/github', 'index');
});
25 changes: 25 additions & 0 deletions app/Domain/Topics/Controller/TopicsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Domain\Topics\Controller;

use App\Domain\Topics\Service\TopicsService;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;

class TopicsController extends Controller
{
private TopicsService $service;

public function __construct(TopicsService $githubService)
{
$this->service = $githubService;
}

public function index(): JsonResponse
{
return response()->json([
'data' => $this->service->get()
], Response::HTTP_OK);
}
}
Loading