mirror of
https://github.com/originalmk/skrytka-app.git
synced 2025-01-18 08:19:17 +00:00
Now loading sensitive data from .env file
This commit is contained in:
parent
847513ebdd
commit
89e4492a63
8
.env
Normal file
8
.env
Normal file
@ -0,0 +1,8 @@
|
||||
# These variables should be set before running app (for PostgreSQL database)
|
||||
# otherwise app will fail connecting to the database.
|
||||
|
||||
# DB_USER=xyz
|
||||
# DB_PASS=1234
|
||||
DB_HOST=localhost
|
||||
DB_PORT=5432
|
||||
DB_NAME=skrytka
|
9
app.js
9
app.js
@ -5,11 +5,10 @@ const responseTime = require('response-time');
|
||||
const types = require('pg').types;
|
||||
const validator = require('validator');
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
const app = express();
|
||||
|
||||
// TODO: Replace with some environmental variables which store real password / host / database name
|
||||
const db = pgp('postgres://postgres:99postgres11@localhost:5432/skrytka');
|
||||
|
||||
const db = pgp(`postgres://${process.env.DB_USER}:${process.env.DB_PASS}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`);
|
||||
const port = 3001;
|
||||
|
||||
class Point {
|
||||
@ -59,6 +58,8 @@ app.use(session({
|
||||
}
|
||||
}));
|
||||
|
||||
console.log(process.env.DB_NAME);
|
||||
|
||||
let latencies = [0];
|
||||
const MAX_LATENCIES = 25;
|
||||
|
||||
|
9
package-lock.json
generated
9
package-lock.json
generated
@ -10,6 +10,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"connect-pg-simple": "^8.0.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"express-session": "^1.17.3",
|
||||
"pg": "^8.9.0",
|
||||
@ -178,6 +179,14 @@
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
|
||||
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"name": "skrytka",
|
||||
"version": "0.0.1",
|
||||
"description": "Potężna aplikacja Skrytka.App!",
|
||||
@ -10,6 +10,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"connect-pg-simple": "^8.0.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"express-session": "^1.17.3",
|
||||
"pg": "^8.9.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user