Skip to content

Instantly share code, notes, and snippets.

View harryWonder's full-sized avatar
🇳🇬
I am that software developer that you cannot sideline. I am <harrywonder/>

Ilori stephen harryWonder

🇳🇬
I am that software developer that you cannot sideline. I am <harrywonder/>
View GitHub Profile
@harryWonder
harryWonder / Weather.js
Last active January 18, 2022 16:48
This class makes use of the axios module to query the openWeather api to get information about the weather of a particular city.
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)
@harryWonder
harryWonder / Notes.js
Created June 4, 2020 08:57
The checkNote method from the Notes.js file
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 ***********');
@harryWonder
harryWonder / package.json
Created July 5, 2020 23:08
Php REST API package.json file.
{
"require": {
"klein/klein": "^2.1",
"firebase/php-jwt": "^5.2"
},
"autoload": {
"psr-4": {
"App\\": "App/"
},
"classmap": [
@harryWonder
harryWonder / index.php
Created July 5, 2020 23:30
The Entry point into the php-rest-api application
<?php
/**
* @author Ilori Stephen A
**/
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/App/routes/api.php';
?>
@harryWonder
harryWonder / api.php
Created July 5, 2020 23:40
The endpoints for the php-rest-api application
<?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' ]);
@harryWonder
harryWonder / Model.php
Created July 6, 2020 00:11
The Base Model for the php-rest-api application.
<?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>
@harryWonder
harryWonder / UserModel.php
Created July 6, 2020 00:32
The UserModel. This Model is responsible for creating, deleting, updating and fetching users.
<?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
@harryWonder
harryWonder / TokenModel.php
Created July 6, 2020 01:01
The TokenModel file for the php-rest-api application which is responsible for managing the API access token
<?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
@harryWonder
harryWonder / CatalogModel.php
Created July 6, 2020 01:30
The CatalogModel file. This file houses a class which makes it possible to create, update, delete and fetch catalogs
<?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
@harryWonder
harryWonder / ProductModel.php
Created July 6, 2020 02:02
The ProductModel file for the php-rest-api application.
<?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