├── .gitignore ├── customer_service ├── .docker │ └── nginx │ │ ├── Dockerfile │ │ └── nginx.conf ├── .editorconfig ├── .env ├── .env.example ├── .gitattributes ├── .gitignore ├── .styleci.yml ├── Dockerfile ├── app │ ├── Console │ │ ├── Commands │ │ │ ├── KafkaConsumer.php │ │ │ └── KafkaProducerSeeder.php │ │ └── Kernel.php │ ├── Exceptions │ │ └── Handler.php │ ├── Http │ │ ├── Controllers │ │ │ ├── Auth │ │ │ │ ├── ConfirmPasswordController.php │ │ │ │ ├── ForgotPasswordController.php │ │ │ │ ├── LoginController.php │ │ │ │ ├── RegisterController.php │ │ │ │ ├── ResetPasswordController.php │ │ │ │ └── VerificationController.php │ │ │ └── Controller.php │ │ ├── Kernel.php │ │ └── Middleware │ │ │ ├── Authenticate.php │ │ │ ├── CheckForMaintenanceMode.php │ │ │ ├── EncryptCookies.php │ │ │ ├── RedirectIfAuthenticated.php │ │ │ ├── TrimStrings.php │ │ │ ├── TrustProxies.php │ │ │ └── VerifyCsrfToken.php │ ├── Kafka │ │ └── OrderHandler.php │ ├── Models │ │ ├── Customer.php │ │ ├── Order.php │ │ ├── OrderItem.php │ │ ├── Product.php │ │ ├── Traits │ │ │ └── Uuid.php │ │ └── User.php │ ├── Nova │ │ ├── Customer.php │ │ ├── Order.php │ │ ├── OrderItem.php │ │ ├── Product.php │ │ ├── Resource.php │ │ └── User.php │ ├── Observers │ │ └── KafkaCustomerObserver.php │ ├── Policies │ │ ├── OrderItemPolicy.php │ │ ├── OrderPolicy.php │ │ └── ProductPolicy.php │ ├── Providers │ │ ├── AppServiceProvider.php │ │ ├── AuthServiceProvider.php │ │ ├── BroadcastServiceProvider.php │ │ ├── EventServiceProvider.php │ │ ├── NovaServiceProvider.php │ │ └── RouteServiceProvider.php │ └── Services │ │ └── OrderService.php ├── artisan ├── bootstrap │ ├── app.php │ └── cache │ │ └── .gitignore ├── composer.json ├── composer.lock ├── config │ ├── app.php │ ├── auth.php │ ├── broadcasting.php │ ├── cache.php │ ├── database.php │ ├── filesystems.php │ ├── hashing.php │ ├── logging.php │ ├── mail.php │ ├── nova.php │ ├── queue.php │ ├── saml2 │ │ ├── CUSTOMER_idp_settings.php │ │ └── test_idp_settings.php │ ├── saml2_settings.php │ ├── services.php │ ├── session.php │ └── view.php ├── database │ ├── .gitignore │ ├── factories │ │ └── UserFactory.php │ ├── migrations │ │ ├── 2014_10_12_000000_create_users_table.php │ │ ├── 2014_10_12_100000_create_password_resets_table.php │ │ ├── 2018_01_01_000000_create_action_events_table.php │ │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ │ ├── 2019_08_25_202953_customer.php │ │ ├── 2019_08_25_202953_product.php │ │ ├── 2019_09_05_110116_create_orders_table.php │ │ └── 2019_10_09_133938_order_item.php │ └── seeds │ │ └── DatabaseSeeder.php ├── docker-compose.yml ├── entrypoint.sh ├── package.json ├── phpunit.xml ├── public │ ├── .htaccess │ ├── favicon.ico │ ├── index.php │ ├── robots.txt │ └── web.config ├── readme.md ├── resources │ ├── js │ │ ├── app.js │ │ └── bootstrap.js │ ├── lang │ │ └── en │ │ │ ├── auth.php │ │ │ ├── pagination.php │ │ │ ├── passwords.php │ │ │ └── validation.php │ ├── sass │ │ └── app.scss │ └── views │ │ └── welcome.blade.php ├── routes │ ├── api.php │ ├── channels.php │ ├── console.php │ └── web.php ├── server.php ├── storage │ ├── app │ │ ├── .gitignore │ │ └── public │ │ │ └── .gitignore │ ├── framework │ │ ├── .gitignore │ │ ├── cache │ │ │ └── .gitignore │ │ ├── sessions │ │ │ └── .gitignore │ │ ├── testing │ │ │ └── .gitignore │ │ └── views │ │ │ └── .gitignore │ └── logs │ │ └── .gitignore ├── tests │ ├── CreatesApplication.php │ ├── Feature │ │ └── ExampleTest.php │ ├── TestCase.php │ └── Unit │ │ └── ExampleTest.php └── webpack.mix.js ├── k8s ├── customer_service │ ├── app │ │ ├── app-configmap.yaml │ │ ├── app-deployment.yaml │ │ ├── app-job.yaml │ │ └── app-service.yaml │ ├── kafka │ │ ├── helm.yaml │ │ └── kafka-client.yaml │ ├── mysql │ │ ├── mysql-deployment.yaml │ │ ├── mysql-persistent-volume-claim.yml │ │ ├── mysql-secret.yaml │ │ └── mysql-service.yaml │ └── redis │ │ └── redis-master.yaml ├── product_service │ ├── app │ │ ├── app-configmap.yaml │ │ ├── app-deployment.yaml │ │ └── app-service.yaml │ ├── kafka │ │ ├── helm.yaml │ │ └── kafka-client.yaml │ ├── mysql │ │ ├── mysql-deployment.yaml │ │ ├── mysql-persistent-volume-claim.yml │ │ ├── mysql-secret.yaml │ │ └── mysql-service.yaml │ └── redis │ │ └── redis-master.yaml └── rental_service │ ├── app │ ├── app-configmap.yaml │ ├── app-deployment.yaml │ ├── app-job-customer.yaml │ ├── app-job.yaml │ └── app-service.yaml │ ├── kafka │ ├── helm.yaml │ └── kafka-client.yaml │ ├── mysql │ ├── mysql-deployment.yaml │ ├── mysql-persistent-volume-claim.yml │ ├── mysql-secret.yaml │ └── mysql-service.yaml │ └── redis │ └── redis-master.yaml ├── kafka └── docker-compose.yml ├── product_service ├── .docker │ └── nginx │ │ ├── Dockerfile │ │ └── nginx.conf ├── .editorconfig ├── .env ├── .env.example ├── .gitattributes ├── .gitignore ├── .styleci.yml ├── Dockerfile ├── app │ ├── Console │ │ ├── Commands │ │ │ └── ProducerSeeder.php │ │ └── Kernel.php │ ├── Exceptions │ │ └── Handler.php │ ├── Http │ │ ├── Controllers │ │ │ ├── Auth │ │ │ │ ├── ConfirmPasswordController.php │ │ │ │ ├── ForgotPasswordController.php │ │ │ │ ├── LoginController.php │ │ │ │ ├── RegisterController.php │ │ │ │ ├── ResetPasswordController.php │ │ │ │ └── VerificationController.php │ │ │ └── Controller.php │ │ ├── Kernel.php │ │ └── Middleware │ │ │ ├── Authenticate.php │ │ │ ├── CheckForMaintenanceMode.php │ │ │ ├── EncryptCookies.php │ │ │ ├── RedirectIfAuthenticated.php │ │ │ ├── TrimStrings.php │ │ │ ├── TrustProxies.php │ │ │ └── VerifyCsrfToken.php │ ├── Models │ │ ├── Product.php │ │ ├── Traits │ │ │ └── Uuid.php │ │ └── User.php │ ├── Nova │ │ ├── Product.php │ │ ├── Resource.php │ │ └── User.php │ ├── Observers │ │ └── KafkaProductObserver.php │ └── Providers │ │ ├── AppServiceProvider.php │ │ ├── AuthServiceProvider.php │ │ ├── BroadcastServiceProvider.php │ │ ├── EventServiceProvider.php │ │ ├── NovaServiceProvider.php │ │ └── RouteServiceProvider.php ├── artisan ├── bootstrap │ ├── app.php │ └── cache │ │ └── .gitignore ├── composer.json ├── composer.lock ├── config │ ├── app.php │ ├── auth.php │ ├── broadcasting.php │ ├── cache.php │ ├── database.php │ ├── filesystems.php │ ├── hashing.php │ ├── logging.php │ ├── mail.php │ ├── nova.php │ ├── queue.php │ ├── saml2 │ │ ├── PRODUCT_idp_settings.php │ │ └── test_idp_settings.php │ ├── saml2_settings.php │ ├── services.php │ ├── session.php │ └── view.php ├── database │ ├── .gitignore │ ├── factories │ │ └── UserFactory.php │ ├── migrations │ │ ├── 2014_10_12_000000_create_users_table.php │ │ ├── 2014_10_12_100000_create_password_resets_table.php │ │ ├── 2018_01_01_000000_create_action_events_table.php │ │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ │ └── 2019_08_25_202953_product.php │ └── seeds │ │ └── DatabaseSeeder.php ├── docker-compose.yml ├── entrypoint.sh ├── package.json ├── phpunit.xml ├── public │ ├── .htaccess │ ├── favicon.ico │ ├── index.php │ ├── robots.txt │ └── web.config ├── readme.md ├── resources │ ├── js │ │ ├── app.js │ │ └── bootstrap.js │ ├── lang │ │ └── en │ │ │ ├── auth.php │ │ │ ├── pagination.php │ │ │ ├── passwords.php │ │ │ └── validation.php │ ├── sass │ │ └── app.scss │ └── views │ │ └── welcome.blade.php ├── routes │ ├── api.php │ ├── channels.php │ ├── console.php │ └── web.php ├── server.php ├── storage │ ├── app │ │ ├── .gitignore │ │ └── public │ │ │ └── .gitignore │ ├── framework │ │ ├── .gitignore │ │ ├── cache │ │ │ ├── .gitignore │ │ │ └── data │ │ │ │ └── .gitignore │ │ ├── sessions │ │ │ └── .gitignore │ │ ├── testing │ │ │ └── .gitignore │ │ └── views │ │ │ └── .gitignore │ └── logs │ │ └── .gitignore ├── test.txt ├── tests │ ├── CreatesApplication.php │ ├── Feature │ │ └── ExampleTest.php │ ├── TestCase.php │ └── Unit │ │ └── ExampleTest.php └── webpack.mix.js └── rental_service ├── .docker └── nginx │ ├── Dockerfile │ └── nginx.conf ├── .editorconfig ├── .env ├── .env.example ├── .gitattributes ├── .gitignore ├── .styleci.yml ├── Dockerfile ├── app ├── Console │ ├── Commands │ │ └── KafkaConsumer.php │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── Auth │ │ │ ├── ConfirmPasswordController.php │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── RegisterController.php │ │ │ ├── ResetPasswordController.php │ │ │ └── VerificationController.php │ │ └── Controller.php │ ├── Kernel.php │ └── Middleware │ │ ├── Authenticate.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php ├── Kafka │ ├── CustomerHandler.php │ └── ProductHandler.php ├── Models │ ├── Customer.php │ ├── Order.php │ ├── OrderItem.php │ ├── Payment.php │ ├── Product.php │ ├── Traits │ │ └── Uuid.php │ └── User.php ├── Nova │ ├── Customer.php │ ├── Order.php │ ├── OrderItem.php │ ├── Payment.php │ ├── Product.php │ ├── Resource.php │ └── User.php ├── Observers │ ├── OrderItemObserver.php │ ├── OrderObserver.php │ └── PaymentObserver.php ├── Policies │ ├── CustomerPolicy.php │ └── ProductPolicy.php └── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ ├── NovaServiceProvider.php │ └── RouteServiceProvider.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── database.php ├── filesystems.php ├── hashing.php ├── logging.php ├── mail.php ├── nova.php ├── queue.php ├── saml2 │ ├── RENTAL_idp_settings.php │ └── test_idp_settings.php ├── saml2_settings.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2018_01_01_000000_create_action_events_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2019_08_25_202953_customer.php │ ├── 2019_08_25_202953_product.php │ ├── 2019_09_05_110116_create_orders_table.php │ ├── 2019_10_09_133938_order_item.php │ └── 2019_10_09_133938_payment.php └── seeds │ └── DatabaseSeeder.php ├── docker-compose.yml ├── entrypoint.sh ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── favicon.ico ├── index.php ├── robots.txt └── web.config ├── readme.md ├── resources ├── js │ ├── app.js │ └── bootstrap.js ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php ├── sass │ └── app.scss └── views │ └── welcome.blade.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tests ├── CreatesApplication.php ├── Feature │ └── ExampleTest.php ├── TestCase.php └── Unit │ └── ExampleTest.php └── webpack.mix.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *vendor* 3 | customer_service/nova 4 | product_service/nova 5 | rental_service/nova 6 | *dbdata* -------------------------------------------------------------------------------- /customer_service/.docker/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.15.0-alpine 2 | RUN apk update && apk add bash 3 | 4 | RUN rm /etc/nginx/conf.d/default.conf 5 | COPY ./nginx.conf /etc/nginx/conf.d 6 | -------------------------------------------------------------------------------- /customer_service/.docker/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | index index.php index.html; 4 | root /var/www/public; 5 | 6 | location ~ \.php$ { 7 | try_files $uri = 404; 8 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 9 | fastcgi_pass localhost:9000; 10 | fastcgi_index index.php; 11 | include fastcgi_params; 12 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 13 | fastcgi_param PATH_INFO $fastcgi_path_info; 14 | } 15 | 16 | location / { 17 | try_files $uri $uri/ /index.php?$query_string; 18 | gzip_static on; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /customer_service/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /customer_service/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=laravel 13 | DB_USERNAME=root 14 | DB_PASSWORD= 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_DRIVER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | AWS_ACCESS_KEY_ID= 34 | AWS_SECRET_ACCESS_KEY= 35 | AWS_DEFAULT_REGION=us-east-1 36 | AWS_BUCKET= 37 | 38 | PUSHER_APP_ID= 39 | PUSHER_APP_KEY= 40 | PUSHER_APP_SECRET= 41 | PUSHER_APP_CLUSTER=mt1 42 | 43 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 44 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 45 | -------------------------------------------------------------------------------- /customer_service/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /customer_service/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .env.backup 8 | .phpunit.result.cache 9 | Homestead.json 10 | Homestead.yaml 11 | npm-debug.log 12 | yarn-error.log 13 | -------------------------------------------------------------------------------- /customer_service/.styleci.yml: -------------------------------------------------------------------------------- 1 | php: 2 | preset: laravel 3 | enabled: 4 | - alpha_ordered_imports 5 | disabled: 6 | - length_ordered_imports 7 | - unused_use 8 | finder: 9 | not-name: 10 | - index.php 11 | - server.php 12 | js: 13 | finder: 14 | not-name: 15 | - webpack.mix.js 16 | css: true 17 | -------------------------------------------------------------------------------- /customer_service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3.6-fpm-alpine3.9 2 | RUN apk add --no-cache openssl bash mysql-client nodejs npm alpine-sdk autoconf librdkafka-dev vim nginx openrc 3 | RUN mkdir -p /run/nginx && \ 4 | echo "pid /run/nginx.pid;" >> /etc/nginx/nginx.conf 5 | 6 | RUN docker-php-ext-install pdo pdo_mysql bcmath 7 | RUN pecl install rdkafka 8 | 9 | RUN ln -s /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini && \ 10 | echo "extension=rdkafka.so" >> /usr/local/etc/php/php.ini 11 | 12 | WORKDIR /var/www 13 | 14 | RUN rm -rf /var/www/html 15 | RUN ln -s public html 16 | 17 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 18 | 19 | RUN rm /etc/nginx/conf.d/default.conf 20 | COPY .docker/nginx/nginx.conf /etc/nginx/conf.d 21 | COPY . . 22 | RUN chmod -R 777 /var/www/storage/ 23 | 24 | EXPOSE 80 25 | ENTRYPOINT [ "/var/www/entrypoint.sh" ] 26 | -------------------------------------------------------------------------------- /customer_service/app/Console/Commands/KafkaConsumer.php: -------------------------------------------------------------------------------- 1 | argument("topic"); 43 | $group = $this->argument("group"); 44 | 45 | $configs = [ 46 | 'consumer' => [ 47 | 'enable.auto.commit' => "true", 48 | 'auto.commit.interval.ms' => "100", 49 | 'offset.store.method' => 'broker', 50 | 'auto.offset.reset' => 'largest', 51 | ] 52 | ]; 53 | 54 | $brokerCollection = $container->get("KafkaBrokerCollection"); 55 | $consumer = new \PHPEasykafka\KafkaConsumer( 56 | $brokerCollection, 57 | [$topic], 58 | $group, 59 | $configs, 60 | $container 61 | ); 62 | $this->info("Consuming topic from kafka"); 63 | $consumer->consume(120*10000, [OrderHandler::class]); 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /customer_service/app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /customer_service/app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /customer_service/app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /customer_service/app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | $this->middleware('signed')->only('verify'); 39 | $this->middleware('throttle:6,1')->only('verify', 'resend'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /customer_service/app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('saml2_login',['idpName'=>'CUSTOMER']); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /customer_service/app/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /customer_service/app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | payload); 16 | // print_r(json_decode($message->payload)); 17 | 18 | $orderService = new OrderService($payload); 19 | $orderService->insert(); 20 | // $consumer->commit(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /customer_service/app/Models/Customer.php: -------------------------------------------------------------------------------- 1 | hasMany(Order::class); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /customer_service/app/Models/Order.php: -------------------------------------------------------------------------------- 1 | 'date', 25 | 'total' => 'float', 26 | 'discount' => 'float', 27 | ]; 28 | 29 | public function items() 30 | { 31 | return $this->hasMany(OrderItem::class); 32 | } 33 | 34 | public function customer() 35 | { 36 | return $this->belongsTo(Customer::class); 37 | } 38 | 39 | public function delete() 40 | { 41 | $this->items()->delete(); 42 | return parent::delete(); 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /customer_service/app/Models/OrderItem.php: -------------------------------------------------------------------------------- 1 | 'int', 24 | 'total' => 'float' 25 | ]; 26 | 27 | public function product() 28 | { 29 | return $this->belongsTo(Product::class); 30 | } 31 | 32 | public function order() 33 | { 34 | return $this->belongsTo(Order::class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /customer_service/app/Models/Product.php: -------------------------------------------------------------------------------- 1 | id) { 14 | $obj->id = \Ramsey\Uuid\Uuid::uuid4(); 15 | } 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /customer_service/app/Models/User.php: -------------------------------------------------------------------------------- 1 | 'datetime', 38 | ]; 39 | } 40 | -------------------------------------------------------------------------------- /customer_service/app/Policies/OrderItemPolicy.php: -------------------------------------------------------------------------------- 1 | app->bind("KafkaBrokerCollection", function () { 21 | $broker = new Broker(env("KAFKA_HOST","kafka"), env("KAFKA_PORT","9092")); 22 | $kafkaBrokerCollection = new BrokerCollection(); 23 | $kafkaBrokerCollection->addBroker($broker); 24 | return $kafkaBrokerCollection; 25 | }); 26 | 27 | $this->app->bind("KafkaTopicConfig", function () { 28 | return [ 29 | 'topic' => [ 30 | 'auto.offset.reset' => 'largest' 31 | ], 32 | 'consumer' => [ 33 | 'enable.auto.commit' => "true", 34 | 'auto.commit.interval.ms' => "100", 35 | 'offset.store.method' => 'broker' 36 | ] 37 | ]; 38 | }); 39 | } 40 | 41 | /** 42 | * Bootstrap any application services. 43 | * 44 | * @return void 45 | */ 46 | public function boot() 47 | { 48 | Customer::observe(KafkaCustomerObserver::class); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /customer_service/app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | OrderPolicy::class, 23 | OrderItem::class => OrderItemPolicy::class, 24 | Product::class => ProductPolicy::class 25 | ]; 26 | 27 | /** 28 | * Register any authentication / authorization services. 29 | * 30 | * @return void 31 | */ 32 | public function boot() 33 | { 34 | $this->registerPolicies(); 35 | 36 | // 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /customer_service/app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | data = $data; 19 | } 20 | 21 | public function insert() 22 | { 23 | print_r($this->data->order); 24 | $order = Order::find($this->data->order->id); 25 | if ($order) { 26 | $order->delete(); 27 | } 28 | 29 | 30 | Order::create([ 31 | 'id' => $this->data->order->id, 32 | 'customer_id' => $this->data->order->customer_id, 33 | 'status' => $this->data->order->status, 34 | 'discount' => $this->data->order->discount, 35 | 'total' => $this->data->order->total, 36 | 'order_date' => $this->data->order->order_date, 37 | ]); 38 | 39 | foreach ($this->data->order->items as $item) { 40 | 41 | Product::firstOrCreate(['id' => $item->product->id], [ 42 | 'name' => $item->product->name, 43 | ]); 44 | 45 | OrderItem::create( 46 | [ 47 | 'id' => $item->id, 48 | 'order_id' => $item->order_id, 49 | 'product_id' => $item->product->id, 50 | 'qtd' => $item->qtd, 51 | 'total' => $item->total 52 | ] 53 | ); 54 | } 55 | 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /customer_service/bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /customer_service/bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /customer_service/config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /customer_service/config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /customer_service/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /customer_service/config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /customer_service/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.sqlite-journal 3 | -------------------------------------------------------------------------------- /customer_service/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(User::class, function (Faker $faker) { 20 | return [ 21 | 'name' => $faker->name, 22 | 'email' => $faker->unique()->safeEmail, 23 | 'email_verified_at' => now(), 24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 25 | 'remember_token' => Str::random(10), 26 | ]; 27 | }); 28 | -------------------------------------------------------------------------------- /customer_service/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /customer_service/database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /customer_service/database/migrations/2018_01_01_000000_create_action_events_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->char('batch_id', 36); 19 | $table->unsignedInteger('user_id')->index(); 20 | $table->string('name'); 21 | $table->string('actionable_type'); 22 | $table->string('actionable_id'); 23 | $table->string('target_type'); 24 | $table->string('target_id'); 25 | $table->string('model_type'); 26 | $table->string('model_id')->nullable(); 27 | $table->text('fields'); 28 | $table->string('status', 25)->default('running'); 29 | $table->text('exception'); 30 | $table->timestamps(); 31 | 32 | $table->index(['actionable_type', 'actionable_id']); 33 | $table->index(['batch_id', 'model_type', 'model_id']); 34 | }); 35 | } 36 | 37 | /** 38 | * Reverse the migrations. 39 | * 40 | * @return void 41 | */ 42 | public function down() 43 | { 44 | Schema::dropIfExists('action_events'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /customer_service/database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->text('connection'); 19 | $table->text('queue'); 20 | $table->longText('payload'); 21 | $table->longText('exception'); 22 | $table->timestamp('failed_at')->useCurrent(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('failed_jobs'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /customer_service/database/migrations/2019_08_25_202953_customer.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->string('name'); 19 | $table->string('email'); 20 | $table->string('phone'); 21 | $table->string('address')->nullable(true); 22 | $table->string('city')->nullable(true); 23 | $table->string('state')->nullable(true); 24 | $table->string('zipcode')->nullable(true); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::dropIfExists('customers'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /customer_service/database/migrations/2019_08_25_202953_product.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->string('name'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('products'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /customer_service/database/migrations/2019_09_05_110116_create_orders_table.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->uuid('customer_id'); 19 | $table->foreign('customer_id')->references("id")->on("customers"); 20 | $table->string('status'); 21 | $table->double('discount'); 22 | $table->double('total'); 23 | $table->dateTime('order_date'); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('orders'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /customer_service/database/migrations/2019_10_09_133938_order_item.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->uuid('order_id'); 19 | $table->foreign('order_id')->references("id")->on("orders"); 20 | $table->uuid('product_id'); 21 | $table->foreign('product_id')->references("id")->on("products"); 22 | $table->string('qtd'); 23 | $table->double('total'); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('order_items'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /customer_service/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /customer_service/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | customerapp: 4 | build: . 5 | volumes: 6 | - ./:/var/www 7 | depends_on: 8 | - customerapp-mysql 9 | - customerapp-redis 10 | 11 | customerapp-mysql: 12 | image: mysql:5.7.22 13 | command: --innodb-use-native-aio=0 14 | restart: always 15 | ports: 16 | - "3306" 17 | volumes: 18 | - "./.docker/dbdata:/var/lib/mysql" 19 | environment: 20 | MYSQL_DATABASE: customerapp 21 | MYSQL_ROOT_PASSWORD: root 22 | 23 | customerapp-nginx: 24 | build: ./.docker/nginx 25 | restart: always 26 | ports: 27 | - "8002:8002" 28 | volumes: 29 | - ./:/var/www 30 | depends_on: 31 | - customerapp 32 | 33 | customerapp-redis: 34 | image: redis:alpine 35 | expose: 36 | - 6379 37 | 38 | networks: 39 | default: 40 | external: 41 | name: jornada-network 42 | -------------------------------------------------------------------------------- /customer_service/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # turn on bash's job control 4 | set -m 5 | 6 | # Start the primary process and put it in the background 7 | php-fpm & 8 | 9 | # Start the helper process 10 | nginx -g 'daemon off;' 11 | 12 | # the my_helper_process might need to know how to wait on the 13 | # primary process to start before it does its work and returns 14 | 15 | 16 | # now we bring the primary process back into the foreground 17 | # and leave it there 18 | fg %1 -------------------------------------------------------------------------------- /customer_service/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "npm run development -- --watch", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.19", 14 | "cross-env": "^5.1", 15 | "laravel-mix": "^4.0.7", 16 | "lodash": "^4.17.13", 17 | "resolve-url-loader": "^2.3.1", 18 | "sass": "^1.15.2", 19 | "sass-loader": "^7.1.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /customer_service/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Unit 14 | 15 | 16 | 17 | ./tests/Feature 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /customer_service/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Handle Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /customer_service/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeedu/jornada-microservicos/15f551c45ee9ba16932ed96b72365352694fdc30/customer_service/public/favicon.ico -------------------------------------------------------------------------------- /customer_service/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /customer_service/public/web.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /customer_service/resources/js/app.js: -------------------------------------------------------------------------------- 1 | require('./bootstrap'); 2 | -------------------------------------------------------------------------------- /customer_service/resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | 3 | /** 4 | * We'll load the axios HTTP library which allows us to easily issue requests 5 | * to our Laravel back-end. This library automatically handles sending the 6 | * CSRF token as a header based on the value of the "XSRF" token cookie. 7 | */ 8 | 9 | window.axios = require('axios'); 10 | 11 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 12 | 13 | /** 14 | * Echo exposes an expressive API for subscribing to channels and listening 15 | * for events that are broadcast by Laravel. Echo and event broadcasting 16 | * allows your team to easily build robust real-time web applications. 17 | */ 18 | 19 | // import Echo from 'laravel-echo'; 20 | 21 | // window.Pusher = require('pusher-js'); 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: process.env.MIX_PUSHER_APP_KEY, 26 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 27 | // encrypted: true 28 | // }); 29 | -------------------------------------------------------------------------------- /customer_service/resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /customer_service/resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /customer_service/resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have e-mailed your password reset link!', 18 | 'token' => 'This password reset token is invalid.', 19 | 'user' => "We can't find a user with that e-mail address.", 20 | 21 | ]; 22 | -------------------------------------------------------------------------------- /customer_service/resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | // 2 | -------------------------------------------------------------------------------- /customer_service/routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 17 | return $request->user(); 18 | }); 19 | -------------------------------------------------------------------------------- /customer_service/routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /customer_service/routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /customer_service/routes/web.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 17 | 18 | Route::redirect('/nova/login/', '/', 301); 19 | -------------------------------------------------------------------------------- /customer_service/server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /customer_service/storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /customer_service/storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /customer_service/storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /customer_service/storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /customer_service/storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /customer_service/storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /customer_service/storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /customer_service/storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /customer_service/tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /customer_service/tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /customer_service/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /customer_service/webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js') 15 | .sass('resources/sass/app.scss', 'public/css'); 16 | -------------------------------------------------------------------------------- /k8s/customer_service/app/app-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: customer-app 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | app: customer-app 10 | 11 | template: 12 | metadata: 13 | labels: 14 | app: customer-app 15 | spec: 16 | containers: 17 | - name: jornada-customer 18 | image: wesleywillians/customer_jornada:latest 19 | imagePullPolicy: Always 20 | # command: ["/bin/sh", "-c", "ln -s /var/www /usr/share/nginx; php-fpm;"] 21 | ports: 22 | - containerPort: 80 23 | envFrom: 24 | - configMapRef: 25 | name: customer-app-conf 26 | env: 27 | - name: DB_PASSWORD 28 | valueFrom: 29 | secretKeyRef: 30 | name: customer-mysql-pass 31 | key: password 32 | volumeMounts: 33 | - name: customer-app-conf 34 | subPath: .env 35 | mountPath: /var/www/.env 36 | 37 | volumes: 38 | - name: customer-app-conf 39 | configMap: 40 | name: customer-app-conf 41 | items: 42 | - key: env 43 | path: .env 44 | -------------------------------------------------------------------------------- /k8s/customer_service/app/app-job.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: customer-job-consumer 5 | spec: 6 | template: 7 | spec: 8 | restartPolicy: OnFailure 9 | containers: 10 | - name: jornada-customer 11 | image: wesleywillians/customer_jornada:latest 12 | imagePullPolicy: Always 13 | command: ["php", "artisan","kafka:consume","orders","order-group"] 14 | envFrom: 15 | - configMapRef: 16 | name: customer-app-conf 17 | env: 18 | - name: DB_PASSWORD 19 | valueFrom: 20 | secretKeyRef: 21 | name: customer-mysql-pass 22 | key: password 23 | volumeMounts: 24 | - name: customer-app-conf 25 | subPath: .env 26 | mountPath: /var/www/.env 27 | 28 | volumes: 29 | - name: customer-app-conf 30 | configMap: 31 | name: customer-app-conf 32 | items: 33 | - key: env 34 | path: .env 35 | -------------------------------------------------------------------------------- /k8s/customer_service/app/app-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: customer-app-service 5 | spec: 6 | type: LoadBalancer 7 | ports: 8 | - port: 80 9 | selector: 10 | app: customer-app -------------------------------------------------------------------------------- /k8s/customer_service/kafka/helm.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: tiller 5 | namespace: kube-system 6 | --- 7 | apiVersion: rbac.authorization.k8s.io/v1 8 | kind: ClusterRoleBinding 9 | metadata: 10 | name: tiller 11 | roleRef: 12 | apiGroup: rbac.authorization.k8s.io 13 | kind: ClusterRole 14 | name: cluster-admin 15 | subjects: 16 | - kind: ServiceAccount 17 | name: tiller 18 | namespace: kube-system -------------------------------------------------------------------------------- /k8s/customer_service/kafka/kafka-client.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: kafka-client 5 | namespace: default 6 | spec: 7 | containers: 8 | - name: kafka-client 9 | image: confluentinc/cp-kafka:5.0.1 10 | command: 11 | - sh 12 | - -c 13 | - "exec tail -f /dev/null" -------------------------------------------------------------------------------- /k8s/customer_service/mysql/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 2 | kind: Deployment 3 | metadata: 4 | name: customer-mysql 5 | labels: 6 | app: customer-mysql 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app: customer-mysql 12 | strategy: 13 | type: Recreate 14 | template: 15 | metadata: 16 | labels: 17 | app: customer-mysql 18 | spec: 19 | containers: 20 | - image: mysql:5.7 21 | args: 22 | - "--ignore-db-dir=lost+found" 23 | name: mysql 24 | env: 25 | - name: MYSQL_ROOT_PASSWORD 26 | valueFrom: 27 | secretKeyRef: 28 | name: customer-mysql-pass 29 | key: password 30 | ports: 31 | - containerPort: 3306 32 | name: mysql 33 | volumeMounts: 34 | - name: mysql-persistent-storage 35 | mountPath: /var/lib/mysql 36 | volumes: 37 | - name: mysql-persistent-storage 38 | persistentVolumeClaim: 39 | claimName: mysql-customer-pv-claim -------------------------------------------------------------------------------- /k8s/customer_service/mysql/mysql-persistent-volume-claim.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: mysql-customer-pv-claim 5 | labels: 6 | app: customer 7 | spec: 8 | accessModes: 9 | - ReadWriteOnce 10 | resources: 11 | requests: 12 | storage: 20Gi -------------------------------------------------------------------------------- /k8s/customer_service/mysql/mysql-secret.yaml: -------------------------------------------------------------------------------- 1 | kubectl create secret generic customer-mysql-pass --from-literal=password='a1s2d3f4' 2 | -------------------------------------------------------------------------------- /k8s/customer_service/mysql/mysql-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: customer-mysql-service 5 | labels: 6 | app: customer-mysql 7 | spec: 8 | ports: 9 | - port: 3306 10 | selector: 11 | app: customer-mysql -------------------------------------------------------------------------------- /k8s/customer_service/redis/redis-master.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 2 | kind: Deployment 3 | metadata: 4 | name: customer-redis 5 | labels: 6 | app: customer-redis 7 | spec: 8 | selector: 9 | matchLabels: 10 | app: customer-redis 11 | replicas: 1 12 | template: 13 | metadata: 14 | labels: 15 | app: customer-redis 16 | spec: 17 | containers: 18 | - name: master 19 | image: redis 20 | ports: 21 | - containerPort: 6379 22 | 23 | --- 24 | 25 | apiVersion: v1 26 | kind: Service 27 | metadata: 28 | name: customer-redis-service 29 | labels: 30 | app: customer-redis-service 31 | spec: 32 | ports: 33 | - port: 6379 34 | targetPort: 6379 35 | selector: 36 | app: customer-redis -------------------------------------------------------------------------------- /k8s/product_service/app/app-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: product-app 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | app: product-app 10 | 11 | template: 12 | metadata: 13 | labels: 14 | app: product-app 15 | spec: 16 | containers: 17 | - name: jornada-product 18 | image: wesleywillians/product_jornada:latest 19 | imagePullPolicy: Always 20 | # command: ["/bin/sh", "-c", "ln -s /var/www /usr/share/nginx; php-fpm;"] 21 | ports: 22 | - containerPort: 80 23 | envFrom: 24 | - configMapRef: 25 | name: product-app-conf 26 | env: 27 | - name: DB_PASSWORD 28 | valueFrom: 29 | secretKeyRef: 30 | name: product-mysql-pass 31 | key: password 32 | volumeMounts: 33 | - name: product-app-conf 34 | subPath: .env 35 | mountPath: /var/www/.env 36 | 37 | volumes: 38 | - name: product-app-conf 39 | configMap: 40 | name: product-app-conf 41 | items: 42 | - key: env 43 | path: .env 44 | -------------------------------------------------------------------------------- /k8s/product_service/app/app-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: product-app-service 5 | spec: 6 | type: LoadBalancer 7 | ports: 8 | - port: 80 9 | selector: 10 | app: product-app -------------------------------------------------------------------------------- /k8s/product_service/kafka/helm.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: tiller 5 | namespace: kube-system 6 | --- 7 | apiVersion: rbac.authorization.k8s.io/v1 8 | kind: ClusterRoleBinding 9 | metadata: 10 | name: tiller 11 | roleRef: 12 | apiGroup: rbac.authorization.k8s.io 13 | kind: ClusterRole 14 | name: cluster-admin 15 | subjects: 16 | - kind: ServiceAccount 17 | name: tiller 18 | namespace: kube-system -------------------------------------------------------------------------------- /k8s/product_service/kafka/kafka-client.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: kafka-client 5 | namespace: default 6 | spec: 7 | containers: 8 | - name: kafka-client 9 | image: confluentinc/cp-kafka:5.0.1 10 | command: 11 | - sh 12 | - -c 13 | - "exec tail -f /dev/null" -------------------------------------------------------------------------------- /k8s/product_service/mysql/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 2 | kind: Deployment 3 | metadata: 4 | name: product-mysql 5 | labels: 6 | app: product-mysql 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app: product-mysql 12 | strategy: 13 | type: Recreate 14 | template: 15 | metadata: 16 | labels: 17 | app: product-mysql 18 | spec: 19 | containers: 20 | - image: mysql:5.7 21 | args: 22 | - "--ignore-db-dir=lost+found" 23 | name: mysql 24 | env: 25 | - name: MYSQL_ROOT_PASSWORD 26 | valueFrom: 27 | secretKeyRef: 28 | name: product-mysql-pass 29 | key: password 30 | ports: 31 | - containerPort: 3306 32 | name: mysql 33 | volumeMounts: 34 | - name: mysql-persistent-storage 35 | mountPath: /var/lib/mysql 36 | volumes: 37 | - name: mysql-persistent-storage 38 | persistentVolumeClaim: 39 | claimName: mysql-product-pv-claim -------------------------------------------------------------------------------- /k8s/product_service/mysql/mysql-persistent-volume-claim.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: mysql-product-pv-claim 5 | labels: 6 | app: product 7 | spec: 8 | accessModes: 9 | - ReadWriteOnce 10 | resources: 11 | requests: 12 | storage: 20Gi -------------------------------------------------------------------------------- /k8s/product_service/mysql/mysql-secret.yaml: -------------------------------------------------------------------------------- 1 | kubectl create secret generic product-mysql-pass --from-literal=password='a1s2d3f4' 2 | -------------------------------------------------------------------------------- /k8s/product_service/mysql/mysql-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: product-mysql-service 5 | labels: 6 | app: product-mysql 7 | spec: 8 | ports: 9 | - port: 3306 10 | selector: 11 | app: product-mysql -------------------------------------------------------------------------------- /k8s/product_service/redis/redis-master.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 2 | kind: Deployment 3 | metadata: 4 | name: product-redis 5 | labels: 6 | app: product-redis 7 | spec: 8 | selector: 9 | matchLabels: 10 | app: product-redis 11 | replicas: 1 12 | template: 13 | metadata: 14 | labels: 15 | app: product-redis 16 | spec: 17 | containers: 18 | - name: master 19 | image: redis 20 | ports: 21 | - containerPort: 6379 22 | 23 | --- 24 | 25 | apiVersion: v1 26 | kind: Service 27 | metadata: 28 | name: product-redis-service 29 | labels: 30 | app: product-redis-service 31 | spec: 32 | ports: 33 | - port: 6379 34 | targetPort: 6379 35 | selector: 36 | app: product-redis -------------------------------------------------------------------------------- /k8s/rental_service/app/app-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: rental-app 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | app: rental-app 10 | 11 | template: 12 | metadata: 13 | labels: 14 | app: rental-app 15 | spec: 16 | containers: 17 | - name: jornada-rental 18 | image: wesleywillians/rental_jornada:latest 19 | imagePullPolicy: Always 20 | # command: ["/bin/sh", "-c", "ln -s /var/www /usr/share/nginx; php-fpm;"] 21 | ports: 22 | - containerPort: 80 23 | envFrom: 24 | - configMapRef: 25 | name: rental-app-conf 26 | env: 27 | - name: DB_PASSWORD 28 | valueFrom: 29 | secretKeyRef: 30 | name: rental-mysql-pass 31 | key: password 32 | volumeMounts: 33 | - name: rental-app-conf 34 | subPath: .env 35 | mountPath: /var/www/.env 36 | 37 | volumes: 38 | - name: rental-app-conf 39 | configMap: 40 | name: rental-app-conf 41 | items: 42 | - key: env 43 | path: .env 44 | -------------------------------------------------------------------------------- /k8s/rental_service/app/app-job-customer.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: rental-job-consumer-customer 5 | spec: 6 | template: 7 | spec: 8 | restartPolicy: OnFailure 9 | containers: 10 | - name: jornada-rental 11 | image: wesleywillians/rental_jornada:latest 12 | imagePullPolicy: Always 13 | command: ["php", "artisan","kafka:consume","customers","customer-group"] 14 | envFrom: 15 | - configMapRef: 16 | name: rental-app-conf 17 | env: 18 | - name: DB_PASSWORD 19 | valueFrom: 20 | secretKeyRef: 21 | name: rental-mysql-pass 22 | key: password 23 | volumeMounts: 24 | - name: rental-app-conf 25 | subPath: .env 26 | mountPath: /var/www/.env 27 | 28 | volumes: 29 | - name: rental-app-conf 30 | configMap: 31 | name: rental-app-conf 32 | items: 33 | - key: env 34 | path: .env 35 | -------------------------------------------------------------------------------- /k8s/rental_service/app/app-job.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: rental-job-consumer-products 5 | spec: 6 | template: 7 | spec: 8 | restartPolicy: OnFailure 9 | containers: 10 | - name: jornada-rental 11 | image: wesleywillians/rental_jornada:latest 12 | imagePullPolicy: Always 13 | command: ["php", "artisan","kafka:consume","products","product-group"] 14 | envFrom: 15 | - configMapRef: 16 | name: rental-app-conf 17 | env: 18 | - name: DB_PASSWORD 19 | valueFrom: 20 | secretKeyRef: 21 | name: rental-mysql-pass 22 | key: password 23 | volumeMounts: 24 | - name: rental-app-conf 25 | subPath: .env 26 | mountPath: /var/www/.env 27 | 28 | volumes: 29 | - name: rental-app-conf 30 | configMap: 31 | name: rental-app-conf 32 | items: 33 | - key: env 34 | path: .env 35 | -------------------------------------------------------------------------------- /k8s/rental_service/app/app-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: rental-app-service 5 | spec: 6 | type: LoadBalancer 7 | ports: 8 | - port: 80 9 | selector: 10 | app: rental-app -------------------------------------------------------------------------------- /k8s/rental_service/kafka/helm.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: tiller 5 | namespace: kube-system 6 | --- 7 | apiVersion: rbac.authorization.k8s.io/v1 8 | kind: ClusterRoleBinding 9 | metadata: 10 | name: tiller 11 | roleRef: 12 | apiGroup: rbac.authorization.k8s.io 13 | kind: ClusterRole 14 | name: cluster-admin 15 | subjects: 16 | - kind: ServiceAccount 17 | name: tiller 18 | namespace: kube-system -------------------------------------------------------------------------------- /k8s/rental_service/kafka/kafka-client.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: kafka-client 5 | namespace: default 6 | spec: 7 | containers: 8 | - name: kafka-client 9 | image: confluentinc/cp-kafka:5.0.1 10 | command: 11 | - sh 12 | - -c 13 | - "exec tail -f /dev/null" -------------------------------------------------------------------------------- /k8s/rental_service/mysql/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 2 | kind: Deployment 3 | metadata: 4 | name: rental-mysql 5 | labels: 6 | app: rental-mysql 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app: rental-mysql 12 | strategy: 13 | type: Recreate 14 | template: 15 | metadata: 16 | labels: 17 | app: rental-mysql 18 | spec: 19 | containers: 20 | - image: mysql:5.7 21 | args: 22 | - "--ignore-db-dir=lost+found" 23 | name: mysql 24 | env: 25 | - name: MYSQL_ROOT_PASSWORD 26 | valueFrom: 27 | secretKeyRef: 28 | name: rental-mysql-pass 29 | key: password 30 | ports: 31 | - containerPort: 3306 32 | name: mysql 33 | volumeMounts: 34 | - name: mysql-persistent-storage 35 | mountPath: /var/lib/mysql 36 | volumes: 37 | - name: mysql-persistent-storage 38 | persistentVolumeClaim: 39 | claimName: mysql-rental-pv-claim -------------------------------------------------------------------------------- /k8s/rental_service/mysql/mysql-persistent-volume-claim.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: mysql-rental-pv-claim 5 | labels: 6 | app: rental 7 | spec: 8 | accessModes: 9 | - ReadWriteOnce 10 | resources: 11 | requests: 12 | storage: 20Gi -------------------------------------------------------------------------------- /k8s/rental_service/mysql/mysql-secret.yaml: -------------------------------------------------------------------------------- 1 | kubectl create secret generic rental-mysql-pass --from-literal=password='a1s2d3f4' 2 | -------------------------------------------------------------------------------- /k8s/rental_service/mysql/mysql-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: rental-mysql-service 5 | labels: 6 | app: rental-mysql 7 | spec: 8 | ports: 9 | - port: 3306 10 | selector: 11 | app: rental-mysql -------------------------------------------------------------------------------- /k8s/rental_service/redis/redis-master.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 2 | kind: Deployment 3 | metadata: 4 | name: rental-redis 5 | labels: 6 | app: rental-redis 7 | spec: 8 | selector: 9 | matchLabels: 10 | app: rental-redis 11 | replicas: 1 12 | template: 13 | metadata: 14 | labels: 15 | app: rental-redis 16 | spec: 17 | containers: 18 | - name: master 19 | image: redis 20 | ports: 21 | - containerPort: 6379 22 | 23 | --- 24 | 25 | apiVersion: v1 26 | kind: Service 27 | metadata: 28 | name: rental-redis-service 29 | labels: 30 | app: rental-redis-service 31 | spec: 32 | ports: 33 | - port: 6379 34 | targetPort: 6379 35 | selector: 36 | app: rental-redis -------------------------------------------------------------------------------- /kafka/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | zookeeper: 4 | image: confluentinc/cp-zookeeper:latest 5 | environment: 6 | ZOOKEEPER_CLIENT_PORT: 2181 7 | ZOOKEEPER_TICK_TIME: 2000 8 | 9 | kafka: 10 | image: confluentinc/cp-kafka:latest 11 | depends_on: 12 | - zookeeper 13 | environment: 14 | KAFKA_BROKER_ID: 1 15 | KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 16 | KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 17 | KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 18 | 19 | networks: 20 | default: 21 | external: 22 | name: jornada-network -------------------------------------------------------------------------------- /product_service/.docker/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.15.0-alpine 2 | RUN apk update && apk add bash 3 | 4 | RUN rm /etc/nginx/conf.d/default.conf 5 | COPY ./nginx.conf /etc/nginx/conf.d 6 | -------------------------------------------------------------------------------- /product_service/.docker/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | index index.php index.html; 4 | root /var/www/public; 5 | 6 | location ~ \.php$ { 7 | try_files $uri = 404; 8 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 9 | fastcgi_pass localhost:9000; 10 | fastcgi_index index.php; 11 | include fastcgi_params; 12 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 13 | fastcgi_param PATH_INFO $fastcgi_path_info; 14 | } 15 | 16 | location / { 17 | try_files $uri $uri/ /index.php?$query_string; 18 | gzip_static on; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /product_service/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /product_service/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=laravel 13 | DB_USERNAME=root 14 | DB_PASSWORD= 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_DRIVER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | AWS_ACCESS_KEY_ID= 34 | AWS_SECRET_ACCESS_KEY= 35 | AWS_DEFAULT_REGION=us-east-1 36 | AWS_BUCKET= 37 | 38 | PUSHER_APP_ID= 39 | PUSHER_APP_KEY= 40 | PUSHER_APP_SECRET= 41 | PUSHER_APP_CLUSTER=mt1 42 | 43 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 44 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 45 | -------------------------------------------------------------------------------- /product_service/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /product_service/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .env.backup 8 | .phpunit.result.cache 9 | Homestead.json 10 | Homestead.yaml 11 | npm-debug.log 12 | yarn-error.log 13 | -------------------------------------------------------------------------------- /product_service/.styleci.yml: -------------------------------------------------------------------------------- 1 | php: 2 | preset: laravel 3 | enabled: 4 | - alpha_ordered_imports 5 | disabled: 6 | - length_ordered_imports 7 | - unused_use 8 | finder: 9 | not-name: 10 | - index.php 11 | - server.php 12 | js: 13 | finder: 14 | not-name: 15 | - webpack.mix.js 16 | css: true 17 | -------------------------------------------------------------------------------- /product_service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3.6-fpm-alpine3.9 2 | RUN apk add --no-cache openssl bash mysql-client nodejs npm alpine-sdk autoconf librdkafka-dev vim nginx openrc 3 | RUN mkdir -p /run/nginx && \ 4 | echo "pid /run/nginx.pid;" >> /etc/nginx/nginx.conf 5 | 6 | RUN docker-php-ext-install pdo pdo_mysql bcmath 7 | RUN pecl install rdkafka 8 | 9 | RUN ln -s /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini && \ 10 | echo "extension=rdkafka.so" >> /usr/local/etc/php/php.ini 11 | 12 | WORKDIR /var/www 13 | 14 | RUN rm -rf /var/www/html 15 | RUN ln -s public html 16 | 17 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 18 | 19 | RUN rm /etc/nginx/conf.d/default.conf 20 | COPY .docker/nginx/nginx.conf /etc/nginx/conf.d 21 | COPY . . 22 | RUN chmod -R 777 /var/www/storage/ 23 | 24 | EXPOSE 80 25 | ENTRYPOINT [ "/var/www/entrypoint.sh" ] 26 | 27 | 28 | -------------------------------------------------------------------------------- /product_service/app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /product_service/app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /product_service/app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /product_service/app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | $this->middleware('signed')->only('verify'); 39 | $this->middleware('throttle:6,1')->only('verify', 'resend'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /product_service/app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('saml2_login',['idpName'=>'PRODUCT']); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /product_service/app/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /product_service/app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | id) { 14 | $obj->id = \Ramsey\Uuid\Uuid::uuid4(); 15 | } 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /product_service/app/Models/User.php: -------------------------------------------------------------------------------- 1 | 'datetime', 38 | ]; 39 | } 40 | -------------------------------------------------------------------------------- /product_service/app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->bind("KafkaBrokerCollection", function () { 21 | $broker = new Broker(env("KAFKA_HOST","kafka"), env("KAFKA_PORT","9092")); 22 | $kafkaBrokerCollection = new BrokerCollection(); 23 | $kafkaBrokerCollection->addBroker($broker); 24 | return $kafkaBrokerCollection; 25 | }); 26 | 27 | $this->app->bind("KafkaTopicConfig", function () { 28 | return [ 29 | 'topic' => [ 30 | 'auto.offset.reset' => 'largest' 31 | ], 32 | 'consumer' => [ 33 | 'enable.auto.commit' => "true", 34 | 'auto.commit.interval.ms' => "100", 35 | 'offset.store.method' => 'broker' 36 | ] 37 | ]; 38 | }); 39 | } 40 | 41 | /** 42 | * Bootstrap any application services. 43 | * 44 | * @return void 45 | */ 46 | public function boot() 47 | { 48 | Product::observe(KafkaProductObserver::class); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /product_service/app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /product_service/app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /product_service/bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /product_service/config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /product_service/config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /product_service/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /product_service/config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /product_service/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.sqlite-journal 3 | -------------------------------------------------------------------------------- /product_service/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(User::class, function (Faker $faker) { 20 | return [ 21 | 'name' => $faker->name, 22 | 'email' => $faker->unique()->safeEmail, 23 | 'email_verified_at' => now(), 24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 25 | 'remember_token' => Str::random(10), 26 | ]; 27 | }); 28 | -------------------------------------------------------------------------------- /product_service/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /product_service/database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /product_service/database/migrations/2018_01_01_000000_create_action_events_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->char('batch_id', 36); 19 | $table->unsignedInteger('user_id')->index(); 20 | $table->string('name'); 21 | $table->string('actionable_type'); 22 | $table->string('actionable_id'); 23 | $table->string('target_type'); 24 | $table->string('target_id'); 25 | $table->string('model_type'); 26 | $table->string('model_id')->nullable(); 27 | $table->text('fields'); 28 | $table->string('status', 25)->default('running'); 29 | $table->text('exception'); 30 | $table->timestamps(); 31 | 32 | $table->index(['actionable_type', 'actionable_id']); 33 | $table->index(['batch_id', 'model_type', 'model_id']); 34 | }); 35 | } 36 | 37 | /** 38 | * Reverse the migrations. 39 | * 40 | * @return void 41 | */ 42 | public function down() 43 | { 44 | Schema::dropIfExists('action_events'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /product_service/database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->text('connection'); 19 | $table->text('queue'); 20 | $table->longText('payload'); 21 | $table->longText('exception'); 22 | $table->timestamp('failed_at')->useCurrent(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('failed_jobs'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /product_service/database/migrations/2019_08_25_202953_product.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->string('name'); 19 | $table->string('description'); 20 | $table->float('price'); 21 | $table->integer('qtd_available'); 22 | $table->integer('qtd_total'); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('products'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /product_service/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /product_service/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | productapp: 4 | build: . 5 | volumes: 6 | - ./:/var/www 7 | depends_on: 8 | - productapp-mysql 9 | - productapp-redis 10 | ports: 11 | - "9000:80" 12 | # command: php-fpm; nginx -g 'daemon off;' 13 | 14 | productapp-mysql: 15 | image: mysql:5.7.22 16 | command: --innodb-use-native-aio=0 17 | restart: always 18 | ports: 19 | - "3306" 20 | volumes: 21 | - "./.docker/dbdata:/var/lib/mysql" 22 | environment: 23 | MYSQL_DATABASE: productapp 24 | MYSQL_ROOT_PASSWORD: root 25 | 26 | productapp-nginx: 27 | build: ./.docker/nginx 28 | restart: always 29 | ports: 30 | - "8001:8001" 31 | volumes: 32 | - ./:/var/www 33 | depends_on: 34 | - productapp 35 | 36 | 37 | productapp-redis: 38 | image: redis:alpine 39 | expose: 40 | - 6379 41 | networks: 42 | default: 43 | external: 44 | name: jornada-network 45 | -------------------------------------------------------------------------------- /product_service/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # turn on bash's job control 4 | set -m 5 | 6 | # Start the primary process and put it in the background 7 | php-fpm & 8 | 9 | # Start the helper process 10 | nginx -g 'daemon off;' 11 | 12 | # the my_helper_process might need to know how to wait on the 13 | # primary process to start before it does its work and returns 14 | 15 | 16 | # now we bring the primary process back into the foreground 17 | # and leave it there 18 | fg %1 -------------------------------------------------------------------------------- /product_service/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "npm run development -- --watch", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.19", 14 | "cross-env": "^5.1", 15 | "laravel-mix": "^4.0.7", 16 | "lodash": "^4.17.13", 17 | "resolve-url-loader": "^2.3.1", 18 | "sass": "^1.15.2", 19 | "sass-loader": "^7.1.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /product_service/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Unit 14 | 15 | 16 | 17 | ./tests/Feature 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /product_service/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Handle Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /product_service/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeedu/jornada-microservicos/15f551c45ee9ba16932ed96b72365352694fdc30/product_service/public/favicon.ico -------------------------------------------------------------------------------- /product_service/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /product_service/public/web.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /product_service/resources/js/app.js: -------------------------------------------------------------------------------- 1 | require('./bootstrap'); 2 | -------------------------------------------------------------------------------- /product_service/resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | 3 | /** 4 | * We'll load the axios HTTP library which allows us to easily issue requests 5 | * to our Laravel back-end. This library automatically handles sending the 6 | * CSRF token as a header based on the value of the "XSRF" token cookie. 7 | */ 8 | 9 | window.axios = require('axios'); 10 | 11 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 12 | 13 | /** 14 | * Echo exposes an expressive API for subscribing to channels and listening 15 | * for events that are broadcast by Laravel. Echo and event broadcasting 16 | * allows your team to easily build robust real-time web applications. 17 | */ 18 | 19 | // import Echo from 'laravel-echo'; 20 | 21 | // window.Pusher = require('pusher-js'); 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: process.env.MIX_PUSHER_APP_KEY, 26 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 27 | // encrypted: true 28 | // }); 29 | -------------------------------------------------------------------------------- /product_service/resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /product_service/resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /product_service/resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have e-mailed your password reset link!', 18 | 'token' => 'This password reset token is invalid.', 19 | 'user' => "We can't find a user with that e-mail address.", 20 | 21 | ]; 22 | -------------------------------------------------------------------------------- /product_service/resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | // 2 | -------------------------------------------------------------------------------- /product_service/routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 17 | return $request->user(); 18 | }); 19 | -------------------------------------------------------------------------------- /product_service/routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /product_service/routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /product_service/routes/web.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 17 | 18 | Route::redirect('/nova/login/', '/', 301); 19 | -------------------------------------------------------------------------------- /product_service/server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /product_service/storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /product_service/storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /product_service/storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /product_service/storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /product_service/storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /product_service/storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /product_service/storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /product_service/storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /product_service/storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /product_service/test.txt: -------------------------------------------------------------------------------- 1 | fdafsa 2 | fdsadfdsa 3 | fdsa 4 | -------------------------------------------------------------------------------- /product_service/tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /product_service/tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /product_service/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /product_service/webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js') 15 | .sass('resources/sass/app.scss', 'public/css'); 16 | -------------------------------------------------------------------------------- /rental_service/.docker/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.15.0-alpine 2 | RUN apk update && apk add bash 3 | 4 | RUN rm /etc/nginx/conf.d/default.conf 5 | COPY ./nginx.conf /etc/nginx/conf.d 6 | -------------------------------------------------------------------------------- /rental_service/.docker/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | index index.php index.html; 4 | root /var/www/public; 5 | 6 | location ~ \.php$ { 7 | try_files $uri =404; 8 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 9 | fastcgi_pass localhost:9000; 10 | fastcgi_index index.php; 11 | include fastcgi_params; 12 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 13 | fastcgi_param PATH_INFO $fastcgi_path_info; 14 | } 15 | 16 | location / { 17 | try_files $uri $uri/ /index.php?$query_string; 18 | gzip_static on; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /rental_service/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /rental_service/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=laravel 13 | DB_USERNAME=root 14 | DB_PASSWORD= 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_DRIVER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | AWS_ACCESS_KEY_ID= 34 | AWS_SECRET_ACCESS_KEY= 35 | AWS_DEFAULT_REGION=us-east-1 36 | AWS_BUCKET= 37 | 38 | PUSHER_APP_ID= 39 | PUSHER_APP_KEY= 40 | PUSHER_APP_SECRET= 41 | PUSHER_APP_CLUSTER=mt1 42 | 43 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 44 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 45 | -------------------------------------------------------------------------------- /rental_service/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /rental_service/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .env.backup 8 | .phpunit.result.cache 9 | Homestead.json 10 | Homestead.yaml 11 | npm-debug.log 12 | yarn-error.log 13 | -------------------------------------------------------------------------------- /rental_service/.styleci.yml: -------------------------------------------------------------------------------- 1 | php: 2 | preset: laravel 3 | enabled: 4 | - alpha_ordered_imports 5 | disabled: 6 | - length_ordered_imports 7 | - unused_use 8 | finder: 9 | not-name: 10 | - index.php 11 | - server.php 12 | js: 13 | finder: 14 | not-name: 15 | - webpack.mix.js 16 | css: true 17 | -------------------------------------------------------------------------------- /rental_service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3.6-fpm-alpine3.9 2 | RUN apk add --no-cache openssl bash mysql-client nodejs npm alpine-sdk autoconf librdkafka-dev vim nginx openrc 3 | RUN mkdir -p /run/nginx && \ 4 | echo "pid /run/nginx.pid;" >> /etc/nginx/nginx.conf 5 | 6 | RUN docker-php-ext-install pdo pdo_mysql bcmath 7 | RUN pecl install rdkafka 8 | 9 | RUN ln -s /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini && \ 10 | echo "extension=rdkafka.so" >> /usr/local/etc/php/php.ini 11 | 12 | WORKDIR /var/www 13 | 14 | RUN rm -rf /var/www/html 15 | RUN ln -s public html 16 | 17 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 18 | 19 | RUN rm /etc/nginx/conf.d/default.conf 20 | COPY .docker/nginx/nginx.conf /etc/nginx/conf.d 21 | COPY . . 22 | RUN chmod -R 777 /var/www/storage/ 23 | 24 | EXPOSE 80 25 | ENTRYPOINT [ "/var/www/entrypoint.sh" ] 26 | -------------------------------------------------------------------------------- /rental_service/app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rental_service/app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /rental_service/app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /rental_service/app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | $this->middleware('signed')->only('verify'); 39 | $this->middleware('throttle:6,1')->only('verify', 'resend'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rental_service/app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('saml2_login', ['idpName' => 'RENTAL']); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /rental_service/app/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /rental_service/app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | payload); 16 | 17 | Customer::firstOrCreate( 18 | ['id' => $payload->id], 19 | [ 20 | 'name' => $payload->name, 21 | 'email' => $payload->email, 22 | 'phone' => $payload->email 23 | ] 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /rental_service/app/Kafka/ProductHandler.php: -------------------------------------------------------------------------------- 1 | payload); 17 | 18 | Product::firstOrCreate( 19 | ['id' => $payload->id], 20 | [ 21 | 'name' => $payload->name, 22 | 'price' => $payload->price, 23 | ] 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /rental_service/app/Models/Customer.php: -------------------------------------------------------------------------------- 1 | hasMany(Order::class); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /rental_service/app/Models/OrderItem.php: -------------------------------------------------------------------------------- 1 | 'int', 24 | 'total' => 'float' 25 | ]; 26 | 27 | public function product() 28 | { 29 | return $this->belongsTo(Product::class); 30 | } 31 | 32 | public function order() 33 | { 34 | return $this->belongsTo(Order::class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /rental_service/app/Models/Payment.php: -------------------------------------------------------------------------------- 1 | 'date', 25 | ]; 26 | 27 | public function order() 28 | { 29 | return $this->belongsTo(Order::class); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /rental_service/app/Models/Product.php: -------------------------------------------------------------------------------- 1 | id) { 14 | $obj->id = \Ramsey\Uuid\Uuid::uuid4(); 15 | } 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /rental_service/app/Models/User.php: -------------------------------------------------------------------------------- 1 | 'datetime', 38 | ]; 39 | } 40 | -------------------------------------------------------------------------------- /rental_service/app/Observers/OrderItemObserver.php: -------------------------------------------------------------------------------- 1 | order->adjustTotal(); 11 | $orderItem->order->adjustBalance(); 12 | } 13 | 14 | public function updated(OrderItem $orderItem) { 15 | $orderItem->order->adjustTotal(); 16 | $orderItem->order->adjustBalance(); 17 | } 18 | 19 | public function deleted(OrderItem $orderItem) { 20 | $orderItem->order->adjustTotal(); 21 | $orderItem->order->adjustBalance(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /rental_service/app/Observers/PaymentObserver.php: -------------------------------------------------------------------------------- 1 | order->adjustTotal(); 11 | $payment->order->adjustBalance(); 12 | } 13 | 14 | public function updated(Payment $payment) { 15 | $payment->order->adjustTotal(); 16 | $payment->order->adjustBalance(); 17 | } 18 | 19 | public function deleted(Payment $payment) { 20 | $payment->order->adjustTotal(); 21 | $payment->order->adjustBalance(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /rental_service/app/Policies/CustomerPolicy.php: -------------------------------------------------------------------------------- 1 | app->bind("KafkaBrokerCollection", function () { 25 | $broker = new Broker(env("KAFKA_HOST","kafka"), env("KAFKA_PORT","9092")); 26 | $kafkaBrokerCollection = new BrokerCollection(); 27 | $kafkaBrokerCollection->addBroker($broker); 28 | return $kafkaBrokerCollection; 29 | }); 30 | 31 | $this->app->bind("KafkaTopicConfig", function () { 32 | return [ 33 | 'topic' => [ 34 | 'auto.offset.reset' => 'largest' 35 | ], 36 | 'consumer' => [ 37 | 'enable.auto.commit' => "true", 38 | 'auto.commit.interval.ms' => "100", 39 | 'offset.store.method' => 'broker' 40 | ] 41 | ]; 42 | }); 43 | } 44 | 45 | /** 46 | * Bootstrap any application services. 47 | * 48 | * @return void 49 | */ 50 | public function boot() 51 | { 52 | Order::observe(OrderObserver::class); 53 | OrderItem::observe(OrderItemObserver::class); 54 | Payment::observe(PaymentObserver::class); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /rental_service/app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | ProductPolicy::class, 21 | Customer::class => CustomerPolicy::class, 22 | ]; 23 | 24 | /** 25 | * Register any authentication / authorization services. 26 | * 27 | * @return void 28 | */ 29 | public function boot() 30 | { 31 | $this->registerPolicies(); 32 | 33 | // 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /rental_service/app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /rental_service/bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /rental_service/config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /rental_service/config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /rental_service/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /rental_service/config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /rental_service/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.sqlite-journal 3 | -------------------------------------------------------------------------------- /rental_service/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(User::class, function (Faker $faker) { 20 | return [ 21 | 'name' => $faker->name, 22 | 'email' => $faker->unique()->safeEmail, 23 | 'email_verified_at' => now(), 24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 25 | 'remember_token' => Str::random(10), 26 | ]; 27 | }); 28 | -------------------------------------------------------------------------------- /rental_service/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /rental_service/database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /rental_service/database/migrations/2018_01_01_000000_create_action_events_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->char('batch_id', 36); 19 | $table->unsignedInteger('user_id')->index(); 20 | $table->string('name'); 21 | $table->string('actionable_type'); 22 | $table->string('actionable_id'); 23 | $table->string('target_type'); 24 | $table->string('target_id'); 25 | $table->string('model_type'); 26 | $table->string('model_id')->nullable(); 27 | $table->text('fields'); 28 | $table->string('status', 25)->default('running'); 29 | $table->text('exception'); 30 | $table->timestamps(); 31 | 32 | $table->index(['actionable_type', 'actionable_id']); 33 | $table->index(['batch_id', 'model_type', 'model_id']); 34 | }); 35 | } 36 | 37 | /** 38 | * Reverse the migrations. 39 | * 40 | * @return void 41 | */ 42 | public function down() 43 | { 44 | Schema::dropIfExists('action_events'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /rental_service/database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->text('connection'); 19 | $table->text('queue'); 20 | $table->longText('payload'); 21 | $table->longText('exception'); 22 | $table->timestamp('failed_at')->useCurrent(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('failed_jobs'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /rental_service/database/migrations/2019_08_25_202953_customer.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->string('name'); 19 | $table->string('email'); 20 | $table->string('phone'); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::dropIfExists('customers'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /rental_service/database/migrations/2019_08_25_202953_product.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->string('name'); 19 | $table->double('price')->default(0); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('products'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /rental_service/database/migrations/2019_09_05_110116_create_orders_table.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->uuid('customer_id'); 19 | $table->foreign('customer_id')->references("id")->on("customers"); 20 | $table->string('status'); 21 | $table->double('discount'); 22 | $table->double('downpayment'); 23 | $table->double('delivery_fee'); 24 | $table->double('late_fee'); 25 | $table->double('total')->default(0); 26 | $table->double('balance')->default(0); 27 | $table->date('order_date'); 28 | $table->date('return_date'); 29 | $table->timestamps(); 30 | }); 31 | } 32 | 33 | 34 | /** 35 | * Reverse the migrations. 36 | * 37 | * @return void 38 | */ 39 | public function down() 40 | { 41 | Schema::dropIfExists('orders'); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /rental_service/database/migrations/2019_10_09_133938_order_item.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->uuid('order_id'); 19 | $table->foreign('order_id')->references("id")->on("orders"); 20 | $table->uuid('product_id'); 21 | $table->foreign('product_id')->references("id")->on("products"); 22 | $table->string('qtd'); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('order_items'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /rental_service/database/migrations/2019_10_09_133938_payment.php: -------------------------------------------------------------------------------- 1 | uuid('id')->primary(); 18 | $table->uuid('order_id'); 19 | $table->foreign('order_id')->references("id")->on("orders"); 20 | $table->string('payment_type'); 21 | $table->string('description')->nullable(); 22 | $table->double('amount'); 23 | $table->date('payment_date'); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('payments'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /rental_service/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /rental_service/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | rentalapp: 4 | build: . 5 | volumes: 6 | - ./:/var/www 7 | depends_on: 8 | - rentalapp-mysql 9 | - rentalapp-redis 10 | 11 | rentalapp-mysql: 12 | image: mysql:5.7.22 13 | command: --innodb-use-native-aio=0 14 | restart: always 15 | ports: 16 | - "3306" 17 | volumes: 18 | - "./.docker/dbdata:/var/lib/mysql" 19 | environment: 20 | MYSQL_DATABASE: rentalapp 21 | MYSQL_ROOT_PASSWORD: root 22 | 23 | rentalapp-nginx: 24 | build: ./.docker/nginx 25 | restart: always 26 | ports: 27 | - "8000:8000" 28 | volumes: 29 | - ./:/var/www 30 | depends_on: 31 | - rentalapp 32 | 33 | 34 | rentalapp-redis: 35 | image: redis:alpine 36 | expose: 37 | - 6379 38 | 39 | networks: 40 | default: 41 | external: 42 | name: jornada-network 43 | -------------------------------------------------------------------------------- /rental_service/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # turn on bash's job control 4 | set -m 5 | 6 | # Start the primary process and put it in the background 7 | php-fpm & 8 | 9 | # Start the helper process 10 | nginx -g 'daemon off;' 11 | 12 | # the my_helper_process might need to know how to wait on the 13 | # primary process to start before it does its work and returns 14 | 15 | 16 | # now we bring the primary process back into the foreground 17 | # and leave it there 18 | fg %1 -------------------------------------------------------------------------------- /rental_service/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "npm run development -- --watch", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.19", 14 | "cross-env": "^5.1", 15 | "laravel-mix": "^4.0.7", 16 | "lodash": "^4.17.13", 17 | "resolve-url-loader": "^2.3.1", 18 | "sass": "^1.15.2", 19 | "sass-loader": "^7.1.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /rental_service/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Unit 14 | 15 | 16 | 17 | ./tests/Feature 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /rental_service/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Handle Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /rental_service/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeedu/jornada-microservicos/15f551c45ee9ba16932ed96b72365352694fdc30/rental_service/public/favicon.ico -------------------------------------------------------------------------------- /rental_service/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /rental_service/public/web.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /rental_service/resources/js/app.js: -------------------------------------------------------------------------------- 1 | require('./bootstrap'); 2 | -------------------------------------------------------------------------------- /rental_service/resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | 3 | /** 4 | * We'll load the axios HTTP library which allows us to easily issue requests 5 | * to our Laravel back-end. This library automatically handles sending the 6 | * CSRF token as a header based on the value of the "XSRF" token cookie. 7 | */ 8 | 9 | window.axios = require('axios'); 10 | 11 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 12 | 13 | /** 14 | * Echo exposes an expressive API for subscribing to channels and listening 15 | * for events that are broadcast by Laravel. Echo and event broadcasting 16 | * allows your team to easily build robust real-time web applications. 17 | */ 18 | 19 | // import Echo from 'laravel-echo'; 20 | 21 | // window.Pusher = require('pusher-js'); 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: process.env.MIX_PUSHER_APP_KEY, 26 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 27 | // encrypted: true 28 | // }); 29 | -------------------------------------------------------------------------------- /rental_service/resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /rental_service/resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /rental_service/resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have e-mailed your password reset link!', 18 | 'token' => 'This password reset token is invalid.', 19 | 'user' => "We can't find a user with that e-mail address.", 20 | 21 | ]; 22 | -------------------------------------------------------------------------------- /rental_service/resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | // 2 | -------------------------------------------------------------------------------- /rental_service/routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 17 | return $request->user(); 18 | }); 19 | -------------------------------------------------------------------------------- /rental_service/routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /rental_service/routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /rental_service/routes/web.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 17 | 18 | Route::redirect('/nova/login/', '/', 301); 19 | -------------------------------------------------------------------------------- /rental_service/server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /rental_service/storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /rental_service/storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /rental_service/storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /rental_service/storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /rental_service/storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /rental_service/storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /rental_service/storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /rental_service/storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /rental_service/storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /rental_service/tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /rental_service/tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /rental_service/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /rental_service/webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js') 15 | .sass('resources/sass/app.scss', 'public/css'); 16 | --------------------------------------------------------------------------------