v0.1.0
This commit is contained in:
1
backend/api/setup/api/middleware.php
Normal file
1
backend/api/setup/api/middleware.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
38
backend/api/setup/api/settings.php
Normal file
38
backend/api/setup/api/settings.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
|
||||
return [
|
||||
'locations' => function() {
|
||||
$arr = ['base' => dirname(__DIR__, 2)];
|
||||
$arr['resources'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['base'],
|
||||
'resources'
|
||||
]);
|
||||
$arr['data'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['resources'],
|
||||
'data'
|
||||
]);
|
||||
$arr['routes'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['resources'],
|
||||
'routes'
|
||||
]);
|
||||
$arr['bin'] = implode(DIRECTORY_SEPARATOR, [
|
||||
dirname($arr['base']),
|
||||
'automation',
|
||||
'bin'
|
||||
]);
|
||||
return (object) $arr;
|
||||
},
|
||||
'coingecko' => function(Container $c) {
|
||||
return implode(DIRECTORY_SEPARATOR, [
|
||||
$c->get('locations')->bin,
|
||||
'coingecko'
|
||||
]);
|
||||
},
|
||||
'mindicador' => function(Container $c) {
|
||||
return implode(DIRECTORY_SEPARATOR, [
|
||||
$c->get('locations')->bin,
|
||||
'mindicador'
|
||||
]);
|
||||
}
|
||||
];
|
24
backend/api/setup/api/setups.php
Normal file
24
backend/api/setup/api/setups.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
|
||||
return [
|
||||
ProVM\Crypto\Common\Service\API::class => function(Container $container) {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('locations')->data,
|
||||
'api.json'
|
||||
]);
|
||||
return new ProVM\Crypto\Common\Service\API($filename);
|
||||
},
|
||||
ProVM\Common\Factory\Model::class => function(Container $container) {
|
||||
return new ProVM\Crypto\Common\Factory\Model();
|
||||
},
|
||||
ProVM\Crypto\Common\Service\Update::class => function(Container $container) {
|
||||
return new ProVM\Crypto\Common\Service\Update(
|
||||
$container->get(ProVM\Crypto\Common\Factory\Model::class),
|
||||
[
|
||||
$container->get('coingecko'),
|
||||
$container->get('mindicador')
|
||||
]
|
||||
);
|
||||
}
|
||||
];
|
55
backend/api/setup/app.php
Normal file
55
backend/api/setup/app.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
use DI\ContainerBuilder as Builder;
|
||||
use DI\Bridge\Slim\Bridge;
|
||||
|
||||
include_once 'composer.php';
|
||||
|
||||
$builder = new Builder();
|
||||
|
||||
$folders = [
|
||||
'env',
|
||||
'common',
|
||||
'api'
|
||||
];
|
||||
$files = [
|
||||
'settings',
|
||||
'setups'
|
||||
];
|
||||
|
||||
foreach ($files as $file) {
|
||||
foreach ($folders as $folder) {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
__DIR__,
|
||||
$folder,
|
||||
$file . '.php'
|
||||
]);
|
||||
if (!file_exists($filename)) {
|
||||
continue;
|
||||
}
|
||||
$builder->addDefinitions($filename);
|
||||
}
|
||||
}
|
||||
|
||||
$container = $builder->build();
|
||||
$app = Bridge::create($container);
|
||||
//$app->setBasePath($container->get('base_url'));
|
||||
$app->add(new ProVM\Crypto\Common\Middleware\CORS());
|
||||
$app->addRoutingMiddleware();
|
||||
|
||||
include_once 'databases.php';
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
__DIR__,
|
||||
$folder,
|
||||
'middlewares.php'
|
||||
]);
|
||||
if (!file_exists($filename)) {
|
||||
continue;
|
||||
}
|
||||
include_once $filename;
|
||||
}
|
||||
|
||||
include_once 'router.php';
|
||||
|
||||
$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware(['enable' => $container->get('debug') ?: true]));
|
6
backend/api/setup/composer.php
Normal file
6
backend/api/setup/composer.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
include_once implode(DIRECTORY_SEPARATOR, [
|
||||
dirname(__DIR__),
|
||||
'vendor',
|
||||
'autoload.php'
|
||||
]);
|
3
backend/api/setup/databases.php
Normal file
3
backend/api/setup/databases.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$service = $app->getContainer()->get(ProVM\Common\Service\Database::class);
|
||||
$service->load();
|
25
backend/api/setup/env/settings.php
vendored
Normal file
25
backend/api/setup/env/settings.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
return [
|
||||
'base_url' => '',
|
||||
'debug' => $_ENV['DEBUG'],
|
||||
'databases' => function() {
|
||||
$settings = [
|
||||
'short_names' => true,
|
||||
'dbs' => []
|
||||
];
|
||||
$default = [
|
||||
'engine' => 'mysql',
|
||||
'host' => (object) [
|
||||
'name' => $_ENV['DB_HOST'],
|
||||
'port' => $_ENV['DB_PORT'] ?? null
|
||||
],
|
||||
'user' => (object) [
|
||||
'name' => $_ENV['MYSQL_USER'],
|
||||
'password' => $_ENV['MYSQL_PASSWORD']
|
||||
],
|
||||
'name' => $_ENV['MYSQL_DATABASE'] . ($_ENV['ENV'] ? '_' . $_ENV['ENV'] : '')
|
||||
];
|
||||
$settings['dbs']['default'] = (object) $default;
|
||||
return (object) $settings;
|
||||
}
|
||||
];
|
8
backend/api/setup/env/setups.php
vendored
Normal file
8
backend/api/setup/env/setups.php
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
|
||||
return [
|
||||
ProVM\Common\Service\Database::class => function(Container $container) {
|
||||
return new ProVM\Common\Service\Database($container->get('databases'));
|
||||
}
|
||||
];
|
5
backend/api/setup/router.php
Normal file
5
backend/api/setup/router.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
include_once implode(DIRECTORY_SEPARATOR, [
|
||||
$app->getContainer()->get('locations')->routes,
|
||||
'api.php'
|
||||
]);
|
Reference in New Issue
Block a user