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
const Axios = require('axios'); | |
class Weather { | |
constructor() { } | |
async getWeather(cityName = 'Lagos') { | |
const ApiKey = 'YOUR_OPEN_WEATHER_API_KEY'; | |
const Url = `http://api.openweathermap.org/data/2.5/weather?q=${cityName}&appid=${ApiKey}`; | |
await Axios.get(Url) |
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
async checkNote(title) { | |
const dbConnection = await this.createConnection(); | |
return dbConnection.collection('notes_db').findOne({ title }).then((doc) => { | |
if (doc) { | |
return true; | |
} else { | |
return false; | |
} | |
}).catch((e) => { | |
console.log('*********** Error ***********'); |
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
{ | |
"require": { | |
"klein/klein": "^2.1", | |
"firebase/php-jwt": "^5.2" | |
}, | |
"autoload": { | |
"psr-4": { | |
"App\\": "App/" | |
}, | |
"classmap": [ |
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
<?php | |
/** | |
* @author Ilori Stephen A | |
**/ | |
require_once __DIR__ . '/vendor/autoload.php'; | |
require_once __DIR__ . '/App/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
<?php | |
namespace App; | |
use App\UserController; | |
use App\CatalogController; | |
use App\ProductController; | |
$Klein = new \Klein\Klein(); | |
/******************** User Routes || Authentication Routes **********************/ | |
$Klein->respond('POST', '/api/v1/user', [ new UserController(), 'createNewUser' ]); |
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
<?php | |
namespace App; | |
use PDO; | |
use Exception; | |
/** | |
* Model - The Base Model for all other Models.... All Other Model extends this Model. | |
* | |
* @author Ilori Stephen A <stephenilori458@gmail.com> |
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
<?php | |
namespace App; | |
use App\Model; | |
/** | |
* UserModel - This Model is consumed basically by the UserController and is also consumed by other controllers and Middlewares... | |
* | |
* @author Ilori Stephen A <stephenilori458@gmail.com> | |
* @link https://github.com/learningdollars/php-rest-api/App/Model/UserModel.php | |
* @license MIT |
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
<?php | |
namespace App; | |
use App\Model; | |
/** | |
* TokenModel - This Model is consumed basically by the UserController and is also consumed by other controllers and Middlewares... | |
* | |
* @author Ilori Stephen A <stephenilori458@gmail.com> | |
* @link https://github.com/learningdollars/php-rest-api/App/Model/TokenModel.php | |
* @license MIT |
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
<?php | |
namespace App; | |
use App\Model; | |
/** | |
* CatalogModel - A Model for the Catalog Controller. | |
* | |
* @author Ilori Stephen A <stephenilori458@gmail.com> | |
* @link https://github.com/learningdollars/php-rest-api/App/Model/CatalogModel.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
<?php | |
namespace App; | |
use App\Model; | |
/** | |
* ProductModel - This Model is consumed basically by the ProductController and is also consumed by other controllers... | |
* | |
* @author Ilori Stephen A <stephenilori458@gmail.com> | |
* @link https://github.com/learningdollars/php-rest-api/App/Model/ProductModel.php |