2018-04-21 12:59:48 +05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once __DIR__.'/../vendor/autoload.php';
|
|
|
|
|
|
|
|
try {
|
|
|
|
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
|
|
|
|
} catch (Dotenv\Exception\InvalidPathException $e) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Defines
|
|
|
|
*/
|
2018-08-11 21:34:36 +02:00
|
|
|
define('BLACKLIST_PATH', __DIR__.'/../storage/app/blacklist.json');
|
2018-04-21 12:59:48 +05:00
|
|
|
define('RATE_LIMIT', 5000); // per day
|
2018-04-23 17:24:04 +05:00
|
|
|
define('CACHE_EXPIRE', 3600 * 24 * 3); // 3 days
|
|
|
|
define('CACHE_EXPIRE_SEARCH', 3600 * 6); // 6 hours
|
|
|
|
//define('CACHE_EXPIRE', 4); // 60 seconds | dev
|
|
|
|
//define('CACHE_EXPIRE_SEARCH', 4); // 60 seconds | dev
|
2018-04-21 12:59:48 +05:00
|
|
|
|
2018-08-10 19:58:13 +05:00
|
|
|
define('REST_VERSION', '3.0');
|
|
|
|
define('SOURCE_VERSION', '2.0.0-rc.1');
|
2018-04-21 12:59:48 +05:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Create The Application
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Here we will load the environment and create the application instance
|
|
|
|
| that serves as the central piece of this framework. We'll use this
|
|
|
|
| application as an "IoC" container and router for this framework.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
$app = new Laravel\Lumen\Application(
|
|
|
|
realpath(__DIR__.'/../')
|
|
|
|
);
|
|
|
|
|
2018-08-16 02:29:25 +05:00
|
|
|
$app->withFacades();
|
|
|
|
$app->withEloquent();
|
2018-04-21 12:59:48 +05:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Register Container Bindings
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Now we will register a few bindings in the service container. We will
|
|
|
|
| register the exception handler and the console kernel. You may add
|
|
|
|
| your own bindings here if you like or you can make another file.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
$app->singleton(
|
|
|
|
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
|
|
|
App\Exceptions\Handler::class
|
|
|
|
);
|
|
|
|
|
|
|
|
$app->singleton(
|
|
|
|
Illuminate\Contracts\Console\Kernel::class,
|
|
|
|
App\Console\Kernel::class
|
|
|
|
);
|
|
|
|
|
2018-08-12 02:45:26 +05:00
|
|
|
$app->singleton(
|
|
|
|
\Jikan\MyAnimeList\MalClient::class,
|
|
|
|
function () {
|
|
|
|
return new \Jikan\MyAnimeList\MalClient();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2018-04-21 12:59:48 +05:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Register Middleware
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Next, we will register the middleware with the application. These can
|
|
|
|
| be global middleware that run before and after each request into a
|
|
|
|
| route or middleware that'll be assigned to some specific routes.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*$app->middleware([App\Http\Middleware\Meta::class]);
|
|
|
|
$app->middleware([App\Http\Middleware\Throttle::class]);*/
|
|
|
|
|
|
|
|
// $app->routeMiddleware([
|
|
|
|
// 'auth' => App\Http\Middleware\Authenticate::class,
|
|
|
|
// ]);
|
|
|
|
|
2018-08-16 02:29:25 +05:00
|
|
|
$app->routeMiddleware([
|
|
|
|
'blacklist' => App\Http\Middleware\Blacklist::class,
|
|
|
|
'meta' => App\Http\Middleware\Meta::class,
|
2018-08-17 19:58:11 +02:00
|
|
|
'redis-cache' => App\Http\Middleware\RedisCache::class,
|
2018-08-16 02:29:25 +05:00
|
|
|
'throttle' => App\Http\Middleware\Throttle::class,
|
|
|
|
]);
|
2018-04-21 12:59:48 +05:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Register Service Providers
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Here we will register all of the application's service providers which
|
|
|
|
| are used to bind services into the container. Service providers are
|
|
|
|
| totally optional, so you are not required to uncomment this line.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2018-08-17 19:58:11 +02:00
|
|
|
$app->register(Illuminate\Redis\RedisServiceProvider::class);
|
2018-04-21 12:59:48 +05:00
|
|
|
|
|
|
|
// $app->register(App\Providers\AppServiceProvider::class);
|
|
|
|
// $app->register(App\Providers\AuthServiceProvider::class);
|
|
|
|
// $app->register(App\Providers\EventServiceProvider::class);
|
|
|
|
|
2018-08-16 02:29:25 +05:00
|
|
|
|
2018-04-21 12:59:48 +05:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Load The Application Routes
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Next we will include the routes file so that they can all be added to
|
|
|
|
| the application. This will provide all of the URLs the application
|
|
|
|
| can respond to, as well as the controllers that may handle them.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2018-08-11 21:34:36 +02:00
|
|
|
$app->router->group(
|
|
|
|
[
|
2018-08-16 00:46:27 +05:00
|
|
|
'prefix' => 'v3',
|
|
|
|
'namespace' => 'App\Http\Controllers\V3',
|
2018-08-17 19:58:11 +02:00
|
|
|
'middleware' => ['redis-cache', 'throttle']
|
2018-08-16 00:46:27 +05:00
|
|
|
],
|
|
|
|
function ($router) {
|
|
|
|
require __DIR__.'/../routes/web.v3.php';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$app->router->group(
|
|
|
|
[
|
|
|
|
'prefix' => 'v2',
|
|
|
|
'namespace' => 'App\Http\Controllers\V2',
|
2018-08-17 19:58:11 +02:00
|
|
|
'middleware' => ['redis-cache', 'throttle']
|
2018-08-11 21:34:36 +02:00
|
|
|
],
|
|
|
|
function ($router) {
|
2018-08-16 00:46:27 +05:00
|
|
|
require __DIR__.'/../routes/web.v2.php';
|
2018-08-11 21:34:36 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-08-17 13:43:08 +05:00
|
|
|
$app->router->group(
|
|
|
|
[
|
|
|
|
'prefix' => '/',
|
|
|
|
'namespace' => 'App\Http\Controllers\V2',
|
2018-08-17 19:58:11 +02:00
|
|
|
'middleware' => ['redis-cache', 'throttle']
|
2018-08-17 13:43:08 +05:00
|
|
|
],
|
|
|
|
function ($router) {
|
|
|
|
require __DIR__.'/../routes/web.v2.php';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$app->router->group(
|
|
|
|
[
|
|
|
|
'prefix' => 'v1',
|
|
|
|
],
|
|
|
|
function ($router) {
|
|
|
|
$router->get('/', function () {
|
|
|
|
return response()->json([
|
|
|
|
'error' => 'This version is depreciated'
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-04-21 12:59:48 +05:00
|
|
|
|
|
|
|
return $app;
|