Skip to content

Commit 76aeb96

Browse files
committed
add dotenv
1 parent 9de1d61 commit 76aeb96

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

.babelrc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@
77
["module-resolver", {
88
"root": ["./src"]
99
}]
10-
]
10+
],
11+
"env": {
12+
"development": {
13+
"plugins": ["inline-dotenv"]
14+
},
15+
"production": {
16+
"plugins": ["transform-inline-environment-variables"]
17+
}
18+
}
1119
}

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NODE_ENV=development
2+
MODE=development
3+
GITHUB_API_ENDPOINT=https://api.github.com

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"dependencies": {
33
"axios": "^0.17.1",
44
"babel-plugin-module-resolver": "^3.0.0",
5+
"babel-plugin-transform-inline-environment-variables": "^0.2.0",
56
"babel-preset-env": "^1.6.1",
67
"compression": "^1.7.1",
78
"express": "^4.16.2",
@@ -31,22 +32,25 @@
3132
"version": "1.0.0",
3233
"main": "server/index.js",
3334
"devDependencies": {
35+
"babel-plugin-inline-dotenv": "^1.1.2",
3436
"enzyme": "^3.3.0",
3537
"enzyme-adapter-react-16": "^1.1.1",
3638
"jest": "^22.1.2",
3739
"nodemon": "^1.12.1",
3840
"raf": "^3.4.0",
3941
"react-test-renderer": "^16.2.0",
42+
"rimraf": "^2.6.2",
4043
"snazzy": "^7.0.0",
4144
"standard": "^10.0.3",
4245
"webpack-bundle-analyzer": "^2.9.1"
4346
},
4447
"scripts": {
45-
"build": "next build",
48+
"build": "NODE_ENV=production next build",
4649
"test:ci": "jest --maxWorkers=2 --ci",
4750
"test": "jest --watch",
4851
"start": "nodemon -w server server/index.js",
49-
"clean": "rm -rf node_modules/.cache .next",
52+
"serve": "NODE_ENV=production node server/index.js",
53+
"clean": "rimraf node_modules/.cache .next",
5054
"lint": "standard --verbose | snazzy",
5155
"lint-fix": "standard --fix --verbose | snazzy"
5256
},

src/libs/github.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import axios from 'axios'
22
import humps from 'humps'
3-
4-
const ENDPOINT = 'https://api.github.com'
3+
import config from 'config'
54

65
const github = {
76
getTopRepos ({ lang = 'javascript' }) {
8-
let path = `${ENDPOINT}/search/repositories?q=language:${lang}&sort=stars&order=desc`
7+
let path = `${config.githubApiEndpoint}/search/repositories?q=language:${lang}&sort=stars&order=desc`
98
return axios.get(path).then(res => {
109
return humps.camelizeKeys(res.data)
1110
})

yarn.lock

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,12 @@ babel-plugin-check-es2015-constants@^6.22.0:
570570
dependencies:
571571
babel-runtime "^6.22.0"
572572

573+
babel-plugin-inline-dotenv@^1.1.2:
574+
version "1.1.2"
575+
resolved "https://registry.yarnpkg.com/babel-plugin-inline-dotenv/-/babel-plugin-inline-dotenv-1.1.2.tgz#d9b43f48b1471506bdc5fe571a067472f16aedf6"
576+
dependencies:
577+
dotenv "^4.0.0"
578+
573579
babel-plugin-istanbul@^4.1.5:
574580
version "4.1.5"
575581
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e"
@@ -836,6 +842,10 @@ babel-plugin-transform-flow-strip-types@^6.22.0:
836842
babel-plugin-syntax-flow "^6.18.0"
837843
babel-runtime "^6.22.0"
838844

845+
babel-plugin-transform-inline-environment-variables@^0.2.0:
846+
version "0.2.0"
847+
resolved "https://registry.yarnpkg.com/babel-plugin-transform-inline-environment-variables/-/babel-plugin-transform-inline-environment-variables-0.2.0.tgz#37dad411a819667fd69c33e72f7a14ea1a50ba98"
848+
839849
840850
version "6.26.0"
841851
resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz#0f36692d50fef6b7e2d4b3ac1478137a963b7b06"
@@ -2102,6 +2112,10 @@ dot-prop@^4.1.0, dot-prop@^4.1.1:
21022112
dependencies:
21032113
is-obj "^1.0.0"
21042114

2115+
dotenv@^4.0.0:
2116+
version "4.0.0"
2117+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d"
2118+
21052119
duplexer3@^0.1.4:
21062120
version "0.1.4"
21072121
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"
@@ -6159,7 +6173,7 @@ right-align@^0.1.1:
61596173
dependencies:
61606174
align-text "^0.1.1"
61616175

6162-
rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1:
6176+
rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2:
61636177
version "2.6.2"
61646178
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
61656179
dependencies:

0 commit comments

Comments
 (0)