-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Jean20jp/dev
Dev into main
- Loading branch information
Showing
56 changed files
with
7,797 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RewriteEngine On | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule ^(.*)$ index.php [QSA,L] | ||
RewriteEngine On | ||
RewriteRule ^(.*)$ index.php |
File renamed without changes.
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,6 @@ | ||
{ | ||
"require": { | ||
"firebase/php-jwt": "^6.10", | ||
"flightphp/core": "^3.6" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,5 @@ | ||
<?php | ||
|
||
require_once 'src/routes/api.php'; | ||
|
||
?> |
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,41 @@ | ||
|
||
<?php | ||
|
||
// Variables de entorno para la configuración de la app | ||
class EnvironmentVariables { | ||
|
||
private $DB_HOST = "localhost"; | ||
private $DB_NAME = "testeoapi_db"; | ||
private $DB_USER = "root"; | ||
private $DB_PASSWORD = ""; | ||
|
||
private $KEY_JWT = "asdfghjkl_k1"; | ||
private $ALGORITHM_JWT = "HS256"; | ||
|
||
public function getHost() { | ||
return $this->DB_HOST; | ||
} | ||
|
||
public function getNameDb() { | ||
return $this->DB_NAME; | ||
} | ||
|
||
public function getUserDb() { | ||
return $this->DB_USER; | ||
} | ||
|
||
public function getPasswordDb() { | ||
return $this->DB_PASSWORD; | ||
} | ||
|
||
public function getKeyJwt() { | ||
return $this->KEY_JWT; | ||
} | ||
|
||
public function getAlgJwt() { | ||
return $this->ALGORITHM_JWT; | ||
} | ||
|
||
} | ||
|
||
?> |
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,17 @@ | ||
<?php | ||
|
||
// Carga util de jwt | ||
define('ISS', 'localhost'); // dominio emisor (opcional) | ||
define('AUD', 'CLIENTS'); // audiencia (opcional) | ||
define('IAT', time()); // momento en el que se emiitio (opcional) | ||
define('NBF', time() + 1); // debe ser posterios a la fecha actual (opcional) | ||
define('EXP', time() + 604800); // tiempo de expiracion se suma en segundos (opcional) | ||
|
||
// Status Codes | ||
define('SUCCESS_RESPONSE', 200); | ||
define('ACCESS_DENIED', 401); | ||
define('BAD_REQUEST', 400); | ||
define('FORBIDDEN', 403); | ||
|
||
|
||
?> |
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,31 @@ | ||
<?php | ||
|
||
require_once '../api-rest/src/data/DatabaseJsonResponse.php'; | ||
|
||
class UserController { | ||
|
||
private $dbJsonResponse; | ||
|
||
public function __construct() { | ||
|
||
$this->dbJsonResponse = new DatabaseJsonResponse(); | ||
} | ||
|
||
public function login($email, $password) { | ||
|
||
return $this->dbJsonResponse->loginUser($email, $password); | ||
} | ||
|
||
public function registerUser($user) { | ||
|
||
return $this->dbJsonResponse->registerUser($user); | ||
} | ||
|
||
public function getUsers($headers) { | ||
|
||
return $this->dbJsonResponse->getUsers($headers); | ||
} | ||
|
||
} | ||
|
||
?> |
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,39 @@ | ||
<?php | ||
|
||
include_once '../api-rest/src/config/EnvironmentVariables.php'; | ||
require 'vendor/autoload.php'; | ||
|
||
// Clase para realizar conexión con patron singleton | ||
class DatabaseConexion { | ||
|
||
private static $instance = null; | ||
private $connection; | ||
private $envVariables; | ||
|
||
// Constructor privado para evitar instanciación directa | ||
private function __construct() { | ||
$this->envVariables = new EnvironmentVariables(); | ||
} | ||
|
||
// Método estático para obtener la instancia única de la clase | ||
public static function getInstance() { | ||
if (self::$instance == null) { | ||
self::$instance = new DatabaseConexion(); | ||
} | ||
return self::$instance; | ||
} | ||
|
||
// Retorna la conexion, si es nula la crea | ||
public function getConnection() { | ||
if ($this->connection == null) { | ||
$this->connection = Flight::register('database', 'PDO', array( | ||
'mysql:host=' . $this->envVariables->getHost() . ';dbname=' . $this->envVariables->getNamedb(), | ||
$this->envVariables->getUserDb(), | ||
$this->envVariables->getPasswordDb() | ||
)); | ||
} | ||
return $this->connection; | ||
} | ||
} | ||
|
||
?> |
Oops, something went wrong.