Added dotenv
rodzic
ad7d5a9de6
commit
1bfdecedf2
|
@ -101,17 +101,16 @@ export default GoogleApiWrapper({
|
|||
})(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
|
||||
const pool = mariadb.createPool({
|
||||
host: 'localhost',
|
||||
user:'ENTER_USERNAME_HERE',
|
||||
password: 'ENTER_PASSWORD_HERE',
|
||||
database: 'Places',
|
||||
multipleStatements: true,
|
||||
connectionLimit: 5
|
||||
});
|
||||
Example implementation:
|
||||
|
||||
```
|
||||
DB_HOST=<host_address>
|
||||
DB_PORT=<port_number>
|
||||
DB_USER=<username>
|
||||
DB_PASS=<password>
|
||||
DB_NAME=<database>
|
||||
```
|
||||
|
||||
### Build the code <a name="build-code"></a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var mariadb = require('mariadb');
|
||||
require('dotenv').config();
|
||||
|
||||
// Local Connection
|
||||
const pool = mariadb.createPool({
|
||||
host: 'localhost',
|
||||
user:'root',
|
||||
|
@ -10,6 +10,16 @@ const pool = mariadb.createPool({
|
|||
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={
|
||||
getConnection: function(){
|
||||
return new Promise(function(resolve,reject){
|
||||
|
|
|
@ -200,6 +200,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",
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"concurrently": "^5.0.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"mariadb": "^2.1.2"
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue