From c073e9639fda22037b540e04afee883b4744d8e7 Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 26 Mar 2019 14:18:12 +0200 Subject: [PATCH 01/57] add Dockerfile --- Dockerfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4f8b6a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# Use an official Python runtime as a parent image +#FROM mysql:8.0 +FROM node + +# Install any needed packages specified in requirements.txt +RUN npm install + +# Make port 80 available to the world outside this container +#EXPOSE 80 + +# Define environment variable +#ENV NAME World + +# Run app.py when the container launches +#CMD ["python", "app.py"] +CMD node index.js \ No newline at end of file From eb842b57f8fc0911d35d596f534a07f74676f9f7 Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 26 Mar 2019 15:39:56 +0200 Subject: [PATCH 02/57] added docker support --- Dockerfile | 16 +++++++++++++--- README.md | 26 ++++++++++++-------------- config.json | 6 +++--- dbManipulator.js | 6 ++++-- index.js | 2 +- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4f8b6a2..15476b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,15 +2,25 @@ #FROM mysql:8.0 FROM node +# Create app directory +RUN mkdir -p /src/app +WORKDIR /src/app + # Install any needed packages specified in requirements.txt +COPY package.json /src/app/ RUN npm install -# Make port 80 available to the world outside this container -#EXPOSE 80 +# Bundle app source +COPY . /src/app + +# Make port 8000 available to the world outside this container +EXPOSE 8000 # Define environment variable #ENV NAME World # Run app.py when the container launches #CMD ["python", "app.py"] -CMD node index.js \ No newline at end of file +#CMD ["node", "index.js"] +#CMD ["npm", "run", "start"] +CMD ["npm", "run", "debug"] \ No newline at end of file diff --git a/README.md b/README.md index e690113..0c1bf3b 100644 --- a/README.md +++ b/README.md @@ -10,29 +10,27 @@ git clone https://github.com/iMelki/Json2MySQL.git ### Prerequisites -Node.js - - -### Installing -Download & Install [Node.js](https://nodejs.org/en/) -Go to the directory of the app -Enter the command: -``` -npm install -``` - +Download & Install [Docker](https://www.docker.com/get-started) ## Running the app -Before first run: -Go to the directory of the app. +Navigate to the directory of the app. + +Before first run: Open the configuration file (config.json) and edit it with the arguments of your choise. Choose a database table that fits the Schema, or choose a non-existing one to be created. + + +To build the app, enter the command: +``` +docker build --tag=json2mysql . +``` + Now, this command will run the app on your local machine: ``` -node index.js [%file_path% [%DB_name% [%table_name%]]] +docker run json2mysql ``` Note: to see app's progress with debug comments in the console: diff --git a/config.json b/config.json index 3045149..2f0daa8 100644 --- a/config.json +++ b/config.json @@ -1,8 +1,8 @@ { + "host" : "192.168.99.104", "jsonPath" : "./inputs/accounts.json", - "host" : "localhost", "user" : "root", - "password" : "root", + "password" : "123", "dbName" : "accountsDB", "tblName" : "accounts" -} \ No newline at end of file +} diff --git a/dbManipulator.js b/dbManipulator.js index 7469557..9f7a8bd 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -121,8 +121,10 @@ exports.insertToDB = async function (jsonData) { }; exports.endConnection = async function(){ - await _connection.end(); - debug('connection ended.'); + if (_connection != null){ + await _connection.end(); + debug('connection ended.'); + } } exports.execQry = async function(qry){ diff --git a/index.js b/index.js index ee49c5b..fc297d5 100644 --- a/index.js +++ b/index.js @@ -125,8 +125,8 @@ async function startScript(){ await getTableFromFirstObject(); await startStreaming(); }catch(err){ - await db.endConnection(); console.error(err.message); + await db.endConnection(); } } From 2c42ae986fd8211af3eb97ca998b55575b4832bf Mon Sep 17 00:00:00 2001 From: mac Date: Thu, 28 Mar 2019 18:28:15 +0200 Subject: [PATCH 03/57] switched to Docker & fixed --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 15476b2..e39cecb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Use an official Python runtime as a parent image #FROM mysql:8.0 -FROM node +FROM node:11.12.0 # Create app directory RUN mkdir -p /src/app @@ -23,4 +23,4 @@ EXPOSE 8000 #CMD ["python", "app.py"] #CMD ["node", "index.js"] #CMD ["npm", "run", "start"] -CMD ["npm", "run", "debug"] \ No newline at end of file +CMD ["npm", "run", "debug"] From 85c8b6b7e99a0a824b25bd824df70019d726d48d Mon Sep 17 00:00:00 2001 From: mac Date: Thu, 28 Mar 2019 18:33:51 +0200 Subject: [PATCH 04/57] Dockerfile updated --- Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e39cecb..7fb1128 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -# Use an official Python runtime as a parent image -#FROM mysql:8.0 +# Use an official node version as a parent image FROM node:11.12.0 # Create app directory @@ -17,10 +16,9 @@ COPY . /src/app EXPOSE 8000 # Define environment variable -#ENV NAME World +#ENV DEBUG True -# Run app.py when the container launches -#CMD ["python", "app.py"] +# Run #CMD ["node", "index.js"] #CMD ["npm", "run", "start"] CMD ["npm", "run", "debug"] From d19c2acf8d47b2c708d93f6a8568ff8ed7fda595 Mon Sep 17 00:00:00 2001 From: mac Date: Sun, 31 Mar 2019 15:34:35 +0300 Subject: [PATCH 05/57] some small output changes --- Dockerfile | 2 +- README.md | 8 ++------ index.js | 10 +++++----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7fb1128..8c8f4b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ EXPOSE 8000 # Define environment variable #ENV DEBUG True -# Run +# Run #CMD ["node", "index.js"] #CMD ["npm", "run", "start"] CMD ["npm", "run", "debug"] diff --git a/README.md b/README.md index 0c1bf3b..9bd0806 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,8 @@ Now, this command will run the app on your local machine: ``` docker run json2mysql ``` - -Note: to see app's progress with debug comments in the console: -``` -SET DEBUG=* & node index.js [%file_path% [%DB_name% [%table_name%]]] -``` - + + Where %filePath% should be replaced with the input JSON file path, %DB_name% should be replaced with the database name and %table_name% should be replaced with the table name. diff --git a/index.js b/index.js index fc297d5..856c013 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,7 @@ var i; /** * a handler for inputing config arguments - * @param argNum the index in the process.argv + * @param argNum the index in the process.argv * @param atrName the attribute name inside the config file * @returns true if got input. false, otherwise. */ @@ -86,11 +86,11 @@ async function getTableFromFirstObject(){ }else{ debug((j++)+' : how did you get through the first object?!'); } - })); + })); }); } -//start Streaming and deal with each JSO seperately +//start Streaming and deal with each JSO seperately async function startStreaming(){ return new Promise(function(res, rej){ debug('Streaming all JSOs from the input file..'); @@ -102,7 +102,7 @@ async function startStreaming(){ }catch(err){ console.error(err.message); } - })); + })); }); } @@ -118,7 +118,7 @@ async function finishApp(){ // Main function: async function startScript(){ try{ - console.log('working..'); + console.log('JSON2MySQL started. \nworking..'); await validateInput(); await db.init(config.host, config.user, config.password, config.dbName, config.tblName); await db.runDatabase(); From 9b9c03e2b31805a413c536eea87cf008df95ba1f Mon Sep 17 00:00:00 2001 From: mac Date: Sun, 31 Mar 2019 15:47:52 +0300 Subject: [PATCH 06/57] some small output changes --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 9bd0806..915714f 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,6 @@ docker run json2mysql ``` -Where %filePath% should be replaced with the input JSON file path, -%DB_name% should be replaced with the database name -and %table_name% should be replaced with the table name. -They're not mandatory. If not specified, they'll be taken from the configuration file instead. - - ## Author * **iMelki** From c9f6af88dfdb92dc828ed4a709c99dc1c2f7c29f Mon Sep 17 00:00:00 2001 From: mac Date: Thu, 4 Apr 2019 11:03:55 +0300 Subject: [PATCH 07/57] added codefresh.yaml --- codefresh.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 codefresh.yaml diff --git a/codefresh.yaml b/codefresh.yaml new file mode 100644 index 0000000..5ce6390 --- /dev/null +++ b/codefresh.yaml @@ -0,0 +1,9 @@ +version: '1.0' +steps: + BuildingDockerImage: + title: Building Docker Image + type: build + image_name: ilancodefresh/json2mysql + working_directory: ./ + tag: '${{CF_BRANCH_TAG_NORMALIZED}}' + dockerfile: Dockerfile From f65a3edb1dad8fda867abeaa99bf74ff31f14e62 Mon Sep 17 00:00:00 2001 From: mac Date: Thu, 4 Apr 2019 11:07:12 +0300 Subject: [PATCH 08/57] added codefresh.yml --- codefresh.yaml => codefresh.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename codefresh.yaml => codefresh.yml (100%) diff --git a/codefresh.yaml b/codefresh.yml similarity index 100% rename from codefresh.yaml rename to codefresh.yml From b5b585531308d57458f1a76e4d420cff3188fa9b Mon Sep 17 00:00:00 2001 From: mac Date: Thu, 4 Apr 2019 11:54:40 +0300 Subject: [PATCH 09/57] added "push to Docker Hub" step --- codefresh.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/codefresh.yml b/codefresh.yml index 5ce6390..29e2e7d 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -1,5 +1,6 @@ version: '1.0' steps: + BuildingDockerImage: title: Building Docker Image type: build @@ -7,3 +8,20 @@ steps: working_directory: ./ tag: '${{CF_BRANCH_TAG_NORMALIZED}}' dockerfile: Dockerfile + + PushToDH: + type: push + title: Push Image to Docker Hub + description: Push Docker Image to Docker Hub Registry + candidate: ${{BuildingDockerImage}} + #tag: latest + #image_name: codefresh/app + registry: dockerhub + fail_fast: false + when: + branch: + only: + - master + retry: + maxAttempts: 2 + delay: 5 From 53b523bbeca4f2156e527617edb289b864f60358 Mon Sep 17 00:00:00 2001 From: mac Date: Sun, 14 Apr 2019 14:37:33 +0300 Subject: [PATCH 10/57] added docker-compose --- Dockerfile | 2 ++ docker-compose.yml | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 8c8f4b0..0b708d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,8 @@ EXPOSE 8000 # Define environment variable #ENV DEBUG True +VOLUME ["/var/lib/docker/volumes/jtmVol"] + # Run #CMD ["node", "index.js"] #CMD ["npm", "run", "start"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c541e30 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '2' +services: + db: + image: mysql:5.7 + restart: always + environment: + MYSQL_DATABASE: 'db' + MYSQL_USER: 'user' + MYSQL_PASSWORD: 'password' + MYSQL_ROOT_PASSWORD: 'password' + ports: + - '3306:3306' + expose: + - '3306' + volumes: + - my-db:/var/lib/mysql + + web: + build: . + + +volumes: + my-db: From f179ff25cbe19fb61108c20df4aa9ac83bf23a60 Mon Sep 17 00:00:00 2001 From: mac Date: Mon, 15 Apr 2019 10:30:24 +0300 Subject: [PATCH 11/57] merging before branching --- codefresh.yml | 11 +++++++++-- docker-compose.yml | 5 +++-- package.json | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/codefresh.yml b/codefresh.yml index 29e2e7d..57ebad2 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -1,7 +1,7 @@ version: '1.0' steps: - BuildingDockerImage: + MyAppDockerImage: title: Building Docker Image type: build image_name: ilancodefresh/json2mysql @@ -9,11 +9,18 @@ steps: tag: '${{CF_BRANCH_TAG_NORMALIZED}}' dockerfile: Dockerfile + MyUnitTests: + title: Running Unit tests + stage: test + image: ${{MyAppDockerImage}} + commands: + - npm run test + PushToDH: type: push title: Push Image to Docker Hub description: Push Docker Image to Docker Hub Registry - candidate: ${{BuildingDockerImage}} + candidate: ${{MyAppDockerImage}} #tag: latest #image_name: codefresh/app registry: dockerhub diff --git a/docker-compose.yml b/docker-compose.yml index c541e30..49b8d1e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,11 +13,12 @@ services: expose: - '3306' volumes: - - my-db:/var/lib/mysql + - jtmVol:/var/lib/docker/volumes/jtmVol + #- my-db:/var/lib/mysql web: build: . volumes: - my-db: + jtmVol: diff --git a/package.json b/package.json index d583712..aec4058 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,9 @@ "description": "input: JSON file path. The app creates a MySQL DB that holds the data from the input file.", "main": "index.js", "scripts": { + "test": "echo \"Running tests..\" ", "test1": "echo \"Error: no test specified\" && exit 1", - "test": "SET DEBUG=DB,test & mocha tests/app.test.js", + "test2": "SET DEBUG=DB,test & mocha tests/app.test.js", "debug": "SET DEBUG=* & node index.js", "start": "node index.js" }, From 31128c5d276aed5ef2a37e1d4fa8f2cf863f931f Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 16 Apr 2019 17:44:05 +0300 Subject: [PATCH 12/57] established server --- Dockerfile | 2 +- app.js | 46 +++++ dbManipulator.js | 28 +-- index.js => jsonToMySQL.js | 27 +-- package-lock.json | 387 +++++++++++++++++++++++++++++++++++++ package.json | 10 +- routes/index.js | 14 ++ server.js | 109 +++++++++++ 8 files changed, 594 insertions(+), 29 deletions(-) create mode 100644 app.js rename index.js => jsonToMySQL.js (89%) create mode 100644 routes/index.js create mode 100644 server.js diff --git a/Dockerfile b/Dockerfile index 0b708d9..3b37117 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,4 +23,4 @@ VOLUME ["/var/lib/docker/volumes/jtmVol"] # Run #CMD ["node", "index.js"] #CMD ["npm", "run", "start"] -CMD ["npm", "run", "debug"] +CMD ["npm", "run", "server"] diff --git a/app.js b/app.js new file mode 100644 index 0000000..35ad59d --- /dev/null +++ b/app.js @@ -0,0 +1,46 @@ +/* +//Outers: +const express = require('express'); +var createError = require('http-errors'); +var path = require('path'); +var debug = require('debug')('app'); + +//Insiders: +const jsonToMySQL = require('./jsonToMySQL.js'); +var indexRouter = require('./routes/index'); + + +const app = express(); + +const port = 3000; +app.listen(port, () => console.log(`Example app listening on port ${port}!`)); + +const data = jsonToMySQL.startScript(); + +//Set up MySQL connection: +// currently in the original file + +// view engine setup +app.set('views', path.join(__dirname, 'views')); +app.set('view engine', 'pug'); + +app.use('/', indexRouter); + +// catch 404 and forward to error handler +app.use(function(req, res, next) { + next(createError(404)); +}); + +// error handler +app.use(function(err, req, res, next) { + // set locals, only providing error in development + res.locals.message = err.message; + res.locals.error = req.app.get('env') === 'development' ? err : {}; + + // render the error page + res.status(err.status || 500); + res.render('error'); +}); + +module.exports = app; +*/ diff --git a/dbManipulator.js b/dbManipulator.js index 9f7a8bd..a711a78 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -1,7 +1,7 @@ // Require modules: -var mysql = require('promise-mysql'); -var debug = require('debug')('DB'); +const mysql = require('promise-mysql'); +const debug = require('debug')('DB'); var _connection; var _host = ""; @@ -25,20 +25,20 @@ exports.init = async function(hostStr, userStr, pwStr, dbName, tblName){ [_host, _user, _password, _dbName, _tblName] = [hostStr, userStr, pwStr, dbName, tblName]; } -// Start all functions sequentially +// Start all functions sequentially /** - * + * */ exports.runDatabase = async function(){ _connection = await crtConnection(); //await connectToDB(); await createDB(); } - + /** * buildTable gets a JSO * and creates a MySQL Table accordingly to its indices - * @param {Object} obj - the JSO + * @param {Object} obj - the JSO */ exports.buildTable = async function(obj){ debug('Building Table..'); @@ -55,21 +55,21 @@ exports.buildTable = async function(obj){ i++; } //execute query: - try{ + try{ await _connection.query(sqlQry); debug('Table created!'); return true; }catch(err){ throw new Error('Error! Failed creating table "'+ _tblName+'" inside DB "'+_dbName+'".'); } - + } /** * insertToDB gets a JSO * build & exec an insert MySQL query - * @param {String} tableName - the table to insert to - * @param {Object} jsonData - the JSO + * @param {String} tableName - the table to insert to + * @param {Object} jsonData - the JSO */ exports.insertToDB = async function (jsonData) { //if(showConsoleComments) console.log("insert Qry:"); @@ -119,7 +119,7 @@ exports.insertToDB = async function (jsonData) { throw new Error('mysql-json [insert]: Require JSON data'); } }; - + exports.endConnection = async function(){ if (_connection != null){ await _connection.end(); @@ -133,7 +133,7 @@ exports.execQry = async function(qry){ } // Accessory Functions: -/////////////////////// +/////////////////////// // Create DB Connection async function crtConnection(){ @@ -148,7 +148,7 @@ async function crtConnection(){ throw new Error("Error creating DB connection"); } return connection; - + } /* @@ -231,7 +231,7 @@ Object.size = function(obj) { * and extracts its indices OR values to MySQL query * @param {String} type - the type to insert ('index', 'value' OR 'createTable') * @param {Object} jso - * @param {String} mainIndex - the index of the JSO itself + * @param {String} mainIndex - the index of the JSO itself * to add to the indices' column names in the MySQL query */ var JSOToStr = function(type, jso, mainIndex){ diff --git a/index.js b/jsonToMySQL.js similarity index 89% rename from index.js rename to jsonToMySQL.js index 856c013..79a18dc 100644 --- a/index.js +++ b/jsonToMySQL.js @@ -1,15 +1,17 @@ // Require modules: -var fs = require( "fs" ); -var JSONStream = require( "JSONStream" ); -var es = require('event-stream'); -var debug = require('debug')('Main'); -var path = require('path'); +const fs = require( "fs" ); +const JSONStream = require( "JSONStream" ); +const es = require('event-stream'); +const debug = require('debug')('Main'); +const path = require('path'); + + // Require Configuration settings: -var config = require('./config.js'); +const config = require('./config.js'); // Require DB Connection: -var db = require('./dbManipulator'); +const db = require('./dbManipulator'); var first = true; var i; @@ -90,11 +92,11 @@ async function getTableFromFirstObject(){ }); } -//start Streaming and deal with each JSO seperately +//start Streaming and deal with each JSO separately async function startStreaming(){ return new Promise(function(res, rej){ debug('Streaming all JSOs from the input file..'); - secondStream = getStream(); + var secondStream = getStream(); secondStream.on('close', async () => {await finishApp(); }) secondStream.pipe(es.mapSync(async function (obj) { try{ @@ -116,12 +118,15 @@ async function finishApp(){ // Main function: -async function startScript(){ +exports.startScript = async function(){ try{ console.log('JSON2MySQL started. \nworking..'); await validateInput(); await db.init(config.host, config.user, config.password, config.dbName, config.tblName); await db.runDatabase(); + // dlt next row when app's rdy: + await db.dropTable(config.tblName); + //////// await getTableFromFirstObject(); await startStreaming(); }catch(err){ @@ -130,7 +135,7 @@ async function startScript(){ } } -startScript(); + diff --git a/package-lock.json b/package-lock.json index 43cbe96..e77ff24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -65,6 +65,20 @@ "through": ">=2.2.7 <3" } }, + "accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "requires": { + "mime-types": "~2.1.18", + "negotiator": "0.6.1" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, "array-from": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", @@ -92,6 +106,38 @@ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==" }, + "body-parser": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "~1.6.3", + "iconv-lite": "0.4.23", + "on-finished": "~2.3.0", + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "~1.6.16" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -111,6 +157,11 @@ "resolved": "https://registry.npmjs.org/bson/-/bson-0.1.9.tgz", "integrity": "sha1-dSj4Htdw5tYwyowszfU5SkCW2xQ=" }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, "chai": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", @@ -150,6 +201,26 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -172,6 +243,16 @@ "type-detect": "^4.0.0" } }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", @@ -182,11 +263,31 @@ "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=" }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, "event-stream": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", @@ -201,6 +302,102 @@ "through": "~2.3.1" } }, + "express": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", + "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", + "requires": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.3", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.4", + "qs": "6.5.2", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.2", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + } + } + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.4.0", + "unpipe": "~1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, "from": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", @@ -245,6 +442,25 @@ "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -259,6 +475,11 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "ipaddr.js": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", + "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -292,6 +513,39 @@ "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=" }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", + "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" + }, + "mime-types": { + "version": "2.1.22", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", + "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", + "requires": { + "mime-db": "~1.38.0" + } + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -362,6 +616,11 @@ "sqlstring": "2.3.1" } }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, "nise": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/nise/-/nise-1.4.8.tgz", @@ -391,6 +650,14 @@ "bson": "^0.1.9" } }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -399,6 +666,11 @@ "wrappy": "1" } }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -451,6 +723,36 @@ "mysql": "^2.14.1" } }, + "proxy-addr": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", + "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.8.0" + } + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "unpipe": "1.0.0" + } + }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", @@ -470,6 +772,62 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, "sinon": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.2.3.tgz", @@ -509,6 +867,11 @@ "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz", "integrity": "sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A=" }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + }, "stream-combiner": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", @@ -550,11 +913,35 @@ "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.18" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index aec4058..5dde188 100644 --- a/package.json +++ b/package.json @@ -5,21 +5,25 @@ "node": "8.11.3" }, "description": "input: JSON file path. The app creates a MySQL DB that holds the data from the input file.", - "main": "index.js", + "main": "server.js", "scripts": { "test": "echo \"Running tests..\" ", "test1": "echo \"Error: no test specified\" && exit 1", "test2": "SET DEBUG=DB,test & mocha tests/app.test.js", - "debug": "SET DEBUG=* & node index.js", - "start": "node index.js" + "debug": "SET DEBUG=* & node server.js", + "start": "node index.js", + "app": "node app.js", + "server": "node server.js" }, "author": "Ilan Melki", "license": "ISC", "dependencies": { "JSON": "^1.0.0", "JSONStream": "^1.3.5", + "body-parser": "^1.18.3", "debug": "^4.1.1", "event-stream": "3.3.4", + "express": "4.16.4", "mocha": "^5.2.0", "mysql": "^2.16.0", "objectid": "^3.2.1", diff --git a/routes/index.js b/routes/index.js new file mode 100644 index 0000000..cd246e6 --- /dev/null +++ b/routes/index.js @@ -0,0 +1,14 @@ +const express = require('express'); +const router = express.Router(); + +// GET home page +router.get('/', function(req, res, next) { + res.render('index', { title: 'Express' }); +}); + +/*// GET home page. +router.get('/', function(req, res) { + res.redirect('/catalog'); +});*/ + +module.exports = router; diff --git a/server.js b/server.js new file mode 100644 index 0000000..f8c03c8 --- /dev/null +++ b/server.js @@ -0,0 +1,109 @@ + +const express = require('express'); +const bodyParser = require('body-parser'); +//const bcrypt = require('bcrypt-nodejs'); +//const cors = require('cors'); +//const knex = require('knex') +const debug = require('debug')('Server'); + + +// Require App: +const jsonToMySQL = require('./jsonToMySQL'); + +const jsonToDB = () => { + jsonToMySQL + .startScript() + .then(() => { + console.log('finished script.'); + }) + .catch(err => { + console.error(err.message); + }); +} + +const app = express(); + +//app.use(cors()) +app.use(bodyParser.json()); + +app.get('/', (req, res)=> { + jsonToDB(); + res.send({}); +}) + +/* +app.post('/signin', (req, res) => { + db.select('email', 'hash').from('login') + .where('email', '=', req.body.email) + .then(data => { + const isValid = bcrypt.compareSync(req.body.password, data[0].hash); + if (isValid) { + return db.select('*').from('users') + .where('email', '=', req.body.email) + .then(user => { + res.json(user[0]) + }) + .catch(err => res.status(400).json('unable to get user')) + } else { + res.status(400).json('wrong credentials') + } + }) + .catch(err => res.status(400).json('wrong credentials')) +}) + +app.post('/register', (req, res) => { + const { email, name, password } = req.body; + const hash = bcrypt.hashSync(password); + db.transaction(trx => { + trx.insert({ + hash: hash, + email: email + }) + .into('login') + .returning('email') + .then(loginEmail => { + return trx('users') + .returning('*') + .insert({ + email: loginEmail[0], + name: name, + joined: new Date() + }) + .then(user => { + res.json(user[0]); + }) + }) + .then(trx.commit) + .catch(trx.rollback) + }) + .catch(err => res.status(400).json('unable to register')) +}) + +app.get('/profile/:id', (req, res) => { + const { id } = req.params; + db.select('*').from('users').where({id}) + .then(user => { + if (user.length) { + res.json(user[0]) + } else { + res.status(400).json('Not found') + } + }) + .catch(err => res.status(400).json('error getting user')) +}) + +app.put('/image', (req, res) => { + const { id } = req.body; + db('users').where('id', '=', id) + .increment('entries', 1) + .returning('entries') + .then(entries => { + res.json(entries[0]); + }) + .catch(err => res.status(400).json('unable to get entries')) +}) +*/ + +app.listen(3000, ()=> { + console.log('app is running on port 3000'); +}) From ce5f87567aff42fff98264ec35eacd93111cb14a Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 16 Apr 2019 18:07:00 +0300 Subject: [PATCH 13/57] codefresh.yml fixed --- codefresh.yml | 4 ++++ jsonToMySQL.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/codefresh.yml b/codefresh.yml index 57ebad2..492a189 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -1,4 +1,8 @@ version: '1.0' + +stages: + - test + steps: MyAppDockerImage: diff --git a/jsonToMySQL.js b/jsonToMySQL.js index 79a18dc..0df6504 100644 --- a/jsonToMySQL.js +++ b/jsonToMySQL.js @@ -125,7 +125,7 @@ exports.startScript = async function(){ await db.init(config.host, config.user, config.password, config.dbName, config.tblName); await db.runDatabase(); // dlt next row when app's rdy: - await db.dropTable(config.tblName); + //await db.dropTable(config.tblName); //////// await getTableFromFirstObject(); await startStreaming(); From 11dd47c8dfb4658b04e756ca1eb10f1c1577306e Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 16 Apr 2019 18:09:55 +0300 Subject: [PATCH 14/57] README fixed --- README.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 915714f..34bc161 100644 --- a/README.md +++ b/README.md @@ -21,19 +21,12 @@ Open the configuration file (config.json) and edit it with the arguments of your Choose a database table that fits the Schema, or choose a non-existing one to be created. -To build the app, enter the command: +To build & run the app, enter the command: ``` -docker build --tag=json2mysql . +docker-compose up ``` - -Now, this command will run the app on your local machine: - -``` -docker run json2mysql -``` - - + ## Author * **iMelki** From eed7193c5009ae78709d27b69fc227ceea461367 Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 16 Apr 2019 19:22:39 +0300 Subject: [PATCH 15/57] compose to CF --- codefresh.yml | 27 +++++++++++++++++++++++++++ docker-compose.yml | 6 +++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/codefresh.yml b/codefresh.yml index 492a189..b5c0309 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -36,3 +36,30 @@ steps: retry: maxAttempts: 2 delay: 5 + + compose: + type: composition + title: Run app + description: Free text description + working_directory: ./ + composition: docker-compose.yml + fail_fast: false + when: + condition: + all: + notFeatureBranch: 'match("${{CF_BRANCH}}", "/FB-/", true) == false' + on_success: + ... + on_fail: + ... + on_finish: + ... + retry: + ... + + + Run: + title: Running Server + image: ${{MyAppDockerImage}} + commands: + - docker-compose up diff --git a/docker-compose.yml b/docker-compose.yml index 49b8d1e..98707a9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,8 +8,8 @@ services: MYSQL_USER: 'user' MYSQL_PASSWORD: 'password' MYSQL_ROOT_PASSWORD: 'password' - ports: - - '3306:3306' + #ports: + # - '3306:3306' expose: - '3306' volumes: @@ -17,7 +17,7 @@ services: #- my-db:/var/lib/mysql web: - build: . + image: . volumes: From 3325115139601811cb839dbfdb83d3b760203413 Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 16 Apr 2019 19:39:37 +0300 Subject: [PATCH 16/57] compose to CF --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 98707a9..9729764 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,8 +16,8 @@ services: - jtmVol:/var/lib/docker/volumes/jtmVol #- my-db:/var/lib/mysql - web: - image: . + #web: + # image: . volumes: From fa6651a146e1483dd53488c3e15d5a8c41aa34c3 Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 16 Apr 2019 19:59:19 +0300 Subject: [PATCH 17/57] compose to CF --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9729764..e8938fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,8 +16,8 @@ services: - jtmVol:/var/lib/docker/volumes/jtmVol #- my-db:/var/lib/mysql - #web: - # image: . + web: + image: ${{MyAppDockerImage}} volumes: From 0e2c29bcecc676cc0545152f4897d27581c800f5 Mon Sep 17 00:00:00 2001 From: mac Date: Tue, 16 Apr 2019 20:08:08 +0300 Subject: [PATCH 18/57] compose to CF --- codefresh.yml | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/codefresh.yml b/codefresh.yml index b5c0309..0e2097d 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -37,29 +37,9 @@ steps: maxAttempts: 2 delay: 5 - compose: - type: composition + Run: + type: launch-composition title: Run app description: Free text description working_directory: ./ composition: docker-compose.yml - fail_fast: false - when: - condition: - all: - notFeatureBranch: 'match("${{CF_BRANCH}}", "/FB-/", true) == false' - on_success: - ... - on_fail: - ... - on_finish: - ... - retry: - ... - - - Run: - title: Running Server - image: ${{MyAppDockerImage}} - commands: - - docker-compose up From 15c691476894bf8a7224b960ca2f4669235c8310 Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Wed, 17 Apr 2019 16:50:29 +0300 Subject: [PATCH 19/57] fixed docker file & composeetc --- Dockerfile | 2 +- codefresh.yml | 8 ++++++++ docker-compose.yml | 15 ++++++++++++--- server.js | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b37117..4f85c81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN npm install COPY . /src/app # Make port 8000 available to the world outside this container -EXPOSE 8000 +EXPOSE 3000 # Define environment variable #ENV DEBUG True diff --git a/codefresh.yml b/codefresh.yml index 0e2097d..f8ab454 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -13,6 +13,14 @@ steps: tag: '${{CF_BRANCH_TAG_NORMALIZED}}' dockerfile: Dockerfile + MyUiDockerImage: + title: Building UI Docker Image + type: build + image_name: ilancodefresh/my-app-ui + working_directory: ./ + tag: '${{CF_BRANCH_TAG_NORMALIZED}}' + dockerfile: Dockerfile + MyUnitTests: title: Running Unit tests stage: test diff --git a/docker-compose.yml b/docker-compose.yml index e8938fd..b36c60a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,8 +8,8 @@ services: MYSQL_USER: 'user' MYSQL_PASSWORD: 'password' MYSQL_ROOT_PASSWORD: 'password' - #ports: - # - '3306:3306' + ports: + - '3306:3306' expose: - '3306' volumes: @@ -17,7 +17,16 @@ services: #- my-db:/var/lib/mysql web: - image: ${{MyAppDockerImage}} + image: my-app-ui + ports: + - 4200:4200 + + server: + image: my-app-server + ports: + - 3000:3000 + + #build: . volumes: diff --git a/server.js b/server.js index f8c03c8..3044883 100644 --- a/server.js +++ b/server.js @@ -28,6 +28,7 @@ app.use(bodyParser.json()); app.get('/', (req, res)=> { jsonToDB(); + // extractDataFromDB res.send({}); }) From a1c7262e1db085af1a020a80c0da2bebc19fcb15 Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Wed, 17 Apr 2019 17:00:14 +0300 Subject: [PATCH 20/57] fixed docker compose --- docker-compose.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b36c60a..2b485bc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,13 +16,14 @@ services: - jtmVol:/var/lib/docker/volumes/jtmVol #- my-db:/var/lib/mysql - web: - image: my-app-ui - ports: - - 4200:4200 +# web: +# image: my-app-ui +# ports: +# - 4200:4200 server: - image: my-app-server + #image: my-app-server + image: ${{MyAppDockerImage}} ports: - 3000:3000 From a913d09c86e8d7c22802dff9ce63fd18037e31ea Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Wed, 17 Apr 2019 17:04:48 +0300 Subject: [PATCH 21/57] fixed docker compose --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2b485bc..607d3f5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,8 +8,8 @@ services: MYSQL_USER: 'user' MYSQL_PASSWORD: 'password' MYSQL_ROOT_PASSWORD: 'password' - ports: - - '3306:3306' +# ports: +# - '3306:3306' expose: - '3306' volumes: @@ -24,8 +24,8 @@ services: server: #image: my-app-server image: ${{MyAppDockerImage}} - ports: - - 3000:3000 +# ports: +# - 3000:3000 #build: . From 5a7a93c9f0bac9fb9e207ecfdf5f4530a8ff8252 Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Wed, 17 Apr 2019 17:14:04 +0300 Subject: [PATCH 22/57] fixed docker compose --- cf-docker-compose.yml | 36 ++++++++++++++++++++++++++++++++++++ codefresh.yml | 2 +- docker-compose.yml | 22 ++++++++++++---------- 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 cf-docker-compose.yml diff --git a/cf-docker-compose.yml b/cf-docker-compose.yml new file mode 100644 index 0000000..2d4d7c6 --- /dev/null +++ b/cf-docker-compose.yml @@ -0,0 +1,36 @@ +version: '2' +services: + db: + image: mysql:5.7 + restart: always + environment: + MYSQL_DATABASE: 'db' + MYSQL_USER: 'user' + MYSQL_PASSWORD: 'password' + MYSQL_ROOT_PASSWORD: 'password' +# ports: +# - '3306:3306' + expose: + - '3306' + volumes: + - jtmVol:/var/lib/docker/volumes/jtmVol + #- my-db:/var/lib/mysql + +# web: +# image: my-app-ui +# ports: +# - 4200:4200 + + server: + #image: my-app-server + image: ${{MyAppDockerImage}} +# ports: +# - 3000:3000 + expose: + - '3000' + + #build: . + + +volumes: + jtmVol: diff --git a/codefresh.yml b/codefresh.yml index f8ab454..83491ed 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -50,4 +50,4 @@ steps: title: Run app description: Free text description working_directory: ./ - composition: docker-compose.yml + composition: cf-docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml index 607d3f5..76e74f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,24 +8,26 @@ services: MYSQL_USER: 'user' MYSQL_PASSWORD: 'password' MYSQL_ROOT_PASSWORD: 'password' -# ports: -# - '3306:3306' + ports: + - '3306:3306' expose: - '3306' volumes: - jtmVol:/var/lib/docker/volumes/jtmVol #- my-db:/var/lib/mysql -# web: -# image: my-app-ui -# ports: -# - 4200:4200 + web: + image: my-app-ui + ports: + - 4200:4200 server: - #image: my-app-server - image: ${{MyAppDockerImage}} -# ports: -# - 3000:3000 + image: my-app-server +# image: ${{MyAppDockerImage}} + ports: + - 3000:3000 + expose: + - '3000' #build: . From 619bd0b82d9536a74ead49ce6e14d18ffbf461ed Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Wed, 17 Apr 2019 17:37:27 +0300 Subject: [PATCH 23/57] cf.yml --- cf-docker-compose.yml | 2 +- codefresh.yml | 18 ++++++++++++------ docker-compose.yml | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cf-docker-compose.yml b/cf-docker-compose.yml index 2d4d7c6..a283165 100644 --- a/cf-docker-compose.yml +++ b/cf-docker-compose.yml @@ -23,7 +23,7 @@ services: server: #image: my-app-server - image: ${{MyAppDockerImage}} + image: ${{MyServerDockerImage}} # ports: # - 3000:3000 expose: diff --git a/codefresh.yml b/codefresh.yml index 83491ed..839c41c 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -5,16 +5,16 @@ stages: steps: - MyAppDockerImage: - title: Building Docker Image + MyServerDockerImage: + title: Building Server Docker Image type: build image_name: ilancodefresh/json2mysql working_directory: ./ tag: '${{CF_BRANCH_TAG_NORMALIZED}}' dockerfile: Dockerfile - MyUiDockerImage: - title: Building UI Docker Image + MyClientDockerImage: + title: Building Client Docker Image type: build image_name: ilancodefresh/my-app-ui working_directory: ./ @@ -24,7 +24,7 @@ steps: MyUnitTests: title: Running Unit tests stage: test - image: ${{MyAppDockerImage}} + image: ${{MyServerDockerImage}} commands: - npm run test @@ -32,7 +32,7 @@ steps: type: push title: Push Image to Docker Hub description: Push Docker Image to Docker Hub Registry - candidate: ${{MyAppDockerImage}} + candidate: ${{MyServerDockerImage}} #tag: latest #image_name: codefresh/app registry: dockerhub @@ -51,3 +51,9 @@ steps: description: Free text description working_directory: ./ composition: cf-docker-compose.yml + +# Run: +# title: Running Server +# image: ${{MyServerDockerImage}} +# commands: +# - docker-compose up diff --git a/docker-compose.yml b/docker-compose.yml index 76e74f2..62c5245 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,7 @@ services: server: image: my-app-server -# image: ${{MyAppDockerImage}} +# image: ${{MyServerDockerImage}} ports: - 3000:3000 expose: From a0ccdcd53f6cef5c0c4e7bcdcf3126788df9e179 Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Wed, 17 Apr 2019 17:41:07 +0300 Subject: [PATCH 24/57] cf.yml & compose --- cf-docker-compose.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cf-docker-compose.yml b/cf-docker-compose.yml index a283165..dc9a65f 100644 --- a/cf-docker-compose.yml +++ b/cf-docker-compose.yml @@ -16,18 +16,21 @@ services: - jtmVol:/var/lib/docker/volumes/jtmVol #- my-db:/var/lib/mysql -# web: + client: + image: ${{MyClientDockerImage}} + expose: + - '4200' # image: my-app-ui # ports: # - 4200:4200 server: - #image: my-app-server image: ${{MyServerDockerImage}} -# ports: -# - 3000:3000 expose: - '3000' +# image: my-app-server +# ports: +# - 3000:3000 #build: . From f9b36b93059c083ada672c02e7a4e13883924f59 Mon Sep 17 00:00:00 2001 From: ilan-codeserver Date: Sun, 21 Apr 2019 08:07:22 +0000 Subject: [PATCH 25/57] test code-server --- server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server.js b/server.js index 3044883..a320cea 100644 --- a/server.js +++ b/server.js @@ -28,6 +28,7 @@ app.use(bodyParser.json()); app.get('/', (req, res)=> { jsonToDB(); + console.log('YA! \n'); // extractDataFromDB res.send({}); }) From a6c85b728cda9b59a27dd45079ba6f25b18f9180 Mon Sep 17 00:00:00 2001 From: ilan-codeserver Date: Sun, 21 Apr 2019 08:45:03 +0000 Subject: [PATCH 26/57] test code-server --- codefresh.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/codefresh.yml b/codefresh.yml index 839c41c..06f0b79 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -50,6 +50,7 @@ steps: title: Run app description: Free text description working_directory: ./ + entry_point: server composition: cf-docker-compose.yml # Run: From 45d697a199bb2b42dedcc578a05524b807de1dc7 Mon Sep 17 00:00:00 2001 From: ilan-codeserver Date: Sun, 21 Apr 2019 10:22:02 +0000 Subject: [PATCH 27/57] test code-server --- cf-docker-compose.yml | 8 ++++---- codefresh.yml | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cf-docker-compose.yml b/cf-docker-compose.yml index dc9a65f..a78f6d3 100644 --- a/cf-docker-compose.yml +++ b/cf-docker-compose.yml @@ -16,10 +16,10 @@ services: - jtmVol:/var/lib/docker/volumes/jtmVol #- my-db:/var/lib/mysql - client: - image: ${{MyClientDockerImage}} - expose: - - '4200' + # client: + # image: ${{MyClientDockerImage}} + # expose: + # - '4200' # image: my-app-ui # ports: # - 4200:4200 diff --git a/codefresh.yml b/codefresh.yml index 06f0b79..e9cc789 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -51,6 +51,7 @@ steps: description: Free text description working_directory: ./ entry_point: server + environment_name: Json2MySQL composition: cf-docker-compose.yml # Run: From f5c16efefa65f621c517d043381d0b44b356c3da Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Mon, 22 Apr 2019 18:09:32 +0300 Subject: [PATCH 28/57] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 34bc161..6ca3e6b 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,5 @@ docker-compose up ## License This project is licensed under the GNU GPL v3.0 License - see the [LICENSE.md](LICENSE.md) file for details + + From 5acaa4458f0d48b8561c899b87d7bb3b362b1baa Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Mon, 22 Apr 2019 18:10:09 +0300 Subject: [PATCH 29/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ca3e6b..f4dda16 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,4 @@ docker-compose up This project is licensed under the GNU GPL v3.0 License - see the [LICENSE.md](LICENSE.md) file for details - +yo From dd1c3d2f01024a0d5ec44b0303d4fecb3ce14f27 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 09:55:07 +0300 Subject: [PATCH 30/57] Update dbManipulator.js --- dbManipulator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/dbManipulator.js b/dbManipulator.js index a711a78..bd7f3c1 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,6 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; +let testingPush = 'PUSH'; // Public Functions: From a6b5dc63a84382a3bec5be1a3c2facc02444f18b Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 10:03:27 +0300 Subject: [PATCH 31/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index bd7f3c1..54a44e8 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -let testingPush = 'PUSH'; +//let testingPush = 'PUSH'; // Public Functions: From 69157c4fcb5ef000a0163e0999daa821384b1c45 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 10:20:01 +0300 Subject: [PATCH 32/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index 54a44e8..bd7f3c1 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -//let testingPush = 'PUSH'; +let testingPush = 'PUSH'; // Public Functions: From cbec35fe609279aaf7cc27ac711c317c02c3f25a Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 10:26:16 +0300 Subject: [PATCH 33/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index bd7f3c1..54a44e8 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -let testingPush = 'PUSH'; +//let testingPush = 'PUSH'; // Public Functions: From 2b1b2cca7df1097d0e1217a0a2a4e16319ef4ab0 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 10:44:41 +0300 Subject: [PATCH 34/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index 54a44e8..bd7f3c1 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -//let testingPush = 'PUSH'; +let testingPush = 'PUSH'; // Public Functions: From 6b1ea72c5a189873a26735e72621706fa997ad89 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 10:49:58 +0300 Subject: [PATCH 35/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index bd7f3c1..54a44e8 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -let testingPush = 'PUSH'; +//let testingPush = 'PUSH'; // Public Functions: From d514e7c4949b567f7f875da36a5a400165a180b5 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 11:03:08 +0300 Subject: [PATCH 36/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index 54a44e8..bd7f3c1 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -//let testingPush = 'PUSH'; +let testingPush = 'PUSH'; // Public Functions: From c0d1a5d75bcfd7055093e866fe5e460eaf2c46e2 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 11:06:39 +0300 Subject: [PATCH 37/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index bd7f3c1..54a44e8 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -let testingPush = 'PUSH'; +//let testingPush = 'PUSH'; // Public Functions: From efef6844677adae93fa4391d08a13e32ed84e681 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 11:06:57 +0300 Subject: [PATCH 38/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index 54a44e8..bd7f3c1 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -//let testingPush = 'PUSH'; +let testingPush = 'PUSH'; // Public Functions: From 76a112874a063384b4ba71bb136bdc7ddbd2a49e Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 11:20:44 +0300 Subject: [PATCH 39/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index bd7f3c1..54a44e8 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -let testingPush = 'PUSH'; +//let testingPush = 'PUSH'; // Public Functions: From 4a23f19e9637bb196f74aefdc5cab0b57884daaa Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 11:34:51 +0300 Subject: [PATCH 40/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index 54a44e8..bd7f3c1 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -//let testingPush = 'PUSH'; +let testingPush = 'PUSH'; // Public Functions: From e54d8f2effa8385c5bc32297e719a60765d7b5d4 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 11:39:44 +0300 Subject: [PATCH 41/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index bd7f3c1..54a44e8 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,7 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -let testingPush = 'PUSH'; +//let testingPush = 'PUSH'; // Public Functions: From c3d015c8ad38cad83ae9b42e5f2a83d5d68dfc8f Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 23 Apr 2019 15:00:12 +0300 Subject: [PATCH 42/57] Update dbManipulator.js --- dbManipulator.js | 1 - 1 file changed, 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index 54a44e8..a711a78 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -9,7 +9,6 @@ var _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; -//let testingPush = 'PUSH'; // Public Functions: From 5417cec9edf64791fe3efb8331d44ad9be9bd9df Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Sun, 28 Apr 2019 10:37:45 +0300 Subject: [PATCH 43/57] update config args --- Dockerfile | 3 +- cf-docker-compose.yml | 6 +++- config.js | 22 +++++++++----- controllers/accountController.js | 51 ++++++++++++++++++++++++++++++++ dbManipulator.js | 11 ++++++- docker-compose.yml | 7 ++++- jsonToMySQL.js | 23 +++++++++----- routes/index.js | 12 ++++++-- server.js | 23 +++----------- 9 files changed, 118 insertions(+), 40 deletions(-) create mode 100644 controllers/accountController.js diff --git a/Dockerfile b/Dockerfile index 4f85c81..34317ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,4 +23,5 @@ VOLUME ["/var/lib/docker/volumes/jtmVol"] # Run #CMD ["node", "index.js"] #CMD ["npm", "run", "start"] -CMD ["npm", "run", "server"] +CMD ["npm", "run", "debug"] +#CMD ["npm", "run", "server"] diff --git a/cf-docker-compose.yml b/cf-docker-compose.yml index dc9a65f..0ceb83c 100644 --- a/cf-docker-compose.yml +++ b/cf-docker-compose.yml @@ -28,7 +28,11 @@ services: image: ${{MyServerDockerImage}} expose: - '3000' -# image: my-app-server + environment: + MYSQL_DATABASE: db.MYSQL_DATABASE + MYSQL_USER: db.MYSQL_USER + MYSQL_PASSWORD: db.MYSQL_PASSWORD + MYSQL_ROOT_PASSWORD: db.MYSQL_ROOT_PASSWORD # ports: # - 3000:3000 diff --git a/config.js b/config.js index af9e2ae..72f2b42 100644 --- a/config.js +++ b/config.js @@ -5,12 +5,13 @@ var configData = require('./config.json'); debug('imported'); -var jsonPath; -var host; -var user; -var password; -var dbName; -var tblName; +let jsonPath; +let host; +let user; +let password; +let rootPassword; +let dbName; +let tblName; function initConfig(){ jsonPath = path.resolve(__dirname, configData.jsonPath); @@ -25,4 +26,11 @@ initConfig(); module.exports = { host, user, password, jsonPath, dbName, tblName -} \ No newline at end of file +} + +exports.initDbParams = function(dbNameStr, username, pass, rootPass){ + user = username; + password = pass; + rootPassword = rootPass; + dbName = dbNameStr; +} diff --git a/controllers/accountController.js b/controllers/accountController.js new file mode 100644 index 0000000..ad9736a --- /dev/null +++ b/controllers/accountController.js @@ -0,0 +1,51 @@ + +const debug = require('debug')('AccountController'); + +// Require App Logic: +const jsonToMySQL = require('../jsonToMySQL'); + +//const jsonToDB = () => { +async function jsonToDB(){ + jsonToMySQL( + process.env.MYSQL_DATABASE, + process.env.MYSQL_USER, + process.env.MYSQL_PASSWORD, + process.env.MYSQL_ROOT_PASSWORD + ) + .startScript() + .then(() => { + console.log('finished insertion script.'); + }) + .catch(err => { + console.error(err.message); + }); +} + +async function getDataFromDB(){ + jsonToMySQL + .getAllAccounts() + .then(data=>{return data;}) + .catch(err => console.error(err)); +} + +exports.index = async function(req, res, next) { + //res.send("Account Controller with logic"); + //res.send("YO ! "+process.env.MYSQL_PASSWORD.toString()); + let status = await jsonToDB(); + debug(status); + + let data = getDataFromDB(); + //return data; + res.send(data); + //res.render('index', { title: 'Express' }); +}; + + + +/* + + MYSQL_DATABASE: 'db' + MYSQL_USER: 'user' + MYSQL_PASSWORD: 'password' + MYSQL_ROOT_PASSWORD: 'password' + */ diff --git a/dbManipulator.js b/dbManipulator.js index a711a78..aca6dbd 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -120,6 +120,15 @@ exports.insertToDB = async function (jsonData) { } }; +exports.getAllRecords = async function(){ + let mysqlQuery = 'SELECT * FROM ' + _dbName+"."+_tblName + ';'; + try{ + return await _connection.execQry(mysqlQuery); + }catch(err){ + throw new Error('Failed getting data from DB'); + } +} + exports.endConnection = async function(){ if (_connection != null){ await _connection.end(); @@ -227,7 +236,7 @@ Object.size = function(obj) { }; /** - * JSOToStr gets a JSO & type of data to extract + * JSOToStr gets a JSO & @type of data to extract * and extracts its indices OR values to MySQL query * @param {String} type - the type to insert ('index', 'value' OR 'createTable') * @param {Object} jso diff --git a/docker-compose.yml b/docker-compose.yml index 62c5245..bab82dd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: - jtmVol:/var/lib/docker/volumes/jtmVol #- my-db:/var/lib/mysql - web: + client: image: my-app-ui ports: - 4200:4200 @@ -24,6 +24,11 @@ services: server: image: my-app-server # image: ${{MyServerDockerImage}} + environment: + MYSQL_DATABASE: db.MYSQL_DATABASE + MYSQL_USER: db.MYSQL_USER + MYSQL_PASSWORD: db.MYSQL_PASSWORD + MYSQL_ROOT_PASSWORD: db.MYSQL_ROOT_PASSWORD ports: - 3000:3000 expose: diff --git a/jsonToMySQL.js b/jsonToMySQL.js index 0df6504..46547b9 100644 --- a/jsonToMySQL.js +++ b/jsonToMySQL.js @@ -7,14 +7,13 @@ const debug = require('debug')('Main'); const path = require('path'); - // Require Configuration settings: const config = require('./config.js'); // Require DB Connection: const db = require('./dbManipulator'); -var first = true; -var i; +let first = true; +let i; /** * a handler for inputing config arguments @@ -37,7 +36,7 @@ async function getConfigAtribute(argNum, atrName){ // validate whether we got all the input needed to run the app async function validateInput(){ debug('validating input..'); - var i=2; + let i=2; const gotJSONPath = await getConfigAtribute(i++, 'jsonPath'); if (gotJSONPath){ const gotDBName = await getConfigAtribute(i++, 'dbName'); @@ -118,14 +117,16 @@ async function finishApp(){ // Main function: -exports.startScript = async function(){ +exports.startScript = async function(dbName, mySqlUser, mySqlPass, rootPass){ try{ + config.initDbParams(dbName, mySqlUser, mySqlPass, rootPass); console.log('JSON2MySQL started. \nworking..'); - await validateInput(); + //await validateInput(); + //await db.init(config.host, config.user, config.password, config.dbName, config.tblName); await db.init(config.host, config.user, config.password, config.dbName, config.tblName); await db.runDatabase(); // dlt next row when app's rdy: - //await db.dropTable(config.tblName); + await db.dropTable(config.tblName); //////// await getTableFromFirstObject(); await startStreaming(); @@ -135,6 +136,14 @@ exports.startScript = async function(){ } } +exports.getAllAccounts = async function() { + try{ + return await db.getAllRecords(); + }catch(err){ + console.error(err); + } +} + diff --git a/routes/index.js b/routes/index.js index cd246e6..82f2169 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,10 +1,16 @@ const express = require('express'); const router = express.Router(); +const debug = require('debug')('CatalogRouter'); + + +// Require controller modules: +const account_controller = require('../controllers/accountController'); + +/// ACCOUNT ROUTES /// // GET home page -router.get('/', function(req, res, next) { - res.render('index', { title: 'Express' }); -}); +router.get('/', account_controller.index); + /*// GET home page. router.get('/', function(req, res) { diff --git a/server.js b/server.js index 3044883..1401fd4 100644 --- a/server.js +++ b/server.js @@ -6,31 +6,15 @@ const bodyParser = require('body-parser'); //const knex = require('knex') const debug = require('debug')('Server'); - -// Require App: -const jsonToMySQL = require('./jsonToMySQL'); - -const jsonToDB = () => { - jsonToMySQL - .startScript() - .then(() => { - console.log('finished script.'); - }) - .catch(err => { - console.error(err.message); - }); -} +// Require ROUTER: +const indexRouter = require('./routes/index'); const app = express(); //app.use(cors()) app.use(bodyParser.json()); -app.get('/', (req, res)=> { - jsonToDB(); - // extractDataFromDB - res.send({}); -}) +app.use('/', indexRouter); /* app.post('/signin', (req, res) => { @@ -106,5 +90,6 @@ app.put('/image', (req, res) => { */ app.listen(3000, ()=> { + console.log(process.env.MYSQL_DATABASE); console.log('app is running on port 3000'); }) From 07aa2da9f89c923f033c6e45b1a313e5757d45ca Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Mon, 29 Apr 2019 16:09:51 +0300 Subject: [PATCH 44/57] update --- cf-docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cf-docker-compose.yml b/cf-docker-compose.yml index 38da7b3..5a3d017 100644 --- a/cf-docker-compose.yml +++ b/cf-docker-compose.yml @@ -8,8 +8,8 @@ services: MYSQL_USER: 'user' MYSQL_PASSWORD: 'password' MYSQL_ROOT_PASSWORD: 'password' - ports: - - '3306:3306' +# ports: +# - '3306:3306' expose: - '3306' volumes: @@ -33,8 +33,8 @@ services: MYSQL_USER: db.MYSQL_USER MYSQL_PASSWORD: db.MYSQL_PASSWORD MYSQL_ROOT_PASSWORD: db.MYSQL_ROOT_PASSWORD - ports: - - 3000:3000 +# ports: +# - 3000:3000 #build: . From d48d03d0c355a73bd5ab769b7f16ede60c68005d Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Mon, 29 Apr 2019 17:19:27 +0300 Subject: [PATCH 45/57] dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 34317ec..2ee4b2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,5 +23,5 @@ VOLUME ["/var/lib/docker/volumes/jtmVol"] # Run #CMD ["node", "index.js"] #CMD ["npm", "run", "start"] -CMD ["npm", "run", "debug"] -#CMD ["npm", "run", "server"] +#CMD ["npm", "run", "debug"] +CMD ["npm", "run", "server"] From ec5ea2f8538110cfc14f68e5848de472ade18448 Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Mon, 29 Apr 2019 17:34:01 +0300 Subject: [PATCH 46/57] dockerfile --- cf-docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cf-docker-compose.yml b/cf-docker-compose.yml index 5a3d017..c76afce 100644 --- a/cf-docker-compose.yml +++ b/cf-docker-compose.yml @@ -10,7 +10,7 @@ services: MYSQL_ROOT_PASSWORD: 'password' # ports: # - '3306:3306' - expose: + ports: - '3306' volumes: - jtmVol:/var/lib/docker/volumes/jtmVol @@ -26,7 +26,7 @@ services: server: image: ${{MyServerDockerImage}} - expose: + ports: - '3000' environment: MYSQL_DATABASE: db.MYSQL_DATABASE From d16cb90ad121d15639adf45670f5138ccbcac86e Mon Sep 17 00:00:00 2001 From: ilan-codefresh Date: Mon, 29 Apr 2019 17:42:18 +0300 Subject: [PATCH 47/57] dockerfile --- codefresh.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/codefresh.yml b/codefresh.yml index e9cc789..c2f5dce 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -13,13 +13,13 @@ steps: tag: '${{CF_BRANCH_TAG_NORMALIZED}}' dockerfile: Dockerfile - MyClientDockerImage: - title: Building Client Docker Image - type: build - image_name: ilancodefresh/my-app-ui - working_directory: ./ - tag: '${{CF_BRANCH_TAG_NORMALIZED}}' - dockerfile: Dockerfile +# MyClientDockerImage: +# title: Building Client Docker Image +# type: build +# image_name: ilancodefresh/my-app-ui +# working_directory: ./ +# tag: '${{CF_BRANCH_TAG_NORMALIZED}}' +# dockerfile: Dockerfile MyUnitTests: title: Running Unit tests From cd1346178ba7e4b10e2cabf3858d3c4cfac19210 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 30 Apr 2019 17:57:23 +0300 Subject: [PATCH 48/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index aca6dbd..2082d80 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -5,7 +5,7 @@ const debug = require('debug')('DB'); var _connection; var _host = ""; -var _user = ""; +let _user = ""; var _password = ""; var _dbName = ""; var _tblName = ""; From 92c51ae9ffe8f2c73c473b017c5c1a1c8e647095 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Tue, 30 Apr 2019 17:58:44 +0300 Subject: [PATCH 49/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index 2082d80..c30965c 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -6,7 +6,7 @@ const debug = require('debug')('DB'); var _connection; var _host = ""; let _user = ""; -var _password = ""; +let _password = ""; var _dbName = ""; var _tblName = ""; From afb143a04760f8796d663f104c24d145e765a477 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Wed, 1 May 2019 17:25:05 +0300 Subject: [PATCH 50/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index c30965c..b5ad63f 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -4,7 +4,7 @@ const mysql = require('promise-mysql'); const debug = require('debug')('DB'); var _connection; -var _host = ""; +let _host = ""; let _user = ""; let _password = ""; var _dbName = ""; From dc3e42671d162be396aeaebfc5d4d948209eeb8a Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Wed, 1 May 2019 17:27:50 +0300 Subject: [PATCH 51/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index b5ad63f..1c49ad0 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -8,7 +8,7 @@ let _host = ""; let _user = ""; let _password = ""; var _dbName = ""; -var _tblName = ""; +let _tblName = ""; // Public Functions: From e945d60cc50242f6c36ae588ab240d5b28bf43c3 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Thu, 2 May 2019 11:30:24 +0300 Subject: [PATCH 52/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index 1c49ad0..b6b3d28 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -3,7 +3,7 @@ const mysql = require('promise-mysql'); const debug = require('debug')('DB'); -var _connection; +let _connection; let _host = ""; let _user = ""; let _password = ""; From d0efa26a6f0d629be10081ecdf298e6f840a59f8 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Thu, 2 May 2019 12:16:29 +0300 Subject: [PATCH 53/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index b6b3d28..4b323b3 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -4,7 +4,7 @@ const mysql = require('promise-mysql'); const debug = require('debug')('DB'); let _connection; -let _host = ""; +var _host = ""; let _user = ""; let _password = ""; var _dbName = ""; From 07462f9ed15e9324784ecdc260fcdd11e794bf1b Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Thu, 2 May 2019 15:21:35 +0300 Subject: [PATCH 54/57] Update dbManipulator.js --- dbManipulator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbManipulator.js b/dbManipulator.js index 4b323b3..59d64e0 100644 --- a/dbManipulator.js +++ b/dbManipulator.js @@ -5,7 +5,7 @@ const debug = require('debug')('DB'); let _connection; var _host = ""; -let _user = ""; +var _user = ""; let _password = ""; var _dbName = ""; let _tblName = ""; From eb700bf49e1ec84bf51695a5ed08b4d4137e22f5 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Thu, 23 May 2019 18:09:09 +0300 Subject: [PATCH 55/57] Create codefresh1.yml --- codefresh1.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 codefresh1.yml diff --git a/codefresh1.yml b/codefresh1.yml new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/codefresh1.yml @@ -0,0 +1 @@ +{} From fcd1b52b6a440cf792a792d7f88fc5f671d0ddd0 Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Sun, 26 May 2019 15:15:29 +0300 Subject: [PATCH 56/57] Create codefresh2 --- codefresh2 | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 codefresh2 diff --git a/codefresh2 b/codefresh2 new file mode 100644 index 0000000..b6c91db --- /dev/null +++ b/codefresh2 @@ -0,0 +1,9 @@ +version: '1.0' +steps: + BuildingDockerImage: + titlee: Building Docker Image + type: build + image_name: ilancodefresh/json2mysql + working_directory: ./ + tag: '${{CF_BRANCH_TAG_NORMALIZED}}' + dockerfile: Dockerfile From 26562aad19a8c3938bc0feb5c5eb1cccb67f7abd Mon Sep 17 00:00:00 2001 From: Milky <48883085+ilan-codefresh@users.noreply.github.com> Date: Sun, 26 May 2019 15:15:47 +0300 Subject: [PATCH 57/57] Rename codefresh2 to codefresh2.yml --- codefresh2 => codefresh2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename codefresh2 => codefresh2.yml (100%) diff --git a/codefresh2 b/codefresh2.yml similarity index 100% rename from codefresh2 rename to codefresh2.yml