-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Robsahm
committed
Nov 30, 2016
0 parents
commit 1fa4f00
Showing
8 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"presets": [ | ||
"es2015" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"extends": "airbnb", | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"experimentalObjectRestSpread": true | ||
} | ||
}, | ||
"rules": { | ||
"no-console": 0, | ||
"no-mixed-operators": 0, | ||
"react/require-extension": 0, | ||
"arrow-body-style": 0, | ||
"no-confusing-arrow": 0, | ||
"import/prefer-default-export": 0, | ||
"new-cap": 0, | ||
"no-underscore-dangle": 0, | ||
"camelcase": 0, | ||
"no-else-return": 0, | ||
"no-process-env": 2, | ||
"quotes": [1, "double"], | ||
"no-console": [2, { "allow": ["error"] }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint no-process-env: 0 */ | ||
import varium from "varium"; | ||
|
||
module.exports = varium(process.env, "env.manifest"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint no-process-env: 0 */ | ||
|
||
import ws from "ws"; | ||
import url from "url"; | ||
import config from "./config"; | ||
|
||
const updateConfig = (webSocket, environment) => { | ||
webSocket.send(environment); | ||
}; | ||
|
||
export const startUpdateConfig = (environment) => { | ||
const connect = () => { | ||
const webSocket = new ws(url.resolve(config.get("CONFIG_SERVICE_URL"), environment)); | ||
|
||
webSocket.on("open", () => { | ||
updateConfig(webSocket, environment); | ||
setInterval( | ||
updateConfig, | ||
config.get("INTERVAL"), | ||
webSocket, | ||
environment, | ||
); | ||
}); | ||
|
||
webSocket.on("message", (message) => { | ||
process.env = { | ||
...process.env, | ||
...JSON.parse(message), | ||
}; | ||
}); | ||
|
||
webSocket.on("error", (error) => { | ||
console.error("Error:", error); | ||
}); | ||
|
||
webSocket.on("close", () => { | ||
console.error("Socket closed"); | ||
setTimeout(connect, 2000); | ||
}); | ||
}; | ||
|
||
connect(); | ||
}; | ||
|
||
startUpdateConfig("dev"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INTERVAL : Int | ||
CONFIG_SERVICE_URL : String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require("babel-register"); | ||
require("./app"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "next-config-applier", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node .", | ||
"dev-start": "nf run npm run test && nf run npm run start -s", | ||
"test": "eslint --fix ." | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"babel-core": "^6.18.2", | ||
"babel-plugin-transform-object-rest-spread": "^6.19.0", | ||
"babel-preset-es2015": "^6.18.0", | ||
"eslint": "^3.11.1", | ||
"eslint-config-airbnb": "^13.0.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-jsx-a11y": "^2.2.3", | ||
"eslint-plugin-react": "^6.7.1", | ||
"foreman": "^2.0.0" | ||
}, | ||
"dependencies": { | ||
"babel-register": "^6.18.0", | ||
"varium": "github:ahultgren/node-varium", | ||
"ws": "^1.1.1" | ||
} | ||
} |