Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend and Frontend #17

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
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
84 changes: 84 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/api/node_modules
/api/public/hot
/api/public/storage
/api/storage/*.key
/api/vendor
/api/.env
/api/.env.backup
/api/.phpunit.result.cache
/api/docker-compose.override.yml
/api/Homestead.json
/api/Homestead.yaml
/api/npm-debug.log
/api/yarn-error.log
/api/.idea
/api/.vscode

# compiled output
/app/dist
/app/tmp
/app/out-tsc
# Only exists if Bazel was run
/app/bazel-out

# dependencies
/app/node_modules

# profiling files
/app/chrome-profiler-events*.json
/app/speed-measure-plugin*.json

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

# IDE - VSCode
/app/.vscode/*
/app/!.vscode/settings.json
/app/!.vscode/tasks.json
/app/!.vscode/launch.json
/app/!.vscode/extensions.json
/app/.history/*

# misc
/app/.sass-cache
/app/connect.lock
/app/coverage
/app/libpeerconnection.log
/app/npm-debug.log
/app/yarn-error.log
/app/testem.log
/app/typings

# System Files
/app/.DS_Store
/app/Thumbs.db



# dependencies
/app/node_modules
/app/.pnp
/app/.pnp.js

# testing
/app/coverage

# production
/app/build

# misc
/app/.DS_Store
/app/.env.local
/app/.env.development.local
/app/.env.test.local
/app/.env.production.local

/app/npm-debug.log*
/app/yarn-debug.log*
/app/yarn-error.log*
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# README #


## API ##

### Criar .env dentro da pasta api com os dados abaixo ###

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=trabalhe-na-mad
DB_USERNAME=postgres
DB_PASSWORD=1234

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=seu@email
MAIL_PASSWORD=sua@senha // Deve ser um hash gerado a partir das configuracoes do email
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

### Após ter certeza que o projeto está devidamente configurado com banco, rodar os comandos abaixo ###

* php artisan migrate
* php artisan db:seed
* php artisan serve

## APP ##

### Entrar na pasta app e executar o comando abaixo ###

* npm install
* npm start
18 changes: 18 additions & 0 deletions api/.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 api/.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=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_DRIVER=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=null
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}"
5 changes: 5 additions & 0 deletions api/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
14 changes: 14 additions & 0 deletions api/.styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
php:
preset: laravel
version: 8
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
32 changes: 32 additions & 0 deletions api/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');
}
}
41 changes: 41 additions & 0 deletions api/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Exceptions;

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

class Handler extends ExceptionHandler
{
/**
* 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 for 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) {
//
});
}
}
24 changes: 24 additions & 0 deletions api/app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Controllers;

use App\Services\CategoryService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class CategoryController extends Controller
{
private $categoryService;

public function __construct(CategoryService $categoryService)
{
$this->categoryService = $categoryService;
}

public function index(): JsonResponse
{
$list = $this->categoryService->getAll();
return response()->json($list, Response::HTTP_OK);
}
}
24 changes: 24 additions & 0 deletions api/app/Http/Controllers/CepController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Controllers;

use App\Services\CepService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class CepController extends Controller
{
private $cepService;

public function __construct(CepService $cepService)
{
$this->cepService = $cepService;
}

public function getAddress(int $cep): JsonResponse
{
$address = $this->cepService->getAddress($cep);
return response()->json($address, Response::HTTP_OK);
}
}
13 changes: 13 additions & 0 deletions api/app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
42 changes: 42 additions & 0 deletions api/app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Http\Controllers;

use App\Http\Requests\UserRequest;
use App\Services\UserService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;

class UserController extends Controller
{
private $userService;

public function __construct(UserService $userService)
{
$this->userService = $userService;
}

public function index(): JsonResponse
{
$list = $this->userService->getAll();
return response()->json($list, Response::HTTP_OK);
}

public function store(UserRequest $request): JsonResponse
{
$this->userService->create($request->all());
return response()->json(Response::HTTP_CREATED);
}

public function emailIsUnique(string $email): JsonResponse
{
$validation = $this->userService->emailIsUnique($email);
return response()->json($validation, Response::HTTP_OK);
}

public function cpfIsValid(string $cpf): JsonResponse
{
$validation = $this->userService->cpfIsValid($cpf);
return response()->json($validation, Response::HTTP_OK);
}
}
Loading