Skip to content

Commit

Permalink
Updated hardcoded env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy-sandhu committed Oct 15, 2024
1 parent 6e05747 commit 840c5b7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 25 deletions.
7 changes: 3 additions & 4 deletions cts/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
"use strict";

// require('dotenv').config();

const Hapi = require("@hapi/hapi"),
H2o2 = require("@hapi/h2o2"),
Inert = require("@hapi/inert"),
Expand Down Expand Up @@ -67,7 +65,8 @@ const provision = async () => {
}
};

await waitPort({host: process.env.DB_HOST, port: 3306});
const DB_HOST = (process.env.DB_HOST || "rdbms");
await waitPort({host: DB_HOST, port: 3306});

const db = await require("./lib/db")();

Expand Down Expand Up @@ -305,4 +304,4 @@ process.on(
}
);

provision();
provision();
27 changes: 18 additions & 9 deletions cts/service/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,33 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
const DB_HOST = (process.env.DB_HOST || "rdbms");
const DB_NAME = (process.env.DB_NAME || "catapult_player");
const DB_USERNAME = (process.env.DB_USERNAME || "catapult");
const DB_PASSWORD = (process.env.DB_PASSWORD || "quartz");

const Hoek = require("@hapi/hoek"),
waitPort = require("wait-port"),
{
MYSQL_HOST: HOST = process.env.DB_HOST,
// MYSQL_HOST: HOST = "rdbms",
MYSQL_HOST_FILE: HOST_FILE,
DATABASE_USER: USER = process.env.DB_USER,
// DATABASE_USER: USER = "catapult",
DATABASE_USER_FILE: USER_FILE,
DATABASE_USER_PASSWORD: PASSWORD = process.env.DB_PASSWORD,
// DATABASE_USER_PASSWORD: DB_PASSWORD,
DATABASE_USER_PASSWORD_FILE: PASSWORD_FILE,
DATABASE_NAME: DB = process.env.DB_DATABASE_NAME,
// DATABASE_NAME: DB = "catapult_player",
DATABASE_NAME_FILE: DB_FILE,
} = process.env;

module.exports = async () => {
const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST,
user = USER_FILE ? fs.readFileSync(USER_FILE) : USER,
password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD,
database = DB_FILE ? fs.readFileSync(DB_FILE) : DB;
// const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST,
// user = USER_FILE ? fs.readFileSync(USER_FILE) : USER,
// password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD,
// database = DB_FILE ? fs.readFileSync(DB_FILE) : DB;
const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : DB_HOST,
user = USER_FILE ? fs.readFileSync(USER_FILE) : DB_USERNAME,
password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : DB_PASSWORD,
database = DB_FILE ? fs.readFileSync(DB_FILE) : DB_NAME;

await waitPort({host, port: 3306});

Expand Down Expand Up @@ -89,4 +98,4 @@ module.exports = async () => {
return result;
}
};
};
};
8 changes: 4 additions & 4 deletions player/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ const Hapi = require("@hapi/hapi"),
TOKEN_SECRET,
API_KEY,
API_SECRET,
PLAYER_API_ROOT,
MYSQL_HOST
PLAYER_API_ROOT
} = process.env;

const rootPath = (PLAYER_API_ROOT || "");
const rootPath = (process.env.PLAYER_API_ROOT || "");

const provision = async () => {
const server = Hapi.server(
Expand Down Expand Up @@ -66,7 +65,8 @@ const provision = async () => {
}
};

await waitPort({host: MYSQL_HOST, port: 3306});
const DB_HOST = (process.env.DB_HOST || "rdbms");
await waitPort({host: DB_HOST, port: 3306});

const db = await require("./lib/db")();

Expand Down
27 changes: 19 additions & 8 deletions player/service/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,35 @@
See the License for the specific language governing permissions and
limitations under the License.
*/

const DB_HOST = (process.env.DB_HOST || "rdbms");
const DB_NAME = (process.env.DB_NAME || "catapult_player");
const DB_USERNAME = (process.env.DB_USERNAME || "catapult");
const DB_PASSWORD = (process.env.DB_PASSWORD || "quartz");

const Hoek = require("@hapi/hoek"),
waitPort = require("wait-port"),
{
MYSQL_HOST,
// MYSQL_HOST: HOST = "rdbms",
MYSQL_HOST_FILE: HOST_FILE,
DATABASE_USER,
// DATABASE_USER: USER = "catapult",
DATABASE_USER_FILE: USER_FILE,
DATABASE_USER_PASSWORD,
// DATABASE_USER_PASSWORD: DB_PASSWORD,
DATABASE_USER_PASSWORD_FILE: PASSWORD_FILE,
DATABASE_NAME,
// DATABASE_NAME: DB = "catapult_player",
DATABASE_NAME_FILE: DB_FILE,
} = process.env;

module.exports = async () => {
const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : MYSQL_HOST,
user = USER_FILE ? fs.readFileSync(USER_FILE) : DATABASE_USER,
password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : DATABASE_USER_PASSWORD,
database = DB_FILE ? fs.readFileSync(DB_FILE) : DATABASE_NAME;
// const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST,
// user = USER_FILE ? fs.readFileSync(USER_FILE) : USER,
// password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD,
// database = DB_FILE ? fs.readFileSync(DB_FILE) : DB;
const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : DB_HOST,
user = USER_FILE ? fs.readFileSync(USER_FILE) : DB_USERNAME,
password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : DB_PASSWORD,
database = DB_FILE ? fs.readFileSync(DB_FILE) : DB_NAME;


await waitPort({host, port: 3306});

Expand Down

0 comments on commit 840c5b7

Please sign in to comment.