mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
216 lines
8.5 KiB
PHP
216 lines
8.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Create The Application
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| The first thing we will do is create a new Laravel application instance
|
|
| which serves as the "glue" for all the components of Laravel, and is
|
|
| the IoC container for the system binding all of the various parts.
|
|
|
|
|
*/
|
|
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
use Illuminate\Support\Facades\Route;
|
|
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
|
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
use Illuminate\Auth\AuthenticationException;
|
|
|
|
return Application::configure(basePath: dirname(__DIR__))
|
|
->withRouting(
|
|
web: __DIR__ . '/../routes/web.php',
|
|
api: __DIR__ . '/../routes/api.php',
|
|
commands: __DIR__ . '/../routes/console.php',
|
|
health: '/up',
|
|
then: function () {
|
|
Route::prefix('public/api')
|
|
->middleware('apipub')
|
|
->group(base_path('routes/apipub.php'));
|
|
},
|
|
)
|
|
|
|
->withMiddleware(function (Middleware $middleware) {
|
|
// '*' trusts all proxies, required for correct IP/HTTPS detection behind AWS ALB/Vapor
|
|
$middleware->trustProxies(at: '*');
|
|
|
|
$middleware->web(append: [
|
|
\App\Http\Middleware\LogRequestPathMiddleware::class,
|
|
]);
|
|
|
|
$middleware->api(append: [
|
|
\App\Http\Middleware\LogRequestPathMiddleware::class,
|
|
]);
|
|
|
|
$middleware->api(prepend: [
|
|
'throttle:300,1',
|
|
]);
|
|
|
|
$middleware->validateCsrfTokens(except: [
|
|
'move-order/api/move',
|
|
]);
|
|
|
|
$middleware->alias([
|
|
'valid.token' => \App\Http\Middleware\ValidateToken::class,
|
|
'token.check' => \App\Http\Middleware\TokenCheckerMiddleware::class,
|
|
'auth.check' => \App\Http\Middleware\CheckAuthorizationMiddleware::class,
|
|
'storage.invoice.check.byorder' => \App\Http\Middleware\CheckForStorageInvoiceByOrderId::class,
|
|
'storage.invoice.check.bytransaction' => \App\Http\Middleware\CheckForStorageInvoiceByTransactionId::class,
|
|
'storage.invoice.check.bytransactions' => \App\Http\Middleware\CheckForStorageInvoiceByTransactions::class,
|
|
'storage.invoice.check.bygroup' => \App\Http\Middleware\CheckForStorageInvoiceByGroup::class,
|
|
'storage.invoice.check.bypackinglists' => \App\Http\Middleware\CheckForStorageInvoiceByPackingLists::class,
|
|
'admin' => \App\Http\Middleware\EnsureUserIsAdmin::class,
|
|
]);
|
|
|
|
$middleware->appendToGroup('apipub', [
|
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
|
\App\Http\Middleware\LogRequestPathMiddleware::class,
|
|
]);
|
|
|
|
|
|
})
|
|
->withExceptions(function (Exceptions $exceptions) {
|
|
$exceptions->render(function (AuthenticationException $e, $request) {
|
|
if ($request->expectsJson()) {
|
|
return (new ApiResponseObject('Authentication', 'To keep your account secure, we need to re-validate it.', HttpStatus::ACCESS_UNAUTHORISED))->handler();
|
|
}
|
|
});
|
|
|
|
// Don't flash these inputs
|
|
$exceptions->dontFlash([
|
|
'password',
|
|
'password_confirmation',
|
|
]);
|
|
|
|
// $exceptions->render(function (MaintenanceModeException $e, $request) {
|
|
// return response()->view('pages.errors.maintenance');
|
|
// });
|
|
})
|
|
->withCommands([
|
|
__DIR__ . '/../app/Console/Commands',
|
|
__DIR__ . '/../app/Console/Commands/V2',
|
|
])
|
|
->withSchedule(function (Schedule $schedule) {
|
|
//Commands Version 2: Laravel Vapor with AWS
|
|
$isEnabled = env('COMMANDS_V2_ENABLED', false);
|
|
if ($isEnabled) {
|
|
// $schedule->command('dummy-command')
|
|
// ->everyFiveMinutes()
|
|
// ->withoutOverlapping();
|
|
|
|
$schedule->command('housekeeping-s3-files-command')
|
|
->dailyAt('01:00')
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('password-reset-token-expriration-check-command')
|
|
->everySixHours()
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('new-user-registration-expire-check-command')
|
|
->everySixHours()
|
|
->withoutOverlapping();
|
|
|
|
if (env('APP_ENV') === 'production') {
|
|
$schedule->command('curl-vt-command')
|
|
->cron('0 8 * * *')
|
|
->withoutOverlapping();
|
|
|
|
// $schedule->command('curl-yd-order-list-command')
|
|
// ->cron('0 9-18/3 * * *')
|
|
// ->withoutOverlapping();
|
|
|
|
$schedule->command('process-yd-by-traking-no-data-command')
|
|
->cron('0 8,11,14,17 * * *')
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('process-yd-portal-data-command')
|
|
->cron('0 9,12,15,18 * * *') //->cron('0 9-18/3 * * *')
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('fix-packinglist-command')
|
|
->cron('30 9-18/3 * * *')
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('fix-duplicate-container-reference-command')
|
|
->cron('0 1 * * *')
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('invoice-generate-command')
|
|
// ->hourly()
|
|
->cron('0 0-8,10-11,13-14,16-17,19-23 * * *')
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('billplz-failed-callback-fix-command')
|
|
->hourly()
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('check-storage-invoices-group-transactions-command')
|
|
->dailyAt('0:01')
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('permits-reminder-send-command')
|
|
->dailyAt('09:30')
|
|
->withoutOverlapping();
|
|
|
|
$schedule->command('process-delayed-jobs-command')
|
|
->everyFiveMinutes()
|
|
->withoutOverlapping();
|
|
} elseif (env('APP_ENV') === 'development') {
|
|
$schedule->command('process-delayed-jobs-command')
|
|
->everyTwoHours()
|
|
->withoutOverlapping();
|
|
}
|
|
}
|
|
//Commands Version 1: Before AWS
|
|
else {
|
|
$schedule->command('command:curlVTCommand')
|
|
->cron('0 8 * * *')
|
|
->withoutOverlapping()
|
|
->appendOutputTo(storage_path() . '/logs/curlvt.log');
|
|
|
|
$schedule->command('command:curlYdOrderListCommand')
|
|
->cron('0 9-18/3 * * *')
|
|
->withoutOverlapping()
|
|
->appendOutputTo(storage_path() . '/logs/curlyd.log');
|
|
|
|
$schedule->command('fix-packinglist')
|
|
->cron('30 9-18/3 * * *')
|
|
->withoutOverlapping()
|
|
->appendOutputTo(storage_path() . '/logs/fix_packinglist.log');
|
|
|
|
// $schedule->command('command:curlYdOrderListCommand')
|
|
// ->cron('0 9 * * *')
|
|
// ->withoutOverlapping()
|
|
// ->appendOutputTo(storage_path().'/logs/departure_email.log');
|
|
|
|
$schedule->command('fix-duplicate-container-reference')
|
|
->cron('0 1 * * *')
|
|
->withoutOverlapping()
|
|
->appendOutputTo(storage_path() . '/logs/fix_duplicate_container_reference.log');
|
|
|
|
$schedule->command('invoice:generate')
|
|
->hourly()
|
|
->withoutOverlapping()
|
|
->appendOutputTo(storage_path() . '/logs/auto_generate_invoice.log');
|
|
|
|
$schedule->command('billplz-failed-callback:fix')
|
|
->hourly()
|
|
->withoutOverlapping()
|
|
->appendOutputTo(storage_path() . '/logs/fix_failed_callback_from_billplz.log');
|
|
|
|
$schedule->command('check-storage-invoices-group-transactions')
|
|
->dailyAt('0:01')
|
|
->withoutOverlapping()
|
|
->appendOutputTo(storage_path() . '/logs/check_storage_invoices.log');
|
|
|
|
$schedule->command('permitsReminder:send')
|
|
->dailyAt('09:30')
|
|
->withoutOverlapping()
|
|
->appendOutputTo(storage_path() . '/logs/permits-reminder-send.log');
|
|
}
|
|
})
|
|
->create();
|