For a project, I am trying to deploy Google Cloud functions as well as Firebase Cloud functions from the same file. That is, I have initiated a Firebase project and in that project file I'm trying to deploy a Google Cloud function for the same project.
The problem I'm facing is that the config for G Cloud function is to be hardcoded in the code itself because unlike Firebase Cloud functions, it is unable to get it from functions.config(). Is there a way in which we can get the config for both the platforms using a single method? Or an alternative way so that for G Cloud functions we don't have to hard code the config again and again? an example of what hard coded config means is as follows. For establishing connection to mysql-
function getMySQLConfig() {
if (!mysqlConfig) {
// const config = functions.config();
//const connectionName = config.config_server_sql.connectionName;//
mysqlConfig = {
// config we get from functions.config()
// host: config.config_server_sql.ip,
// port: config.config_server_sql.port,
// user: config.config_server_sql.dbUser,
// password: config.config_server_sql.password,
// database: config.config_server_sql.dbName,
// multipleStatements: true,
// charset: "utf8mb4_unicode_ci",
//hard coded config
dbName: "config_db",
ip: ‘IP_ADDRESS,
dbUser: "root",
port: 3306,
connectionName: ‘SAMPLE_NAME’,
password: ‘PASSWORD’,
...configSetting
};
// mysqlConfig.socketPath = `/cloudsql/${connectionName}`;
}
return mysqlConfig;
}