pull/1/head
Rob Hedgpeth 2020-01-30 13:12:23 -08:00
rodzic ad7d5a9de6
commit 1bfdecedf2
4 zmienionych plików z 26 dodań i 11 usunięć

Wyświetl plik

@ -101,17 +101,16 @@ export default GoogleApiWrapper({
})(MapContainer) })(MapContainer)
``` ```
2. Update the MariaDB connection configuration [here](src/db.js#L4). 2. 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).
```js Example implementation:
const pool = mariadb.createPool({
host: 'localhost', ```
user:'ENTER_USERNAME_HERE', DB_HOST=<host_address>
password: 'ENTER_PASSWORD_HERE', DB_PORT=<port_number>
database: 'Places', DB_USER=<username>
multipleStatements: true, DB_PASS=<password>
connectionLimit: 5 DB_NAME=<database>
});
``` ```
### Build the code <a name="build-code"></a> ### Build the code <a name="build-code"></a>

Wyświetl plik

@ -1,6 +1,6 @@
var mariadb = require('mariadb'); var mariadb = require('mariadb');
require('dotenv').config();
// Local Connection
const pool = mariadb.createPool({ const pool = mariadb.createPool({
host: 'localhost', host: 'localhost',
user:'root', user:'root',
@ -10,6 +10,16 @@ const pool = mariadb.createPool({
connectionLimit: 5 connectionLimit: 5
}); });
const pool = mariadb.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASS,
port: process.env.DB_PORT,
database: process.env.DB_NAME,
multipleStatements: true,
connectionLimit: 5
});
module.exports={ module.exports={
getConnection: function(){ getConnection: function(){
return new Promise(function(resolve,reject){ return new Promise(function(resolve,reject){

Wyświetl plik

@ -200,6 +200,11 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" "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": { "ee-first": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",

Wyświetl plik

@ -13,6 +13,7 @@
"dependencies": { "dependencies": {
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"concurrently": "^5.0.0", "concurrently": "^5.0.0",
"dotenv": "^8.2.0",
"express": "^4.17.1", "express": "^4.17.1",
"mariadb": "^2.1.2" "mariadb": "^2.1.2"
} }