forked from islamic-network/api.alquran.cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
112 changed files
with
7,708 additions
and
3,497 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 +1,6 @@ | ||
edition-importer/* | ||
.git/* | ||
.circleci/* | ||
.idea/* | ||
.gitignore | ||
|
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
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,27 +1,16 @@ | ||
FROM islamicnetwork/php:8.0-apache | ||
|
||
# Copy files | ||
RUN cd ../ && rm -rf /var/www/html | ||
COPY . /var/www/ | ||
COPY /etc/apache2/mods-enabled/mpm_prefork.conf /etc/apache2/mods-enabled/mpm_prefork.conf | ||
|
||
# Run Composer | ||
RUN cd /var/www && composer install --no-dev | ||
|
||
RUN chown -R www-data:www-data /var/www/ | ||
ENV MYSQL_USER "someUser" | ||
ENV MYSQL_PASSWORD "somePassword" | ||
ENV MYSQL_DATABASE "someDb" | ||
ENV MYSQL_HOST_1 "localhost" | ||
ENV MYSQL_HOST_2 "localhost" | ||
ENV MYSQL_HOST_3 "localhost" | ||
# 0 = disabled. 1 = enabled | ||
ENV WAF_PROXY_MODE "0" | ||
ENV WAF_KEY "someKey" | ||
ENV LOAD_BALANCER_MODE "0" | ||
ENV LOAD_BALANCER_KEY "KEY" | ||
|
||
COPY doctrineProxies.sh /usr/local/bin/doctrineProxies.sh | ||
RUN chmod 755 /usr/local/bin/doctrineProxies.sh | ||
|
||
CMD ["/usr/local/bin/doctrineProxies.sh"] | ||
FROM islamicnetwork/php:8.1-apache-dev | ||
|
||
# Copy files | ||
COPY . /var/www/ | ||
COPY etc/apache2/mods-enabled/mpm_prefork.conf /etc/apache2/mods-enabled/mpm_prefork.conf | ||
|
||
# Run Composer | ||
RUN cd /var/www && composer install --no-dev | ||
|
||
# Set the correct permissions | ||
RUN chown -R www-data:www-data /var/www/ | ||
|
||
COPY doctrineProxies.sh /usr/local/bin/doctrineProxies.sh | ||
RUN chmod 755 /usr/local/bin/doctrineProxies.sh | ||
|
||
CMD ["/usr/local/bin/doctrineProxies.sh"] |
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
<?php | ||
|
||
namespace Api\Controllers; | ||
|
||
use Doctrine\ORM\EntityManager; | ||
use Mamluk\Kipchak\Components\Controllers; | ||
use Psr\Container\ContainerInterface; | ||
use Symfony\Component\Cache\Adapter\MemcachedAdapter; | ||
|
||
/** | ||
* All Controllers extending Controllers\Slim Contain the Service / DI Container as a protected property called $container. | ||
* Access it using $this->container in your controller. | ||
* Default objects bundled into a container are: | ||
* logger - which returns an instance of \Monolog\Logger. This is also a protected property on your controller. Access it using $this->logger. | ||
*/ | ||
|
||
class AlQuranController extends Controllers\Slim | ||
{ | ||
/** | ||
* @var EntityManager | ||
*/ | ||
protected $em; | ||
|
||
/** | ||
* @var MemcachedAdapter | ||
*/ | ||
protected $mc; | ||
|
||
public function __construct(ContainerInterface $container) | ||
{ | ||
parent::__construct($container); | ||
|
||
$this->em = $this->container->get('database.doctrine.entitymanager.primary'); | ||
|
||
$this->mc = $this->container->get('cache.memcached.cache'); | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace Api\Controllers; | ||
|
||
use Mamluk\Kipchak\Components\Controllers; | ||
use Mamluk\Kipchak\Components\Http; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Doctrine\DBAL\Connection; | ||
use Symfony\Component\Cache\Adapter\MemcachedAdapter; | ||
|
||
/** | ||
* All Controllers extending Controllers\Slim Contain the Service / DI Container as a protected property called $container. | ||
* Access it using $this->container in your controller. | ||
* Default objects bundled into a container are: | ||
* logger - which returns an instance of \Monolog\Logger. This is also a protected property on your controller. Access it using $this->logger. | ||
*/ | ||
|
||
class Liveness extends Controllers\Slim | ||
{ | ||
public function get(ServerRequestInterface $request, ResponseInterface $response, array $args): ResponseInterface | ||
{ | ||
return Http\Response::json($response, | ||
'UP', | ||
200 | ||
); | ||
} | ||
} |
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,69 @@ | ||
<?php | ||
|
||
namespace Api\Controllers; | ||
|
||
use Mamluk\Kipchak\Components\Controllers; | ||
use Mamluk\Kipchak\Components\Http; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Doctrine\DBAL\Connection; | ||
use Symfony\Component\Cache\Adapter\MemcachedAdapter; | ||
use Symfony\Contracts\Cache\ItemInterface; | ||
|
||
/** | ||
* All Controllers extending Controllers\Slim Contain the Service / DI Container as a protected property called $container. | ||
* Access it using $this->container in your controller. | ||
* Default objects bundled into a container are: | ||
* logger - which returns an instance of \Monolog\Logger. This is also a protected property on your controller. Access it using $this->logger. | ||
*/ | ||
|
||
class Status extends Controllers\Slim | ||
{ | ||
|
||
public function get(ServerRequestInterface $request, ResponseInterface $response, array $args): ResponseInterface | ||
{ | ||
|
||
$this->logger->debug('Checking Status...'); | ||
|
||
/** | ||
* @var $db Connection | ||
*/ | ||
$db = $this->container->get('database.doctrine.dbal.primary'); | ||
|
||
/** | ||
* @var $mc MemcachedAdapter | ||
*/ | ||
$mc = $this->container->get('cache.memcached.cache'); | ||
|
||
$mc->get('status', function (ItemInterface $item) { | ||
$item->expiresAfter(3); | ||
return 'up'; | ||
}); | ||
|
||
$mcStatus = $mc->getItem('status'); | ||
|
||
try { | ||
$dbResult = $db->fetchAssociative("SELECT id FROM ayat WHERE id = ? ", [7]); | ||
} catch (Exception $e) { | ||
$dbResult = false; | ||
} | ||
|
||
$status = [ | ||
'memcached' => $mcStatus->get() === 'up' ? 'OK' : 'NOT OK', | ||
'database' => $dbResult === false ? 'NOT OK' : 'OK (' . $dbResult['id']. ')', | ||
]; | ||
|
||
if ($mcStatus->get() !== 'up' || $dbResult === false) { | ||
return Http\Response::json($response, | ||
$status, | ||
500 | ||
); | ||
|
||
} | ||
|
||
return Http\Response::json($response, | ||
$status, | ||
200 | ||
); | ||
} | ||
} |
Oops, something went wrong.