Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

best way to store db config in node js

var config = {
development: {
    //url to be used in link generation
    url: 'http://my.site.com',
    //mongodb connection settings
    database: {
        host:   '127.0.0.1',
        port:   '27017',
        db:     'site_dev'
    },
    //server details
    server: {
        host: '127.0.0.1',
        port: '3422'
    }
},
production: {
    //url to be used in link generation
    url: 'http://my.site.com',
    //mongodb connection settings
    database: {
        host: '127.0.0.1',
        port: '27017',
        db:     'site'
    },
    //server details
    server: {
        host:   '127.0.0.1',
        port:   '3421'
    }
}
};
module.exports = config;
Comment

best way to store db config in node js

var env = process.env.NODE_ENV || 'development';
var config = require('./config')[env];
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs string value check === and !== 
Javascript :: app scrip sheet cell boarder 
Javascript :: javascript loop Tool 
Javascript :: .chartjs-render-monitor 
Javascript :: make express app object accessible from all project modules 
Javascript :: fly: Javascript 
Javascript :: convert javascript to java regex 
Javascript :: global variables using strict mode 
Javascript :: vue send event plus variable 
Javascript :: no unused vars blank underscore javacript 
Javascript :: maximum element in an array javascript 
Javascript :: dom jquery 
Javascript :: blank array condition in react js 
Javascript :: close all function of react in vscode mac 
Javascript :: cors error in post request resolved 
Javascript :: NetSuite Add Line Item to a Sales Order in afterSubmit 
Javascript :: turn any function into promise 
Javascript :: set select2 value from local storage 
Javascript :: javascript verbatim string 
Javascript :: how to accept only. proper email from an input field react with functional component 
Javascript :: mongoose validate array of references required 
Javascript :: add position suffix to number in js 
Javascript :: JavaScript endsWith() example with length parameter 
Javascript :: input creates console log delay 
Javascript :: url-regex-improvement-to-allow-localhost-url 
Javascript :: how to test emited method from child component vue js 
Javascript :: i wanted to detect when a user enters an alphabet key in input text javascript 
Javascript :: tictactoe using Jquery 
Javascript :: js append sample 
Javascript :: js sol 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =