Skip to content

Commit c621f5e

Browse files
web api v1
0 parents  commit c621f5e

File tree

186 files changed

+21046
-0
lines changed

Some content is hidden

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

186 files changed

+21046
-0
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.git*
2+
/.idea*
3+
.dockerignore
4+
.editorconfig
5+
vendor/
6+
node_modules
7+
.phpstorm.meta.php
8+
Dockerfile
9+
docker-compose.yaml

.editorconfig

Lines changed: 18 additions & 0 deletions
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}]
15+
indent_size = 2
16+
17+
[docker-compose.yaml]
18+
indent_size = 2

.env.ci

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost:8000
6+
7+
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
DB_CONNECTION=sqlite
12+
DB_HOST=
13+
DB_PORT=
14+
DB_DATABASE=
15+
DB_USERNAME=
16+
DB_PASSWORD=
17+
18+
BROADCAST_DRIVER=log
19+
CACHE_DRIVER=file
20+
FILESYSTEM_DISK=local
21+
QUEUE_CONNECTION=sync
22+
SESSION_DRIVER=file
23+
SESSION_LIFETIME=120
24+
25+
MEMCACHED_HOST=127.0.0.1
26+
27+
REDIS_HOST=127.0.0.1
28+
REDIS_PASSWORD=null
29+
REDIS_PORT=6379
30+
31+
MAIL_MAILER=smtp
32+
MAIL_HOST=mailpit
33+
MAIL_PORT=1025
34+
MAIL_USERNAME=null
35+
MAIL_PASSWORD=null
36+
MAIL_ENCRYPTION=null
37+
MAIL_FROM_ADDRESS="hello@example.com"
38+
MAIL_FROM_NAME="${APP_NAME}"
39+
40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
45+
46+
PUSHER_APP_ID=
47+
PUSHER_APP_KEY=
48+
PUSHER_APP_SECRET=
49+
PUSHER_HOST=
50+
PUSHER_PORT=443
51+
PUSHER_SCHEME=https
52+
PUSHER_APP_CLUSTER=mt1
53+
54+
VITE_APP_NAME="${APP_NAME}"
55+
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
56+
VITE_PUSHER_HOST="${PUSHER_HOST}"
57+
VITE_PUSHER_PORT="${PUSHER_PORT}"
58+
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
59+
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.example

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost:8000
6+
7+
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
DB_CONNECTION=mysql
12+
DB_HOST=db
13+
DB_PORT=3306
14+
DB_DATABASE={YOUR_DATABASE}
15+
DB_USERNAME={YOUR_USERNAME}
16+
DB_PASSWORD={YOUR_PASSWORD}
17+
18+
BROADCAST_DRIVER=log
19+
CACHE_DRIVER=file
20+
FILESYSTEM_DISK=local
21+
QUEUE_CONNECTION=sync
22+
SESSION_DRIVER=file
23+
SESSION_LIFETIME=120
24+
25+
MEMCACHED_HOST=127.0.0.1
26+
27+
REDIS_HOST=127.0.0.1
28+
REDIS_PASSWORD=null
29+
REDIS_PORT=6379
30+
31+
MAIL_MAILER=smtp
32+
MAIL_HOST=mailpit
33+
MAIL_PORT=1025
34+
MAIL_USERNAME=null
35+
MAIL_PASSWORD=null
36+
MAIL_ENCRYPTION=null
37+
MAIL_FROM_ADDRESS="hello@example.com"
38+
MAIL_FROM_NAME="${APP_NAME}"
39+
40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
45+
46+
PUSHER_APP_ID=
47+
PUSHER_APP_KEY=
48+
PUSHER_APP_SECRET=
49+
PUSHER_HOST=
50+
PUSHER_PORT=443
51+
PUSHER_SCHEME=https
52+
PUSHER_APP_CLUSTER=mt1
53+
54+
VITE_APP_NAME="${APP_NAME}"
55+
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
56+
VITE_PUSHER_HOST="${PUSHER_HOST}"
57+
VITE_PUSHER_PORT="${PUSHER_PORT}"
58+
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
59+
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
60+
61+
SANCTUM_STATEFUL_DOMAINS=http://localhost:3000

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/.phpunit.cache
2+
/node_modules
3+
/public/build
4+
/public/hot
5+
/public/storage
6+
/storage/*.key
7+
/vendor
8+
.env
9+
.env.backup
10+
.env.production
11+
.phpunit.result.cache
12+
Homestead.json
13+
Homestead.yaml
14+
auth.json
15+
npm-debug.log
16+
yarn-error.log
17+
/.fleet
18+
/.idea
19+
/.vscode
20+
.docker
21+
.scribe

Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM php:8.1-fpm
2+
3+
# set your user name
4+
ARG user=victor
5+
ARG uid=1000
6+
7+
# Install system dependencies
8+
RUN apt-get update && apt-get install -y \
9+
git \
10+
curl \
11+
libpng-dev \
12+
libonig-dev \
13+
libxml2-dev \
14+
zip \
15+
unzip
16+
17+
# Clear cache
18+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
19+
20+
# Install PHP extensions
21+
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd sockets
22+
23+
# Install PHP Xdebug
24+
RUN pecl install -o -f xdebug \
25+
&& docker-php-ext-enable xdebug
26+
27+
# Get latest Composer
28+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
29+
30+
# Create system user to run Composer and Artisan Commands
31+
RUN useradd -G www-data,root -u $uid -d /home/$user $user
32+
RUN mkdir -p /home/$user/.composer && \
33+
chown -R $user:$user /home/$user
34+
35+
# Copy custom configurations PHP
36+
COPY docker/php/php.ini /usr/local/etc/php/
37+
38+
# Set working directory
39+
WORKDIR /var/www
40+
41+
USER $user
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class ClearCacheCommand extends Command
8+
{
9+
protected $signature = 'clear:cache';
10+
11+
protected $description = 'Clear the application cache.';
12+
13+
public function handle()
14+
{
15+
$this->call('cache:clear');
16+
$this->call('view:clear');
17+
$this->call('config:clear');
18+
$this->call('route:clear');
19+
20+
$this->info('Cache has been cleared successfully!');
21+
22+
return 0;
23+
}
24+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Enums\AchievementType;
6+
use App\Models\Achievement;
7+
use App\Models\User;
8+
use Illuminate\Console\Command;
9+
use Illuminate\Support\Facades\Validator;
10+
use Illuminate\Validation\Rule;
11+
12+
class CreateUserCommand extends Command
13+
{
14+
protected $signature = 'users:create';
15+
16+
protected $description = 'Command to create a user.';
17+
18+
public function handle()
19+
{
20+
$user['name'] = $this->ask('Name of the new user');
21+
$user['email'] = $this->ask('Email of the new user');
22+
$user['password'] = $this->secret('Password of the new user');
23+
24+
$user['role'] = $this->choice('Role of the new user', ['USER', 'ADMIN'], 0);
25+
26+
$validator = Validator::make(
27+
$user,
28+
[
29+
'name' => ['required', 'string', 'max:255'],
30+
'email' => ['required', 'string', 'email', 'unique:users', 'max:255'],
31+
'password' => ['required', 'string', 'min:6', 'max:255'],
32+
'role' => ['required', 'string', Rule::in(['USER', 'ADMIN'])],
33+
]
34+
);
35+
36+
if ($validator->fails()) {
37+
foreach ($validator->errors()->all() as $error) {
38+
$this->error($error);
39+
}
40+
41+
return -1;
42+
}
43+
44+
$createdUser = User::create($user);
45+
46+
Achievement::create([
47+
'achievement_type' => AchievementType::READY_TO_PLAY->value,
48+
'unlocked_at' => now(),
49+
'user_id' => $createdUser->id,
50+
]);
51+
52+
$this->info("User '{$user['email']}' created successfully");
53+
54+
return 0;
55+
}
56+
}

app/Console/Kernel.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use App\Console\Commands\ClearCacheCommand;
6+
use Illuminate\Console\Scheduling\Schedule;
7+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
8+
9+
class Kernel extends ConsoleKernel
10+
{
11+
protected $commands = [
12+
ClearCacheCommand::class,
13+
];
14+
15+
protected function schedule(Schedule $schedule): void
16+
{
17+
$schedule->command('clear:cache')->daily();
18+
}
19+
20+
protected function commands(): void
21+
{
22+
$this->load(__DIR__.'/Commands');
23+
24+
require base_path('routes/console.php');
25+
}
26+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\DTO\Achievement;
4+
5+
use App\Http\Requests\Achievement\AchievementRequest;
6+
7+
class AchievementDTO
8+
{
9+
public function __construct(
10+
public readonly string $achievement_type,
11+
public readonly string $unlocked_at
12+
) {
13+
}
14+
15+
public static function fromRequest(AchievementRequest $request): self
16+
{
17+
return new self(
18+
achievement_type: $request->validated('achievement_type'),
19+
unlocked_at: $request->validated('unlocked_at')
20+
);
21+
}
22+
}

app/DTO/Auth/LoginDTO.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\DTO\Auth;
4+
5+
use App\Http\Requests\Auth\LoginRequest;
6+
7+
class LoginDTO
8+
{
9+
public function __construct(
10+
public readonly string $email,
11+
public readonly string $password
12+
) {
13+
}
14+
15+
public static function fromRequest(LoginRequest $request): self
16+
{
17+
return new self(
18+
email: $request->validated('email'),
19+
password: $request->validated('password')
20+
);
21+
}
22+
}

0 commit comments

Comments
 (0)