Skip to content

Commit 3748875

Browse files
committed
Add default API Skeleton projet
1 parent a9170f0 commit 3748875

File tree

99 files changed

+13058
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+13058
-4
lines changed

CHANGELOG.md

Whitespace-only changes.

CODE_OF_CONDUCT.md

Whitespace-only changes.

LICENSE.md

Whitespace-only changes.

README-example.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Laravel API Skeleton

SECURITY.md

Whitespace-only changes.

composer.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"laravel/framework": "^10.2",
2121
"laravel/sanctum": "^3.2.1",
2222
"laravel/tinker": "^2.8.1",
23-
"timacdonald/json-api": "v1.0.0-beta.4",
24-
"treblle/treblle-laravel": "^2.8.6"
23+
"timacdonald/json-api": "v1.0.0-beta.4"
2524
},
2625
"require-dev": {
2726
"fakerphp/faker": "^1.21.0",
@@ -32,12 +31,15 @@
3231
"nunomaduro/larastan": "^2.5.1",
3332
"pestphp/pest": "^1.22.5",
3433
"pestphp/pest-plugin-laravel": "^1.4",
35-
"spatie/laravel-ignition": "^2.0"
34+
"spatie/laravel-ignition": "^2.0",
35+
"symfony/console": "^6.3",
36+
"symfony/filesystem": "^6.3"
3637
},
3738
"autoload": {
3839
"psr-4": {
3940
"App\\": "app/",
4041
"Core\\": ".core/",
42+
"Skeleton\\": "skeleton/",
4143
"Database\\Factories\\": "database/factories/",
4244
"Database\\Seeders\\": "database/seeders/"
4345
}

composer.lock

+64-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Core\Console;
6+
7+
use Illuminate\Console\Scheduling\Schedule;
8+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
9+
10+
final class Kernel extends ConsoleKernel
11+
{
12+
protected function schedule(Schedule $schedule): void
13+
{
14+
//
15+
}
16+
17+
protected function commands(): void
18+
{
19+
$this->load(
20+
paths: [
21+
__DIR__ . '/../app/Console/Commands',
22+
],
23+
);
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Core\Exceptions;
6+
7+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8+
use Throwable;
9+
10+
final class Handler extends ExceptionHandler
11+
{
12+
protected $levels = [];
13+
14+
protected $dontReport = [];
15+
16+
protected $dontFlash = [
17+
'current_password',
18+
'password',
19+
'password_confirmation',
20+
];
21+
22+
public function register(): void
23+
{
24+
$this->reportable(function (Throwable $e) {
25+
//
26+
});
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Core\Http\Controllers;
6+
7+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
8+
use Illuminate\Foundation\Validation\ValidatesRequests;
9+
use Illuminate\Routing\Controller as BaseController;
10+
11+
abstract class Controller extends BaseController
12+
{
13+
use AuthorizesRequests;
14+
use ValidatesRequests;
15+
}
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Core\Http;
6+
7+
use App\Http\Middleware\CacheHeaders;
8+
use App\Http\Middleware\EnsureEmailIsVerified;
9+
use App\Http\Middleware\JsonApiResponseMiddleware;
10+
use App\Http\Middleware\PreventRequestsDuringMaintenance;
11+
use App\Http\Middleware\TrimStrings;
12+
use App\Http\Middleware\TrustProxies;
13+
use App\Http\Middleware\ValidateSignature;
14+
use Illuminate\Auth\Middleware\Authenticate;
15+
use Illuminate\Auth\Middleware\Authorize;
16+
use Illuminate\Auth\Middleware\RequirePassword;
17+
use Illuminate\Foundation\Http\Kernel as HttpKernel;
18+
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
19+
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
20+
use Illuminate\Http\Middleware\HandleCors;
21+
use Illuminate\Http\Middleware\SetCacheHeaders;
22+
use Illuminate\Routing\Middleware\ThrottleRequests;
23+
24+
final class Kernel extends HttpKernel
25+
{
26+
protected $middleware = [
27+
TrustProxies::class,
28+
HandleCors::class,
29+
PreventRequestsDuringMaintenance::class,
30+
ValidatePostSize::class,
31+
TrimStrings::class,
32+
ConvertEmptyStringsToNull::class,
33+
];
34+
35+
protected $middlewareGroups = [
36+
'web' => [],
37+
38+
'api' => [
39+
ThrottleRequests::class.':api',
40+
JsonApiResponseMiddleware::class,
41+
CacheHeaders::class,
42+
],
43+
];
44+
45+
protected $middlewareAliases = [
46+
'auth' => Authenticate::class,
47+
'cache.headers' => SetCacheHeaders::class,
48+
'can' => Authorize::class,
49+
'password.confirm' => RequirePassword::class,
50+
'signed' => ValidateSignature::class,
51+
'throttle' => ThrottleRequests::class,
52+
'verified' => EnsureEmailIsVerified::class,
53+
];
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Core\Providers;
6+
7+
use Illuminate\Support\ServiceProvider;
8+
9+
final class AppServiceProvider extends ServiceProvider
10+
{
11+
public function boot(): void
12+
{
13+
//
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Core\Providers;
6+
7+
use Illuminate\Auth\Notifications\ResetPassword;
8+
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
9+
10+
final class AuthServiceProvider extends ServiceProvider
11+
{
12+
protected $policies = [];
13+
14+
public function boot(): void
15+
{
16+
$this->registerPolicies();
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Core\Providers;
6+
7+
use Illuminate\Support\Facades\Broadcast;
8+
use Illuminate\Support\ServiceProvider;
9+
10+
final class BroadcastServiceProvider extends ServiceProvider
11+
{
12+
public function boot(): void
13+
{
14+
Broadcast::routes();
15+
require base_path('routes/sockets/routes.php');
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Core\Providers;
6+
7+
use Illuminate\Auth\Events\Registered;
8+
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
9+
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
10+
11+
final class EventServiceProvider extends ServiceProvider
12+
{
13+
protected $listen = [
14+
Registered::class => [
15+
SendEmailVerificationNotification::class,
16+
],
17+
];
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Core\Providers;
6+
7+
use Illuminate\Cache\RateLimiting\Limit;
8+
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
9+
use Illuminate\Http\Request;
10+
use Illuminate\Support\Facades\RateLimiter;
11+
use Illuminate\Support\Facades\Route;
12+
13+
final class RouteServiceProvider extends ServiceProvider
14+
{
15+
public function boot(): void
16+
{
17+
$this->configureRateLimiting();
18+
19+
$this->routes(static function (): void {
20+
Route::middleware('api')
21+
->as('api:')
22+
->group(
23+
base_path('routes/api/routes.php')
24+
);
25+
});
26+
}
27+
28+
protected function configureRateLimiting(): void
29+
{
30+
RateLimiter::for(
31+
name: 'api',
32+
callback: static fn (Request $request): Limit => Limit::perMinute(
33+
maxAttempts: 60,
34+
)->by(
35+
key: $request->user()?->id ?: $request->ip(),
36+
),
37+
);
38+
}
39+
}

projects/default/.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml,json}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

0 commit comments

Comments
 (0)