Skip to content

Commit

Permalink
Closes #37: Replace node-config with a JS config file
Browse files Browse the repository at this point in the history
`node-config` is hard to use with transpilers, because it uses
conditional dependencies, see node-config/node-config#345. Move
endpoint configs into a simple JS module.
  • Loading branch information
jaredhirsch authored and Marina Samuel committed Feb 6, 2017
1 parent ba7b1c4 commit c6e61b2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 10 deletions.
5 changes: 5 additions & 0 deletions config.js
@@ -0,0 +1,5 @@
module.exports = {
endpoint: process.env.NODE_ENV === "production" ?
"https://tiles.services.mozilla.com/v3/links/ping-centre" :
"https://onyx_tiles.stage.mozaws.net/v3/links/ping-centre"
};
3 changes: 0 additions & 3 deletions config/default.json

This file was deleted.

3 changes: 0 additions & 3 deletions config/production.json

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -21,7 +21,6 @@
"homepage": "https://github.com/mozilla/ping-centre#readme",
"dependencies": {
"chai-as-promised": "^6.0.0",
"config": "^1.24.0",
"isomorphic-fetch": "^2.2.1",
"joi": "^10.0.1",
"node-fetch": "^1.6.3",
Expand Down
4 changes: 2 additions & 2 deletions ping-centre.js
Expand Up @@ -4,7 +4,7 @@ require("isomorphic-fetch");
const commonSchema = require("./schemas/commonSchema");
const Joi = require("joi");
const uuid = require("uuid");
const config = require("config");
const config = require("./config");

class PingCentre {
constructor(topic, clientID, pingEndpoint) {
Expand All @@ -13,7 +13,7 @@ class PingCentre {
}
this._topic = topic;
this._clientID = clientID || uuid();
this._pingEndpoint = pingEndpoint || config.get("endpoint");
this._pingEndpoint = pingEndpoint || config.endpoint;

const schema = require(`./schemas/${topic}`);
this._schema = schema || commonSchema;
Expand Down
2 changes: 1 addition & 1 deletion test/endpoints.js
Expand Up @@ -15,7 +15,7 @@ describe("Ping Centre Endpoints", function() {
// required again in order to require config again and look up the
// newly set environment variables.
delete require.cache[require.resolve("../ping-centre")];
delete require.cache[require.resolve("config")];
delete require.cache[require.resolve("../config")];

process.env["NODE_ENV"] = "production";
const PingCentre = require("../ping-centre");
Expand Down

0 comments on commit c6e61b2

Please sign in to comment.