apache / apache/couchdb-nano

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

Open
#223 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
689
Forks
167
Avg merge
1h
Merged PRs (30d)
1

Description

## 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

Contributor guide

Open the contributing guide

Research direction

Start with startup/environment, especially the dburl export, and inspect how user.js invokes nano with dburl versus dburl(). Reproduce the two forms using the reported Node.js 8.11.1 environment and the DB_ADDRESS setup. Done means clearly identifying the invocation difference and documenting or confirming the expected endpoint behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.