diff --git a/Orders/README.md b/Orders/README.md
new file mode 100644
index 0000000..844f452
--- /dev/null
+++ b/Orders/README.md
@@ -0,0 +1,171 @@
+# Orders
+
+**Orders** is a web application written in [React.js](https://reactjs.org) and [Node.js](https://nodejs.org) that, backed by the power of the [MariaDB Node.js Connector](https://github.com/MariaDB/mariadb-connector-nodejs), introduces you to the power, performance, and simplicity of [MariaDB](https://mariadb.com/resources/blog/deploying-mariadb-platform-x4/#smart).
+
+
+
+
+
+
+
+The following will walk you through the steps for getting this application up and running (locally) within minutes! This application is completely open source. Please feel free to use it and the source code as you see fit!
+
+# Table of Contents
+1. [Environment and Compatibility](#compatibility)
+2. [Getting start with MariaDB](#overview)
+ 1. [The Basics](#intro-mariadb)
+ 2. [Create the schema](#create-schema)
+3. [Requirements to run the app](#requirements)
+4. [Getting started with the app](#getting-started)
+ 1. [Grab the code](#grab-code)
+ 2. [Build the code](#build-code)
+ 3. [Run the app](#run-app)
+5. [Support and Contribution](#support-contribution)
+6. [License](#license)
+
+## Environment and Compatibility
+
+This sample was created using the following techologies:
+
+* [MariaDB Platform](https://mariadb.com/products/)
+* [React.js (v.16.12.0)](https://github.com/facebook/react/blob/master/CHANGELOG.md#16120-november-14-2019)
+* [Node.js (v.12.x)](https://nodejs.org/docs/latest-v12.x/api/index.html)
+* [NPM (v.6.11.3)](https://docs.npmjs.com/)
+
+This sample was tested on macOS v.10.14.6.
+
+## Overview
+
+### Introduction to MariaDB
+
+[MariaDB platform](https://mariadb.com/products/mariadb-platform/) unifies [MariaDB TX (transactions)](https://mariadb.com/products/mariadb-platform-transactional/) and [MariaDB AX (analytics)](https://mariadb.com/products/mariadb-platform-analytical/) so transactional applications can retain unlimited historical data and leverage powerful, real-time analytics in order to provide data-driven customers with more information, actionable insight and greater value – and businesses with endless ways to monetize data. It is the enterprise open source database for hybrid transactional/analytical processing at scale.
+
+
+
+
+
+
+
+### Getting start with MariaDB
+
+To download and deploy MariaDB HTAP check out the instructions [here](https://mariadb.com/docs/deploy/installation/). You can also make use of the [MariaDB Image available on Docker Hub](https://hub.docker.com/_/mariadb).
+
+### Create the schema
+
+Next you can create the schema necessary for this application by running
+
+```
+$ ./create_schema.sh
+```
+
+or executing the SQL within (create.sql)(schema/create.sql) directly
+
+```sql
+CREATE DATABASE `orders`;
+
+CREATE TABLE `orders` (
+ `description` varchar(100) NOT NULL DEFAULT ''
+) ENGINE=InnoDB;
+```
+
+## Requirements to run the app
+
+This project assumes you have familiarity with building web applications using [ReactJS](https://reactjs.org) and [NodeJS](https://nodejs.org) technologies.
+
+The following is required to run this application:
+
+1. [Download and install MariaDB](#installation).
+2. [Download and install Node.js](https://nodejs.org/en/download/).
+3. git (Optional) - this is required if you would prefer to pull the source code from GitHub repo.
+ - Create a [free github account](https://github.com/) if you don’t already have one
+ - git can be downloaded from git-scm.org
+
+## Getting started with the app
+
+### Grab the code
+
+Download this code directly or use [git](git-scm.org) (through CLI or a client) to retrieve the code.
+
+### Configure the code
+
+Configure the MariaDB connection by [adding an .env file to the Node.js project](https://github.com/mariadb-corporation/mariadb-connector-nodejs/blob/master/documentation/promise-api.md#security-consideration).
+
+Example implementation:
+
+```
+DB_HOST=
+DB_PORT=
+DB_USER=
+DB_PASS=
+DB_NAME=
+```
+
+The environmental variables from `.env` are used within the [db.js](src/db.js) for the MariaDB Node.js Connector configuration pool settings:
+
+```javascript
+var mariadb = require('mariadb');
+require('dotenv').config();
+
+const pool = mariadb.createPool({
+ host: process.env.DB_HOST,
+ user: process.env.DB_USER,
+ password: process.env.DB_PASS,
+ port: process.env.DB_PORT,
+ multipleStatements: true,
+ connectionLimit: 5
+});
+```
+
+### Build the code
+
+Once you have retrieved a copy of the code you're ready to build and run the project! However, before running the code it's important to point out that the application uses several Node Packages.
+
+Executing the CLI command
+
+```
+$ npm install
+```
+
+within
+
+* [src](src): the Node.js project
+* [client](src/client): the React.js project
+
+folders will target the the relative `package.json` file and [install all dependencies](https://docs.npmjs.com/downloading-and-installing-packages-locally).
+
+### Run the app
+
+Once you've pulled down the code and have verified that all of the required Node packages are installed you're ready to run the application! It's as easy as 1,2,3.
+
+1. Using a command line interface (CLI) navigate to the [src](src) directory.
+
+
+
+
+
+2. Run the command:
+
+```bash
+$ npm start
+```
+
+
+
+
+
+3. Open a browser window and navigate to http://localhost:3000.
+
+
+
+
+
+
+
+## Support and Contribution
+
+Thanks so much for taking a look at the Bookings app! As this is a very simple example, there's plenty of potential for customization. Please feel free to submit PR's to the project to include your modifications!
+
+If you have any questions, comments, or would like to contribute to this or future projects like this please reach out to us directly at developers@mariadb.com or on [Twitter](https://twitter.com/mariadb).
+
+## License
+[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=plastic)](https://opensource.org/licenses/Apache-2.0)
\ No newline at end of file
diff --git a/Orders/create_schema.sh b/Orders/create_schema.sh
new file mode 100644
index 0000000..c6c55ca
--- /dev/null
+++ b/Orders/create_schema.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+SCHEMA_DIR=$(readlink -f ./schema)
+
+# create orders database and table
+/usr/bin/mysql --defaults-file=/etc/my.cnf -u root -vvv < $SCHEMA_DIR/create.sql
\ No newline at end of file
diff --git a/Orders/media/cli_root.png b/Orders/media/cli_root.png
new file mode 100644
index 0000000..4eb98df
Binary files /dev/null and b/Orders/media/cli_root.png differ
diff --git a/Orders/media/demo.gif b/Orders/media/demo.gif
new file mode 100644
index 0000000..12a3de4
Binary files /dev/null and b/Orders/media/demo.gif differ
diff --git a/Orders/media/get_started.png b/Orders/media/get_started.png
new file mode 100644
index 0000000..cd086b8
Binary files /dev/null and b/Orders/media/get_started.png differ
diff --git a/Orders/media/npm_start.png b/Orders/media/npm_start.png
new file mode 100644
index 0000000..b51c161
Binary files /dev/null and b/Orders/media/npm_start.png differ
diff --git a/Orders/media/platform.png b/Orders/media/platform.png
new file mode 100644
index 0000000..5189f12
Binary files /dev/null and b/Orders/media/platform.png differ
diff --git a/Orders/schema/create.sql b/Orders/schema/create.sql
new file mode 100644
index 0000000..e3e7f2b
--- /dev/null
+++ b/Orders/schema/create.sql
@@ -0,0 +1,5 @@
+CREATE DATABASE `orders`;
+
+CREATE TABLE `orders` (
+ `description` varchar(100) NOT NULL DEFAULT ''
+) ENGINE=InnoDB;
\ No newline at end of file
diff --git a/Orders/src/client/public/favicon.ico b/Orders/src/client/public/favicon.ico
index a11777c..89b54a8 100644
Binary files a/Orders/src/client/public/favicon.ico and b/Orders/src/client/public/favicon.ico differ
diff --git a/Orders/src/client/public/index.html b/Orders/src/client/public/index.html
index aa069f2..13346fa 100644
--- a/Orders/src/client/public/index.html
+++ b/Orders/src/client/public/index.html
@@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
- React App
+ Orders
diff --git a/Orders/src/db.js b/Orders/src/db.js
index f287f03..284d47a 100644
--- a/Orders/src/db.js
+++ b/Orders/src/db.js
@@ -1,23 +1,20 @@
const fs = require("fs");
var mariadb = require('mariadb');
+require('dotenv').config();
-// Place a .pem file within the project root to use this line
+// For SSL connections
//const serverCert = [fs.readFileSync("skysql_chain.pem", "utf8")];
var pools = [
mariadb.createPool({
- host: '',
- user:'',
- password: '',
- database: 'orders',
- port: 5001,
+ host: process.env.DB_HOST_1,
+ user: process.env.DB_USER_1,
+ password: process.env.DB_PASS_1,
+ port: process.env.DB_PORT_1,
+ database: process.env.DB_NAME_1,
multipleStatements: true,
- connectionLimit: 5,
- ssl: {
- //ca: serverCert
- rejectUnauthorized: false
- }
- }),
+ connectionLimit: 5
+ })/*,
mariadb.createPool({
host: '',
user:'',
@@ -27,33 +24,19 @@ var pools = [
multipleStatements: true,
connectionLimit: 5,
ssl: {
- //ca: serverCert
- rejectUnauthorized: false
+ ca: serverCert
}
- }),
- mariadb.createPool({
- host: '',
- user:'',
- password: '',
- database: 'orders',
- port: 5003,
- multipleStatements: true,
- connectionLimit: 5,
- ssl: {
- //ca: serverCert
- rejectUnauthorized: false
- }
- })
+ })*/
];
module.exports={
- getConnection: function(config_id){
- return new Promise(function(resolve,reject){
- pools[config_id].getConnection().then(function(connection){
- resolve(connection);
- }).catch(function(error){
- reject(error);
- });
+ getConnection: function(config_id){
+ return new Promise(function(resolve,reject){
+ pools[config_id].getConnection().then(function(connection){
+ resolve(connection);
+ }).catch(function(error){
+ reject(error);
});
- }
- }
\ No newline at end of file
+ });
+ }
+}
\ No newline at end of file
diff --git a/Orders/src/package-lock.json b/Orders/src/package-lock.json
index 0511e67..754e487 100644
--- a/Orders/src/package-lock.json
+++ b/Orders/src/package-lock.json
@@ -10,9 +10,9 @@
"integrity": "sha512-wE2v81i4C4Ol09RtsWFAqg3BUitWbHSpSlIo+bNdsCJijO9sjme+zm+73ZMCa/qMC8UEERxzGbvmr1cffo2SiQ=="
},
"@types/node": {
- "version": "12.12.22",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.22.tgz",
- "integrity": "sha512-r5i93jqbPWGXYXxianGATOxTelkp6ih/U0WVnvaqAvTqM+0U6J3kw6Xk6uq/dWNRkEVw/0SLcO5ORXbVNz4FMQ=="
+ "version": "13.1.8",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.8.tgz",
+ "integrity": "sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A=="
},
"accepts": {
"version": "1.3.7",
@@ -183,6 +183,11 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
+ "dotenv": {
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
+ "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
+ },
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@@ -370,12 +375,12 @@
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
},
"mariadb": {
- "version": "2.1.4",
- "resolved": "https://registry.npmjs.org/mariadb/-/mariadb-2.1.4.tgz",
- "integrity": "sha512-CMLbIKZCzxero94luo25IKpboEuUCvA2g2+NMUBdRYpBCDmnsiQ8kwdgqvuVQ13a4/ZKr87BC1nbe4b3UZXXmQ==",
+ "version": "2.1.5",
+ "resolved": "https://registry.npmjs.org/mariadb/-/mariadb-2.1.5.tgz",
+ "integrity": "sha512-uRHtjc0bg+Rt91LvIaZNo8tLcYs9YPiiW9Mke/BavFzg0MnctJBDkqZW9X59NyrRGDd7Oz9UshTWgmUpfDZc0Q==",
"requires": {
"@types/geojson": "^7946.0.7",
- "@types/node": "^12.12.11",
+ "@types/node": "^13.1.4",
"denque": "^1.4.1",
"iconv-lite": "^0.5.0",
"long": "^4.0.0",
@@ -383,9 +388,9 @@
},
"dependencies": {
"iconv-lite": {
- "version": "0.5.0",
- "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.5.0.tgz",
- "integrity": "sha512-NnEhI9hIEKHOzJ4f697DMz9IQEXr/MMJ5w64vN2/4Ai+wRnvV7SBrL0KLoRlwaKVghOc7LQ5YkPLuX146b6Ydw==",
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.5.1.tgz",
+ "integrity": "sha512-ONHr16SQvKZNSqjQT9gy5z24Jw+uqfO02/ngBSBoqChZ+W8qXX7GPRa1RoUnzGADw8K63R1BXUMzarCVQBpY8Q==",
"requires": {
"safer-buffer": ">= 2.1.2 < 3"
}
diff --git a/Orders/src/package.json b/Orders/src/package.json
index 930cf16..f530b8f 100644
--- a/Orders/src/package.json
+++ b/Orders/src/package.json
@@ -13,7 +13,8 @@
"dependencies": {
"body-parser": "^1.19.0",
"concurrently": "^5.0.2",
+ "dotenv": "^8.2.0",
"express": "^4.17.1",
- "mariadb": "^2.1.4"
+ "mariadb": "^2.1.5"
}
}
diff --git a/Orders/src/routes/ordersRoutes.js b/Orders/src/routes/ordersRoutes.js
index f80bfd6..1bdb4e2 100644
--- a/Orders/src/routes/ordersRoutes.js
+++ b/Orders/src/routes/ordersRoutes.js
@@ -6,37 +6,44 @@ let express = require("express"),
// GET
router.get("/", async (req, res, next) => {
- let connection_id = req.query.c;
+ // Set the query string parameters
let read_count = req.query.r;
let write_count = req.query.w;
+ let connection_id = req.query.c;
let conn;
try {
+ // Establish connection to SkySQL using the db.js module
conn = await pool.getConnection(connection_id);
- let reads = "";
+ let reads = "";
let writes = "";
- // reads
+ // Create 0-N read queries
for (let i = 0; i < read_count; i++) {
reads += "select * from orders limit 1;";
}
- // writes
+ // Create 0-N write queries
let transaction_id = Date.now().toString();
for (let i = 0; i < write_count; i++) {
writes += "insert into orders (description) values('order - " + transaction_id + "');";
}
+ // Start latency timer
var start = Date.now();
+ // Asynchronously execute read and write queries
await Promise.all([conn.query(reads), conn.query(writes)]);
+ // Calculate latency
var delta = Date.now() - start;
+ // Return the results
res.send({ execution_time: delta });
} catch (err) {
throw err;
} finally {
+ // Release (close) the connection
if (conn) return conn.release();
}
});
diff --git a/Orders/src/skysql_chain.pem b/Orders/src/skysql_chain.pem
new file mode 100644
index 0000000..71d213a
--- /dev/null
+++ b/Orders/src/skysql_chain.pem
@@ -0,0 +1,48 @@
+-----BEGIN CERTIFICATE-----
+MIIELzCCAxegAwIBAgIUNz1kWFjbLVDWVCBnEAsf95UPMS8wDQYJKoZIhvcNAQEL
+BQAwQTEQMA4GA1UEChMHTWFyaWFEQjEPMA0GA1UECxMGU2t5U1FMMRwwGgYDVQQD
+ExNyb290LXBraS5za3lzcWwubmV0MB4XDTE5MDkwNTE4MjMxMVoXDTI5MDkwMjE4
+MjM0MFowQTEQMA4GA1UEChMHTWFyaWFEQjEPM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