Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodejs AssertionError [ERR_ASSERTION]: You must specify the endpoint url when invoking this module #223

Open
armanriazi opened this issue May 13, 2020 · 1 comment

Comments

@armanriazi
Copy link

armanriazi commented May 13, 2020

Expected Behavior

AssertionError [ERR_ASSERTION]: You must specify the endpoint url when invoking this module
I am suggesting event emitter maybe. I need away for converting dburl() to dburl object

Current Behavior

I used couchdb and I was wondering If you could help me about differential between

require("nano")(require("../startup/environment").dburl) <=with=>
require("nano")(require("../startup/environment").dburl())

It is ok when I set process.env.DB_ADDRESS on line of this code(Bookmark:/)

    const winston = require("winston");
    const fs = require("fs");
    const result = require("dotenv").config();
    
    if (result.error) {
      throw result.error;
    }
    winston.info(result.parsed);
    
    const doSelectEnv = () => {
      switch (process.env.NODE_ENV) {
        case "development":
          const envConfigDev = require("dotenv").parse(
            fs.readFileSync(".env.override.development")
          );
          for (const k in envConfigDev) {
            process.env[k] = envConfigDev[k];
            winston.info(process.env[k]);
          }
          break;
        case "production":
          const envConfigPro = require("dotenv").parse(
            fs.readFileSync(".env.override.production")
          );
          for (const k in envConfigPro) {
            //Bookmark **********\/********** if("DB_ADDRESS" == k)  {
            //  console.log(url);
            // }
            process.env[k] = envConfigPro[k];
            winston.info(process.env[k]);
          }
          break;
        case "stage":
          const envConfigStage = require("dotenv").parse(
            fs.readFileSync(".env.override.stage")
          );
          for (const k in envConfigStage) {
            process.env[k] = envConfigStage[k];
            winston.info(process.env[k]);
          }
          break;
      }
    };
    exports.doSelectEnv = doSelectEnv;
    exports.dburl =  "http://dbadmin:server@192.168.1.11:5984"; // process.env.DB_ADDRESS

If I use dburl object it will execute (user.js consume dburl)

  const db = require("nano")(require("../startup/environment").dburl).use(
     "dbvidly"
   );

Steps to Reproduce (for bugs)

But I need this code because of DB_ADDRESS

exports.dburl = ()=> {return process.env.DB_ADDRESS);

when I used this code then rising ERR_ASSERTION

    const db = require("nano")(require("../startup/environment").dburl()).use(
          "dbvidly"
        );

AssertionError [ERR_ASSERTION]: You must specify the endpoint url when invoking this module

Your Environment

  • Version nodejs: 8.11.1 on container
  • executed by nodemon
@armanriazi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant