Debug NodeJS Application

Refer: https://dev.to/john_papa/debug-your-nodejs-app-in-60-seconds-5cni

Visual Studio Code (aka VS Code) has changed the game on Node.js debugging. There is a feature called Node: Auto Attach (you can learn more about it here in the docs). Or keep reading — this will only take a minute.

When you enable this feature, you can run your node app from a command line, from an npm script, or from a tool that runs one of those. Just make sure you add the Node Inspector flag to let Node know you are planning on debugging. Once you do this, the debugger lights up in VS Code!

Auto-Attach the Debugger to Node.js Apps with VS Code

Step by Step

Open the settings in VS Code (CMD + , on Mac or CTRL + , on Windows). You can also go to the Command Palette (CMD + SHIFT + P on Mac or CTRL + SHIFT + P on Windows) and search for settings.

Search for “auto attach” and you’ll see a setting for Node: Auto Attach. Go ahead and turn that on.

Now run your Node.js app from your favorite command line whether that be integrated terminal, external terminal.

node --inspect=0.0.0.0:9229 server.js

Now when you launch your app with the --inspect flag the debugger attaches to your app in VS Code! From here you can set breakpoints, step through your code, and have all the great debugging goodness!

Debug NodeJS

Refer: https://dev.to/john_papa/debug-your-nodejs-app-in-60-seconds-5cni

Visual Studio Code (aka VS Code) has changed the game on Node.js debugging. There is a feature called Node: Auto Attach (you can learn more about it here in the docs). Or keep reading — this will only take a minute.

When you enable this feature, you can run your node app from a command line, from an npm script, or from a tool that runs one of those. Just make sure you add the Node Inspector flag to let Node know you are planning on debugging. Once you do this, the debugger lights up in VS Code!

Auto-Attach the Debugger to Node.js Apps with VS Code

Step by Step

Open the settings in VS Code (CMD + , on Mac or CTRL + , on Windows). You can also go to the Command Palette (CMD + SHIFT + P on Mac or CTRL + SHIFT + P on Windows) and search for settings.

Search for “auto attach” and you’ll see a setting for Node: Auto Attach. Go ahead and turn that on.

Now run your Node.js app from your favorite command line whether that be integrated terminal, external terminal.

node --inspect=0.0.0.0:9229 server.js

Now when you launch your app with the --inspect flag the debugger attaches to your app in VS Code! From here you can set breakpoints, step through your code, and have all the great debugging goodness!

NodeJS Connection Pooling

Refer: https://github.com/oracle/node-oracledb/blob/master/doc/api.md#connpoolcache

12.4.3 Connection Pool Cache
When pools are created, they can be given a named alias. The alias can later be used to retrieve the related pool object for use. This facilitates sharing pools across modules and simplifies getting connections.

Pools are added to the cache by using a poolAlias property in the poolAttrs object::

oracledb.createPool (
  {
    user: 'hr',
    password: mypw,  // mypw contains the hr schema password
    connectString: 'localhost/XEPDB1',
    poolAlias: 'hrpool'
  },
  function(err) {  // callback 'pool' parameter can be omitted
    . . . // get the pool from the cache and use it
  }
);

Promos loaded different from QA to Stage

From: "Sankar, Kousalya (HA Group)" <KSankar@HollandAmericaGroup.com>
Subject: Re: Promos loaded different from QA to Stage
Date: June 21, 2018 at 2:21:27 PM PDT

Anila,

To sync up QA and Stage with same data for feed and API, We are thinking of these steps

  • Stop ETL job on both QA and Stage
  • Take weekly snapshot of Voyage and Offer Mongo collections from Prod and upload to Stage and QA Mongo.
  • CJ to check UAT voyages on Mongo and update Rate Codes in Polar region if needed
  • Point Node API for feed to use Prod Oracle
  • Generate feed from QA and Stage (daily or weekly)
  • Feed ingestion scheduled to run on both QA and Stage (daily or weekly)

Thanks,
Kousalya

From: "Poreddy, Rohith (HAL Contractor)" <RPoreddy@hollandamerica.com>
Subject: RE: Promos loaded different from QA to Stage
Date: June 21, 2018 at 11:04:55 AM PDT

Please find the details below

QA:
Data file folder location used by ETL job:  /cdsshore/test-dwh-data
Node API Mongo location for feed:  haluxqamdb02.hq.halw.com
Node API Mongo location for API:  haluxqamdb02.hq.halw.com
Are we running feed ingestion on AEM-QA on daily basis?   Ingestion I am not sure, but we do upload files every day to S3.
ETL Job Status:  Runs every day around 6:30am

STAGE:
Data file folder location used by ETL job:   /cdsshore/test-dwh-data
Node API Mongo location for feed:  haluxstgmdb07.hq.halw.com
Node API Mongo location for API:   haluxstgmdb07.hq.halw.com
Are we running feed ingestion on AEM-STAGE on daily basis?   Ingestion I am not sure, but we do upload files every day to S3.
ETL Job Status:  Currently the ETL job is disabled on Stage

Thanks,
Rohith

Installing NPM and NodeJS in Ubuntu

Possible Solution (Not Tested):
http://www.hostingadvice.com/how-to/install-nodejs-ubuntu-14-04/

Updating NPM
Refer: http://stackoverflow.com/questions/23393707/how-to-update-npm

This will update npm using npm itself:

# This is for initial installation
$ sudo npm install npm -g

# This is for upgrade
$ sudo npm update npm -g

From article: If you are stuck, try sudo npm update npm -g. All credit goes to Tim Castelijns. I have tested it on ubuntu 14.04, npm 1.3.10

Note that if you are using nvm for managing multiple versions in your local dev environment for e.g. testing purposes, all your installed versions (listed by nvm ls) are in ~/.nvm, hence you just omit system wide installation (i.e. omit sudo):

$ npm install npm -g

Updated version of NodeJS - Chris Lea
Refer: https://nodesource.com/blog/chris-lea-joins-forces-with-nodesource