Skip to content

Commit

Permalink
Rest API done without Oauth 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adriano-pinaffo committed Apr 25, 2022
0 parents commit 7183313
Show file tree
Hide file tree
Showing 18 changed files with 752 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
OKTAAUDIENCE=api://default
OKTAISSUER=
SCOPE=
OKTACLIENTID=
OKTASECRET=
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
31 changes: 31 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"root": true,
"env": {
"browser": true,
"es6": true
},
"extends": ["prettier", "plugin:node/recommended", "plugin:json/recommended"],
"plugins": ["prettier"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module"
},
"rules": {
"prettier/prettier": "warn",
"linebreak-style": "off",
"no-unused-vars": "warn",
"no-plusplus": "off",
"spaced-comment": "off",
"func-names": "off",
"object-shorthand": "off",
"no-param-reassign": ["error", { "props": false }],
"node/no-unsupported-features/es-syntax": "off",
"quotes": ["warn", "single"],
"semi": ["error", "always", {"omitLastInOneLineBlock": true}],
"node/no-unpublished-require": "off"
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
.env
*.swp
*.vim
20 changes: 20 additions & 0 deletions .htmlhintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"tagname-lowercase": true,
"attr-lowercase": true,
"attr-value-double-quotes": true,
"doctype-first": true,
"tag-pair": true,
"spec-char-escape": true,
"id-unique": true,
"src-not-empty": true,
"attr-no-duplication": true,
"title-require": true,
"head-script-disabled": true,
"alt-require": true,
"doctype-html5": true,
"inline-style-disabled": true,
"inline-script-disabled": true,
"space-tab-mixed-disabled": "true",
"id-class-ad-disabled": true,
"spec-char-escape": false
}
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"singleQuote": true,
"arrowParens": "avoid"
}
8 changes: 8 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "stylelint-config-standard-scss",
"rules": {
"alpha-value-notation": "off",
"selector-class-pattern": false,
"comment-empty-line-before": "off"
}
}
14 changes: 14 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
require 'vendor/autoload.php';
use Dotenv\Dotenv;
use Src\System\DatabaseConnector;

$dotenv = new DotEnv(__DIR__);
$dotenv->load();

// run with $php bootstrap.php
//echo getenv('OKTAAUDIENCE');

$dbConnection = (new DatabaseConnector())->getConnection();
//print_r($dbConnection);
?>
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"require": {
"vlucas/phpdotenv": "^2.4"
},
"autoload": {
"psr-4": {
"Src\\": "src/"
}
}
}
177 changes: 177 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions dbseed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
require 'bootstrap.php';

$statement = <<<EOF
CREATE TABLE IF NOT EXISTS person(
id INT NOT NULL AUTO_INCREMENT,
firstname VARCHAR(100) NOT NULL,
lastname VARCHAR(100) NOT NULL,
firstparent_id INT DEFAULT NULL,
secondparent_id INT DEFAULT NULL,
PRIMARY KEY(id),
FOREIGN KEY(firstparent_id) REFERENCES person(id) ON DELETE SET NULL,
FOREIGN KEY(secondparent_id) REFERENCES person(id) ON DELETE SET NULL
) ENGINE=INNODB;
INSERT INTO person
(firstname, lastname, firstparent_id, secondparent_id)
VALUES
('Krasimir', 'Hristozov', null, null),
('Maria', 'Hristozova', null, null),
('Masha', 'Hristozova', 1, 2),
('Jane', 'Smith', null, null),
('John', 'Smith', null, null),
('Richard', 'Smith', 4, 5),
('Donna', 'Smith', 4, 5),
('Josh', 'Harrelson', null, null),
('Anna', 'Harrelson', 7, 8);
EOF;

try {
$dbConnection->exec($statement);
echo "Seeded with success!\n";
} catch(\PDOException $e) {
exit($e->getMessage());
}
?>
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "testing-polyfill",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
},
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": ">=6.8.0",
"eslint-config-airbnb": ">=18.1.0",
"eslint-config-node": ">=4.0.0",
"eslint-config-prettier": ">=6.11.0",
"eslint-plugin-import": ">=2.20.2",
"eslint-plugin-json": ">=3.1.0",
"eslint-plugin-jsx-a11y": ">=6.2.3",
"eslint-plugin-node": ">=11.1.0",
"eslint-plugin-prettier": ">=3.1.3",
"eslint-plugin-react": ">=7.20.0",
"eslint-plugin-react-hooks": ">=2.5.0",
"fecs": ">=1.6.4",
"htmlhint": ">=0.16.0",
"jsonlint": ">=1.6.3",
"lehre": ">=1.3.5",
"prettier": ">=2.0.5",
"stylelint": ">=13.5.0",
"stylelint-config-standard": ">=20.0.0",
"stylelint-config-standard-scss": ">=2.0.1"
},
"keywords": [],
"description": ""
}
22 changes: 22 additions & 0 deletions prepare_database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mysql -uroot -p
CREATE DATABASE api_example CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'api_user'@'localhost' identified by 'api_password';
GRANT ALL on api_example.* to 'api_user'@'localhost';
quit

mysql -uapi_user -papi_password api_example

CREATE TABLE person (
id INT NOT NULL AUTO_INCREMENT,
firstname VARCHAR(100) NOT NULL,
lastname VARCHAR(100) NOT NULL,
firstparent_id INT DEFAULT NULL,
secondparent_id INT DEFAULT NULL,
PRIMARY KEY (id),
FOREIGN KEY (firstparent_id)
REFERENCES person(id)
ON DELETE SET NULL,
FOREIGN KEY (secondparent_id)
REFERENCES person(id)
ON DELETE SET NULL
) ENGINE=INNODB;
Loading

0 comments on commit 7183313

Please sign in to comment.