Skip to content

Commit

Permalink
Adiciona limite de solicitações de resposta, corrige visitor analytic…
Browse files Browse the repository at this point in the history
…s e package.json
  • Loading branch information
a21ns1g4ts committed Jun 14, 2020
1 parent 25efeac commit 2ceedbc
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 15 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Changelog

## [1.0.0] - 25/05/2020
## [1.0.0] - 31/05/2020

### Recursos adicionados

* API
* Repositórios DB e FILE
* Integração Contínua
* Política de consumo da api
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ Veja
http://localhost:8080

## API

**Importante:**

Atualmente temos uma api demonstração no seguinte endereço: https://cid10-api.herokuapp.com.
No entanto, a partir de 2021 ela será desativada e funcionará na seguinte url: https://cid.api.mokasoft.org

##### CID-10

|Nome|Descrição|Rota|Demo|
Expand Down
2 changes: 1 addition & 1 deletion app/VisitorAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class VisitorAnalytics
public static function visit(Request $request)
{
$visit = new Visitor;
$visit->ip = $request->ip();
$visit->ip = $request->getClientIp();
$visit->end_point = $request->getRequestUri();
$visit->created_at = Carbon::now();
$visit->save();
Expand Down
27 changes: 16 additions & 11 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

require_once __DIR__.'/../vendor/autoload.php';

use Illuminate\Http\Request;

Request::setTrustedProxies(
['127.0.0.1', 'REMOTE_ADDR'],
Request::HEADER_X_FORWARDED_AWS_ELB
);

(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
dirname(__DIR__)
))->bootstrap();
Expand Down Expand Up @@ -38,14 +45,10 @@
|
*/

/*register cors policy*/
$app->register(GrahamCampbell\Throttle\ThrottleServiceProvider::class);

$app->register(Fruitcake\Cors\CorsServiceProvider::class);
$app->configure('cors');
$app->middleware([
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\VisitorAnalyticsMiddleware::class
]);

$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
Expand Down Expand Up @@ -101,13 +104,14 @@
|
*/

// $app->middleware([
// App\Http\Middleware\ExampleMiddleware::class
// ]);
$app->middleware([
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\VisitorAnalyticsMiddleware::class
]);

// $app->routeMiddleware([
// 'auth' => App\Http\Middleware\Authenticate::class,
// ]);
$app->routeMiddleware([
'throttle' => GrahamCampbell\Throttle\Http\Middleware\ThrottleMiddleware::class,
]);

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -137,6 +141,7 @@

$app->router->group([
'namespace' => 'App\Http\Controllers',
'middleware' => env('APP_THROTTLE') ? 'throttle:60,3' : null
], function ($router) {
require __DIR__.'/../routes/web.php';
require __DIR__.'/../routes/api.php';
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Atiladanvi/cid-api-php",
"name": "atiladanvi/cid-api-php",
"description": "Api com todas as doenças catalogadas pela OMS.",
"authors": [
{
Expand All @@ -14,6 +14,7 @@
"php": "^7.2.5",
"ext-json": "*",
"fruitcake/laravel-cors": "^2.0",
"graham-campbell/throttle": "^8.0",
"laravel/lumen-framework": "^7.0"
},
"require-dev": {
Expand Down
79 changes: 78 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ceedbc

Please sign in to comment.