Skip to content

Commit aa02e49

Browse files
committed
dotenv
1 parent 3dfcb62 commit aa02e49

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ yarn-error.log*
99
# Editor directories and files
1010
.idea
1111
.vscode
12+
13+
.env

db/db.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
require('../dotenv'); // eslint-disable-line import/order
2+
13
const DynamoDB = require('aws-sdk/clients/dynamodb');
24
const { Dymon, StatsDChannel } = require('dymon');
35
const dy2json = require('./dy2json');
46

57
const DB = new DynamoDB({
68
apiVersion: '2012-08-10',
9+
endpoint: process.env.AWS_ENDPOINT || undefined,
710
credentials: {
8-
accessKeyId: 'AKIAZM7CQSNGXDQUY6PA',
9-
secretAccessKey: '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',
11+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
12+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
1013
},
11-
region: 'eu-central-1',
14+
region: process.env.AWS_REGION,
1215
});
1316

1417
const dymon = new Dymon({

dotenv.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const path = require('path');
2+
const ENV = require('dotenv').config({ path: path.resolve(__dirname, '.env') });
3+
4+
module.exports = ENV;

example.env

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
AWS_ENDPOINT=""
2+
AWS_REGION="eu-central-1"
3+
AWS_ACCESS_KEY_ID="<YOUR_ACCESS_KEY_ID>"
4+
AWS_SECRET_ACCESS_KEY="<YOUR_SECRET>"

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@koa/cors": "^2.2.3",
1313
"aws-sdk": "^2.610.0",
14+
"dotenv": "^8.2.0",
1415
"dymon": "link:./Dymon",
1516
"koa": "^2.11.0",
1617
"koa-bodyparser": "^4.2.1",

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,11 @@ doctrine@^3.0.0:
463463
dependencies:
464464
esutils "^2.0.2"
465465

466+
dotenv@^8.2.0:
467+
version "8.2.0"
468+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
469+
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==
470+
466471
"dymon@link:./Dymon":
467472
version "0.0.0"
468473
uid ""

0 commit comments

Comments
 (0)