1.0.1 • Published 6 years ago

node-laravel-config v1.0.1

Weekly downloads
2
License
GPL-3.0-or-later
Repository
-
Last release
6 years ago

Node Config Wraper

How to Use:

import * as dotenv from 'dotenv'
import * as fs from 'fs'

import {config, env, parseEnvToJSON, initConfig, initEnvironment} from "node-laravel-config"

// If you want to use 'dotenv'
dotenv.config()
initEnvironment(process.env)

// Without 'dotenv'
initEnvironment(
    parseEnvToJSON(
        fs.readFileSync(__dirname + '/.test.env', 'utf-8')))

// You'll probably put this call in it's own file
initConfig({
    appName: 'Research Coder',
    
    rabbitmqHost: env('RABBITMQ_HOST', 'localhost'),
    rabbitmqUser: env('RABBITMQ_USER', 'rabbitmq'),
    rabbitmqPass: env('RABBITMQ_PASS', 'rabbitmq'),
    
    mysqlHost: env('MYSQL_HOST', 'localhost'),
    mysqlUser: env('MYSQL_USER', 'root'),
    mysqlPass: env('MYSQL_PASS', 'secret'),
    mysqlDatabase: env('MYSQL_DB', 'SomeDatabase'),

    jwt: {
        private_key: '/path/to/private/key',
        public_key: '/path/to/public/key'
    }
})

// Use the 'env' helper to access environment variables.
console.log(env('RABBITMQ_HOST'))

// Use the 'config' helper to access configuration settings.
console.log(config('jwt.private_key'))