all files / generators/api/config/ config.js

100% Statements 10/10
100% Branches 0/0
100% Functions 4/4
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30                                       
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Class which generated string content for configuration file (based on env variable)
 *
 * @export
 * @class Config
 */
var Config = (function () {
    function Config() {
    }
    /**
     * Generate config file string content based on env variable
     * @return {string} - string generated content
     */
    Config.prototype.getConfig = function () {
        return "module.exports = {\n  development: {\n    morgan: 'dev',\n    APP_PORT: process.env.PORT || 3000\n  },\n  production: {\n    morgan: 'combined',\n    APP_PORT: process.env.PORT || 3000\n  }\n};";
    };
    /**
     * Generate index file string content from /config folder which returns Environment variables by ENV key
     * @return {string} - string generated content
     */
    Config.prototype.getEnvBasedConfig = function () {
        return "const config = require('./config');\n\nmodule.exports = {\n  getEnvBasedConfig: () => {\n    return (config[process.env.NODE_ENV] || config['development']);\n  }\n};";
    };
    return Config;
}());
exports.Config = Config;
exports.default = new Config();