From f3cbdf40109313e583370527fc83df3bfd8864a2 Mon Sep 17 00:00:00 2001 From: Olu Amey Date: Mon, 23 Aug 2021 10:50:31 -0400 Subject: [PATCH] initial commit --- .gitignore | 13 ++++++++ index.js | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 16 ++++++++++ 3 files changed, 119 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..69d450c --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +app.log +transaction.log +node_modules +tests/_output/ +tests/_output/* +.sass-cache +npm-debug.log +Docs/ +vendor/ +/stats.json +Public/static/assets +Project/Mobile/Views/Layouts/ui.layout.tpl +package-lock.json \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..2ddf611 --- /dev/null +++ b/index.js @@ -0,0 +1,90 @@ +//const config = require('config'); +const app = require('express')(); +const PORT = 5101; +var mysql = require('mysql'); + +//const cors = require('cors'); +//const app = express(); +//const { Pool, Client } = require('pg'); + +//app.use(cors()); +//app.use(express.json()); + +// Database connection details; +/*const cn = { + host: '10.20.30.60', // 'localhost' is the default; + port: 5432, // 5432 is the default; + database: 'mermsemr_dev', + user: 'mermsemr', + password: 'mermsemr' +}; + +const connectionString = 'postgresql://mermsemr:mermsemr@10.20.30.60:5432/mermsemr_dev' +const pool = new Pool({ + connectionString, +}) + +// pool.query('SELECT NOW()', (err, res) => { +// console.log(err, res) +// pool.end() +// }) + const client = new Client({ + connectionString, +}) +client.connect() + + + +*/ + +/* +mysql -u root -p -h 10.10.33.60 + +SET GLOBAL validate_password.policy=LOW; +CREATE USER 'wroot'@'10.0.0.52' IDENTIFIED BY 'wroot@#Chi3fW0rks.52'; +GRANT ALL PRIVILEGES ON coregrade_blog.* TO 'wroot'@'10.0.0.52'; +GRANT ALL PRIVILEGES ON blog_mermsemr_com.* TO 'wroot'@'10.0.0.52'; + +*/ + +var con = mysql.createConnection({ + host: "10.10.33.60", // ip address of server running mysql + user: "wroot", // user name to your mysql database + password: "wroot@#Chi3fW0rks.52", // corresponding password + database: "blog_mermsemr_com" // use this database to querying context + }); + + +const price_list = [ + { id: 1, description: 'Free',price: '0.00',currency : 'NG', provider_id : '1' }, + { id: 2, description: 'Basic Encounter',price: '100.00',currency : 'NG', provider_id : '1' }, + { id: 3, description: 'Detail Review',price: '2000.02',currency : 'NG', provider_id : '1' }, + { id: 4, description: 'Second Opinion',price: '5000.00',currency : 'NG', provider_id : '1' }, +]; + +app.get('/', function (req, res) { + + res.status(200).send(price_list); + + // client.query('SELECT * FROM members', (err, res) => { + // console.log(err, res) + // client.end() + // }) + +con.query("SELECT * FROM studentsDB.students", function (err, result, fields) { + // if any error while executing above query, throw error + if (err) throw err; + // if there is no error, you have the result + console.log(result); +}); + + +}) + + +app.listen(PORT, + ()=>{ + console.log(`WD Connect is alive on port:${PORT}`); + }); + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..db7ae8f --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "wp-connect", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "express": "^4.17.1", + "mysql": "^2.18.1" + } +}