Tuesday, March 26, 2019

API unit testing

Test open API service  php artisan make:test SampleTest  You can use above artisan command to make test command. If you want to use repositories in Test file you have to follow below steps.  Step 1: Create setup function and add followings just like in constructors.  public function setUp(){ parent::setUp(); $this->application...

Share/Bookmark

Tuesday, February 26, 2019

Nodejs upload file to S3 bucket and create signed url

AWS.config.update({ region: 'region', accessKeyId: 'adadadada', secretAccessKey: 'aadadadadad'}); const s3 = new AWS.S3(); const today = new Date(); const token = 'test-upload'; return new Promise((resolve, reject) => { // console.log(req.files.inputFile); fs.readFile(req.files.inputFile.path, (err, fileBuffer) => { ...

Share/Bookmark

Monday, February 25, 2019

Nodejs Queue with AWS SQS

Step 1: Install docker This digital ocean article describes properly how to install docker on ubuntuinstall docker article Step 2: Install AWS SQS queue service docker image in local  You can manage Nodejs queues using AWS SQS in your local machine.  https://github.com/vsouza/docker-SQS-local docker pull vsouza/sqs-local; docker run...

Share/Bookmark

Thursday, July 5, 2018

Set up jenkins

Follow this link for install jenkins in ubuntu. https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-16-04 Step 1 : Click on new item then select Free style project. Step 2 : Go to customize project. Tick on gitHub project under general tab and add git project url. Step 3 : Under source code management tick on git....

Share/Bookmark

Tuesday, May 8, 2018

Laravel with MySql json format - hints

Hint 1:  You can define in model which table column is array or json. Then you don't need to json_encode and json_decode arrays when saving and retrieving data from json format database field. protected $casts = [ 'attributes' => 'array']; In saving, updating or inserting you can inject directly. $record->attributes = $request['attributes']; Hint...

Share/Bookmark

Wednesday, April 25, 2018

unit testing - use database or sqlite cache

use new database for unit testing add new testing connection to config/database.php 'testing' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('TEST_DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), ...

Share/Bookmark

Customoze laravel monolog - add user IP and UUID to logs

Step 1: add custom function to AppServiceProvider private function addUniqueIdAndIpToMonoLog(){ $ip = \Request::ip(); $uuid = \Uuid::generate(); $monolog = \Log::getMonolog(); $monolog->pushProcessor(function ($record) use ($uuid, $ip) { $record['extra']['request-id'] = $uuid; $record['extra']['ip'] = $ip; ...

Share/Bookmark