I am currently learning Javascript/HTML/CSS in order to build some data dashboard.
I have found this tutorial https://d3-dashboard.cube.dev/setting-up-a-database-and-cube-js
Currently I am getting stuck at this part:
The next step is to create a Cube.js data schema.
When opening the Cube.js playground at: http://localhost:4000, I get the following output in my terminal:
๐ฆ
Dev environment available at http://localhost:4000, I get the following error:
๐ Cube.js server (0.21.1) is listening on 4000
Error: getaddrinfo ENOTFOUND <YOUR_DB_HOST_HERE>
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
And in the Cube.js playground webpage view:
Error while loading DB schema
Error: getaddrinfo ENOTFOUND <YOUR_DB_HOST_HERE> at
GetAddrInfoReqWrap.onlookup [as oncomplete](dns.js66:26)
I have edited the following file:
d3-dashboard/node_modules/#cubejs-backend/server-core/core/index.js
, with:
const checkEnvForPlaceholders = () => {
const placeholderSubstr = '<YOUR_DB_';
const credentials = [
'CUBEJS_API_SECRET=SECRET',
'CUBEJS_DB_TYPE=postgres',
'CUBEJS_DB_NAME=ecom',
'CUBEJS_WEB_SOCKETS=true'
/*'CUBEJS_DB_HOST',*/
/*'CUBEJS_DB_NAME',*/
/*'CUBEJS_DB_USER',*/
/*'CUBEJS_DB_PASS'*/
];
Any input on what I am doing wrong here?
I am totally new to apps and front-ends, so it might be something "stupid" that I am sking, but I really would like to learn from my mistakes :)
Thank you for your time and potential inputs/help!
Have a great day :)
You definitely should not edit any files in the node_modules directory. You should store the env variables in the .env file.
-your-cubejs-server-root
--schema
--.env
--//..
And it may look like
CUBEJS_DB_HOST=localhost
CUBEJS_DB_NAME=cubejs
CUBEJS_DB_USER=root
CUBEJS_DB_PASS=
CUBEJS_DB_TYPE=mysql
CUBEJS_API_SECRET=secret
The error you're getting is saying that the connection to the DB cannot be established. Because you're missing the proper CUBEJS_DB_HOST= variable.
The minimum required set of variables differs for each database and can be found here https://cube.dev/docs/connecting-to-the-database
Related
I wrote a simple smart contract in Solidity 0.6.6 that I'm trying to deploy to the BSC Testnet.
This is what I have in my truffle-config.js file (privateKeys is an array with a single entry of ['0x + privatekey']:
networks: {
bscTestnet: {
provider: () => new HDWalletProvider(
privateKeys,
'https://data-seed-prebsc-1-s1.binance.org:8545/'
),
network_id: 97,
skipDryRun: true
}
}
When I run the command "truffle migrate --reset --network bscTestnet" I get the following error:
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'bscTestnet'
> Network id: 97
> Block gas limit: 30000000 (0x1c9c380)
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" -- cb is not a function.
at /Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration._deploy (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:70:1)
at Migration._load (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1)
at Migration.run (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1)
at Object.runMigrations (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
at Object.runFrom (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
at Object.runAll (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
at Object.run (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
at runMigrations (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:80:1)
at Object.module.exports [as run] (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:44:1)
at Command.run (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)
Truffle v5.4.31 (core: 5.4.31)
Node v17.4.0
Opened an Issue a about it: https://github.com/trufflesuite/truffle/issues/4676
I guess its a bug in HardwareWallet2.0.2.
Reverting to HardwareWallet2.0.0 solved the problem for me
npm i #truffle/hdwallet-provider#2.0.0
UPDATE:
Right, workaround: I rolled #HDWalletProvider back to v2.0.1 and was able to migrate.
I assume there must be an issue with the new version for ppl who updated today.
================
Same problem with Polygon Mumbai.
Function "cb" refers to the callback function. The strange part is the error message doesn't reference my own code at all; it references the migrations.js located in:
<.nvm/versions/node/v16.11.1/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
at processTicksAndRejections (node:internal/process/task_queues:96:5>
This leads me to believe there's a problem with out 1_initial_migration.js... however that's auto-generated so I can't see any problem... it's strange.
1_initial_migration.js:
const Migrations = artifacts.require("Migrations");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
I'm following the tutorial step by step, when I get to the part of run npx mikro-orm migration:create, I get this error
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received null
at prepareSecretKey (internal/crypto/keys.js:322:11)
at new Hmac (internal/crypto/hash.js:113:9)
at Object.createHmac (crypto.js:147:10)
at createHMAC (C:\lireddit-server\node_modules\pg\lib\sasl.js:133:17)
at Hi (C:\lireddit-server\node_modules\pg\lib\sasl.js:137:13)
at Object.continueSession (C:\lireddit-server\node_modules\pg\lib\sasl.js:32:24)
at Client._handleAuthSASLContinue (C:\lireddit-server\node_modules\pg\lib\client.js:248:10)
at Connection.emit (events.js:314:20)
at Connection.EventEmitter.emit (domain.js:483:12)
at C:\lireddit-server\node_modules\pg\lib\connection.js:109:12
at Parser.parse (C:\lireddit-server\node_modules\pg-protocol\src\parser.ts:102:9)
at Socket.<anonymous> (C:\lireddit-server\node_modules\pg-protocol\src\index.ts:7:48)
at Socket.emit (events.js:314:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at addChunk (_stream_readable.js:298:12)
at readableAddChunk (_stream_readable.js:273:9)```
I can't find any solution on google, and the tut doesn't point out how to login to postgresql on the app
You are missing some configuration, most probably user or password fields. Here is related issue:
https://github.com/mikro-orm/mikro-orm/issues/866
If you do not provide them, MikroORM will pick the defaults for given driver, which is postgres user and empty password - your postgres installation apparently do not have empty password for this user.
If you are using docker to create the postgres server, this is how you can make it accept empty pws:
postgre:
image: postgres:12.4
ports:
- 5432:5432
environment:
POSTGRES_HOST_AUTH_METHOD: trust <-- here
It seems like you have not specified the password or user property of an object which you are passing inside of MikroORM.init.
This should work
export default {
entities: [Entity],
dbName: "yourDatabaseName",
type: "postgresql",
user: "yourUserName",
password: "yourPassword"
} as Parameters<typeof MikroORM.init>[0];
I have a backend project on Node js. Right now installed Node 14. So I have Jest and want to test functions from the auth.js file. So I create auth.test.js and import login from '../auth.js 0 got unexpected token error.
Then I do the trick with esm according to the node documentation
So I hade "type":module" in my package.json file, but it didn't provide any result.
So now I did this:
const esmImport = require('esm')(module);
const login = esmImport('../src/controllers/auth')(module);
test('Auth login', () => {
let result = 'OK';
expect(result).toBe('OK')
})
And the error is:
FAIL test/auth.test.js
โ Test suite failed to run
D:\Programming\Anami\anami-backend\node_modules\wkx\lib\point.js:1
RangeError: Maximum call stack size exceeded
Any help how to fix this issue?
I'm creating a SailsJS application, and I want users to log in only with Steam authentication. I used sails-generate-auth to create some boilerplate code with sails routes, but I'm having trouble plugging passport-steam into it.
https://github.com/kasperisager/sails-generate-auth
https://github.com/liamcurry/passport-steam
The reported error is:
C:\Users\Joe\testProject\node_modules\passport-steam\lib\passport-steam\strategy.js:67
id: result.response.players[0].steamid,
^
TypeError: Cannot read property 'steamid' of undefined
at steamapi.getPlayerSummaries.callback (C:\Users\Joe\testProject\node_modules\passport-steam\lib\passport-steam\strategy.js:67:43)
at IncomingMessage.<anonymous> (C:\Users\Joe\testProject\node_modules\passport-steam\node_modules\steam-web\lib\steam.js:218:7)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickDomainCallback (node.js:486:13)
I have a feeling that this is caused by SteamWebAPI returning an empty response: {"response":{"players":[]}}, which is caused by a bogus SteamID in the request. The offending line is here in passport-steam: https://github.com/liamcurry/passport-steam/blob/master/lib/passport-steam/strategy.js#L53
Looking at identifier parameter to getUserProfile, it appears to be the entire Sails request scope. If I hardcode a good steam id into that array, I get this error:
C:\Users\Joe\testProject\api\services\passport.js:98
return next(new Error('Neither a username nor email was available'));
^
TypeError: undefined is not a function
at Authenticator.passport.connect (C:\Users\Joe\testProject\api\services\passport.js:98:12)
at module.exports (C:\Users\Joe\testProject\api\services\protocols\openid.js:24:12)
at steamapi.getPlayerSummaries.callback (C:\Users\Joe\testProject\node_modules\passport-steam\lib\passport-steam\strategy.js:72:11)
at IncomingMessage.<anonymous> (C:\Users\Joe\testProject\node_modules\passport-steam\node_modules\steam-web\lib\steam.js:218:7)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickDomainCallback (node.js:486:13)
I think that makes sense since the steam response doesn't have a username nor email, but this is the profile: {"emails":[{}],"name":{}}
This is my passport configuration:
steam: {
name: 'Steam',
protocol: 'openid',
strategy: require('passport-steam').Strategy,
options: {
returnURL: 'http://localhost:1337/auth/steam/callback',
realm: 'http://localhost:1337/',
apiKey:'STEAM-API-KEY-REMOVED'
}
}
}
Not sure if there is something simple I'm missing, or I need to write a ton of custom handling. Is my configuration correct?
This is caused by out-of-date source code in npm. Even with the latest 0.1.4 version, the code is not correct. Replacing strategy.js in passport-steam with the latest version will fix this error.
Also, in api\services\passport.js, a little custom handling in passport.connect() needs to be added. The profile does not have a username, but has an id (user steamid) and displayName. These can be used to set the user model properties, e.g.
//steam auth
if (profile.hasOwnProperty('displayName')) {
user.username = profile.displayName;
}
Here is the ticket where the problem was solved: https://github.com/liamcurry/passport-steam/issues/10
I've been working through the learnyoujs and stream-adventure tutorials:
https://github.com/substack/stream-adventure
https://github.com/rvagg/learnyounode#learn-you-the-nodejs-for-much-win
I've gotten all the way through the first set and most of the way thorough the second, but I keep getting an odd error... usually I can get it to go away.
Here's the command/error:
DEV/javascript/streamAdventure ยป stream-adventure run httpserver.js
stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
This will launch but not kill the process for node, so I ps aux | grep node and then find the process and kill it.
Here's the "working" code from the tutorial:
var http = require('http');
var through = require('through');
var server = http.createServer(function (req, res) {
if (req.method === 'POST') {
req.pipe(through(function (buf) {
this.queue(buf.toString().toUpperCase());
})).pipe(res);
}
else res.end('send me a POST\n');
});
server.listen(8000);
If I just run nod httpserver.js and then curl at it, it works fine.... so does anyone have any insight into what is causing this error?
There is a pull request to fix this, here:
https://github.com/substack/stream-adventure/pull/16
Try to listen on port 8001 instead and rerun verify after closing all processes listening on 8000.
I had the same error, problem wasn't with though node however, it was with mysql.
Ran "mysqld_safe restart" (depends on your version), then it worked fine.