-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add api support, and scribe documentation (monicahq/chandler#307)
- Loading branch information
Showing
17 changed files
with
1,766 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
/bootstrap/ssr | ||
/data.ms | ||
/lang/php_*.json | ||
/node_modules | ||
/public/build | ||
/public/docs | ||
/public/hot | ||
/public/storage | ||
/public/vendor/scribe | ||
/resources/views/scribe | ||
/storage/*.key | ||
/vendor | ||
/results | ||
/.scribe | ||
/tests/Features/screenshots/ | ||
/tests/Features/videos/ | ||
_ide_helper.php | ||
_ide_helper_models.php | ||
.env | ||
.phpunit.result.cache | ||
Homestead.json | ||
.DS_Store | ||
.idea | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
.php_cs.cache | ||
.DS_Store | ||
/tests/Features/screenshots/ | ||
/tests/Features/videos/ | ||
/data.ms | ||
_ide_helper.php | ||
_ide_helper_models.php | ||
.phpstorm.meta.php | ||
lang/php_*.json | ||
.phpunit.result.cache | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Console\ConfirmableTrait; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class SetupDocumentation extends Command | ||
{ | ||
use ConfirmableTrait; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'scribe:setup | ||
{--force : Force the operation to run when in production.}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Install or update the application, and run migrations after a new release'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(): void | ||
{ | ||
if ($this->confirmToProceed()) { | ||
$this->documentation(); | ||
} | ||
} | ||
|
||
/** | ||
* Regenerate api documentation. | ||
* | ||
* @return void | ||
*/ | ||
protected function documentation(): void | ||
{ | ||
putenv('DB_CONNECTION=docs'); | ||
putenv('APP_ENV=testing'); | ||
putenv('CACHE_DRIVER=array'); | ||
putenv('QUEUE_CONNECTION=sync'); | ||
putenv('SESSION_DRIVER=array'); | ||
putenv('MAIL_MAILER=log'); | ||
putenv('SCOUT_DRIVER=null'); | ||
|
||
exec('php artisan scribe:generate --verbose --force', $output); | ||
|
||
if ($this->getOutput()->getOutput()->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { | ||
foreach ($output as $line) { | ||
$this->line($line); | ||
} | ||
$this->line(''); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Contact; | ||
use App\Models\Group; | ||
use App\Models\Note; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Console\ConfirmableTrait; | ||
use MeiliSearch\Client; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class SetupScout extends Command | ||
{ | ||
use ConfirmableTrait; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'scout:setup | ||
{--force : Force the operation to run when in production.}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Setup scout indexes.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(): void | ||
{ | ||
if ($this->confirmToProceed()) { | ||
$this->scout(); | ||
} | ||
} | ||
|
||
/** | ||
* Configure scout. | ||
* | ||
* @return void | ||
*/ | ||
protected function scout(): void | ||
{ | ||
if (config('scout.driver') !== null) { | ||
$this->artisan('☐ Flush search engine', 'scout:flush', ['model' => Note::class]); | ||
$this->artisan('☐ Flush search engine', 'scout:flush', ['model' => Contact::class]); | ||
$this->artisan('☐ Flush search engine', 'scout:flush', ['model' => Group::class]); | ||
} | ||
|
||
if (config('scout.driver') === 'meilisearch' && ($host = config('scout.meilisearch.host')) !== '') { | ||
$this->info('-> Creating indexes on Meilisearch. Make sure Meilisearch is running.'); | ||
|
||
$config = [ | ||
'contacts' => ['id', 'vault_id'], | ||
'notes' => ['id', 'vault_id', 'contact_id'], | ||
'groups' => ['id', 'vault_id'], | ||
]; | ||
|
||
$client = new Client($host, config('scout.meilisearch.key')); | ||
foreach ($config as $name => $fields) { | ||
$index = $client->index($name); | ||
$index->updateFilterableAttributes($fields); | ||
} | ||
|
||
$this->info('✓ Indexes created'); | ||
} | ||
} | ||
|
||
private function artisan(string $message, string $command, array $options = []) | ||
{ | ||
$this->info($message); | ||
$this->getOutput()->getOutput()->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE | ||
? $this->call($command, $options) | ||
: $this->callSilent($command, $options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Domains\Settings\ManageUsers\Api; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
|
||
class UserController extends Controller | ||
{ | ||
/** | ||
* GET api/user | ||
* | ||
* Get the authenticated User. | ||
* | ||
* @apiResourceModel \App\Models\User | ||
*/ | ||
public function __invoke(Request $request) | ||
{ | ||
return $request->user(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.