Table of Contents |
---|
...
Reference_description_with_linked_URLs____________________________ | Notes__________________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
m Javascript and Nodejs references | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
m Javascript | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
i Javascript | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://drive.google.com/open?id=1gtGNXt1mBN-UOKVboB2l3cRhUZLr3zz6 | Nodejs cheat sheet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://drive.google.com/open?id=122X-MwR-7LctVRuWjefGduliSZf_Acs1 | Nodejs book - free code camp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://drive.google.com/open?id=1vlz4U_-KgmDf-IyeXd4W1JxL-AZz5vHc | Beginner Nodejs book | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://drive.google.com/open?id=1RkkEkEIV1-BMY-23tnPw93LVYDbD-Dn8 | Beginner Nodejs book part 2 - Craftsman | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://drive.google.com/open?id=0BxqKQGV-b4WQY3pIZV8ycHlISEk | Npm Beginners Guide | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://www.scottklement.com/presentations/#WORLDOFNODE nodejs-ibmi-klement-session-World of NodeJS on IBM i.pdf https://drive.google.com/open?id=1jAJtSpNoGW8K8ABE20FI9ej7ZGClcn7m https://drive.google.com/open?id=1N32OltwVm4MUm5Iz98ygOIfQl5L93W4j | Scott Klement Nodejs intro for IBM i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://github.com/nvm-sh/nvm | NVM for Node Version Mgt on any platform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://bytearcher.com/articles/ways-to-get-the-latest-node.js-version-on-a-mac/ | Nodejs versions and upgrade options 1 - MACOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version | Nodejs versions and upgrade options 1 - Linux | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://www.w3schools.com/nodejs/ref_modules.asp | W3Schools Nodejs NPM ** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Node configuration module for environment variables | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://www.guru99.com/node-js-tutorial.html | Tutorial - Full Node.js course - 3 days est - guru99 - excellent - quick Nodej.js, Express, MongoDB - test w curl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://www.guru99.com/node-js-create-server-get-data.html | Tutorial - Create Node.js Data server - guru99 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://developer.okta.com/blog/2019/06/18/command-line-app-with-nodejs | Node.js CLI app with OAuth securityFrameworks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
drive.google/open?id=0BxqKQGV-b4WQdlFPSV9hQ0szamMStrongLoop /html/ online html-handbook.pdf file | html handbook flavio | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
www.profoundlogicprofoundjs css/ online css-handbook.pdf file | css handbook flavio | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://githubthevalleyofcode.com/nestjs/nestjs/ online js-handbook.pdf file | javascript handbook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://docs.nestjsthevalleyofcode.com/node/ online Nestjs an abstracted Node.js services framework built in typescript allows both Javascript and Typescript development.handbook.pdf file | nodejs handbook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
wwwslideshare.netthesoftwarehouseone-tool-to-rule-them-allNestjs overview slides online react-handbook.pdf file | react handbook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
wwwslideshare.netRafaelCasusoRomatesolid-nodejs-with-typescript-jest-nestjsNestjs SOLID design online next-handbook.pdf file | nextjs handbook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Frameworks | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://wwwdrive.slidesharegoogle.net/nirkaufman/nestjs-masterclass-slidesNestjs Master class - 46 slidescom/open?id=0BxqKQGV-b4WQdlFPSV9hQ0szamM | StrongLoop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://www.slideshareprofoundlogic.netcom/BabacarNIANG6/end-to-end-todo-list-app-with-nestjs-angular-redux-redux-saga | Nestjs Todo app w Angular | Web Socketsprofoundjs/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
https://wwwgithub.nodebeginner.orgcom/blog/post/nodejs-tutorial-how-to-work-with-websockets/nestjs/nest https://drivedocs.googlenestjs.com/open?id=1jdcAQrY3zLP3AiSu0DCSx0w2F38KjDmq Nodejs Web sockets example with socket.io use this tutorial for websockets first | Nestjs - an abstracted Node.js services framework built in typescript allows both Javascript and Typescript development. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://mediumwww.slideshare.comnet/@martin.sikorathesoftwarehouse/nodeone-jstool-websocketto-simplerule-chat-tutorial-2def3a841b61filethem-all | Nestjs overview slides | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https:///C:/Users/Jim%20Mason/Google%20Drive/_docs/howto/js/node/tutorials/web-socketswww.slideshare.net/RafaelCasusoRomate/solid-nodejs-chatwith-tutorialtypescript-medium.com-Nodejs%20amp%20WebSocket%20%20Simple%20chat%20tutorial.pdfWeb sockets example in Nodejs without Socket.iojest-nestjs | Nestjs SOLID design | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
https://githubwww.slideshare.comnet/websockets/ws | Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js | Nodejs frameworks | nirkaufman/nestjs-masterclass-slides | Nestjs Master class - 46 slides | |||||||||||||||||||||||||||||||||||||||||||||||||||
https://polterguywww.githubslideshare.io/ Magic Nodejs REST Angular CRUD generator - 600 per servernet/BabacarNIANG6/end-to-end-todo-list-app-with-nestjs-angular-redux-redux-saga | Nestjs Todo app w Angular | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Web Sockets | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
npmjscompackage/harcon | harcon is a microservice solution for NodeJS/Browser giving superior abstraction layer for interoperability between entities in a highly structured and fragmented ecosystem. It allows you to design and implement complex workflows and microservices where context and causality of messages are important. | Nodejs tools blog/post/nodejs-tutorial-how-to-work-with-websockets/ codevisualstudiodocs/nodejs/nodejs-tutorial | VSCode for Nodejs tutorial | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Github |
Key Concepts
...
Nodejs Web sockets example with socket.io use this tutorial for websockets first | |
...
...
...
...
...
set the NVM default version then always run
nvm use default
can set this in the user profile script: .bashrc in the Home directory
Node, NPM support install
uninstall globals before installing NVM to manage Node, NPM
https://docs.npmjs.com/cli/v6/commands/npm-uninstall/
to remove the NPM global package
npm uninstall -g
Use NVM command ( in user/.bashrc ) to install Node, NPM
https://bytearcher.com/articles/ways-to-get-the-latest-node.js-version-on-a-mac/
Ubuntu NVM install
https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version
Uninstall Nodejs on MACOS
Options to Update Node.js
https://phoenixnap.com/kb/update-node-js-version
Use Node config module to manage environment variables
https://zetcode.com/javascript/nodeconfig/
Node-config tutorial shows how to create configuration files for Node applications with node-config module.
Node-config
Node-config creates configuration files for application deployments.
Node-config allows us to define a set of default parameters and extend them for different deployment environments (development, qa, staging, production, etc.).
The configuration files are located in the default config
directory. The location can be overriden with the NODE_CONFIG_DIR
environment variable. The NODE_ENV
environment variable contains the name of our application's deployment environment; it is development
by default.
Node config supports various configuration file formats, including JSON, YAML, properties, or XML. The default configuration file is default.json
(or default.yaml
, default.xml
). If we use a production deployment, then the configuration is loaded from production.json
.
Setting up Node-config
First, we install node-config
.
$ node -v
v11.5.0
We use Node version 11.5.0.
$ npm init -y
We initiate a new Node application.
$ npm i config
We install node-config with nmp i config
.
$ npm i js-yaml
In addition, we install js-yaml
for YAML support.
Node-config example
The following example retrieves configuration data with config
package.
...
simple-chat-tutorial-2def3a841b61 file:///C:/Users/Jim%20Mason/Google%20Drive/_docs/howto/js/node/tutorials/web-sockets-nodejs-chat-tutorial-medium.com-Nodejs%20amp%20WebSocket%20%20Simple%20chat%20tutorial.pdf | Web sockets example in Nodejs without Socket.io |
https://github.com/websockets/ws | Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js |
Nodejs frameworks | |
https://polterguy.github.io/ | Magic Nodejs REST Angular CRUD generator - 600 per server |
https://www.npmjs.com/package/harcon | harcon is a microservice solution for NodeJS/Browser giving superior abstraction layer for interoperability between entities in a highly structured and fragmented ecosystem. It allows you to design and implement complex workflows and microservices where context and causality of messages are important. |
Nodejs tools | |
https://code.visualstudio.com/docs/nodejs/nodejs-tutorial | VSCode for Nodejs tutorial |
Github |
Key Concepts
NVM - Node Version Manager
https://github.com/nvm-sh/nvm#installing-and-updating
set the NVM default version then always run
nvm use default
can set this in the user profile script: .bashrc in the Home directory
Node, NPM support install
uninstall globals before installing NVM to manage Node, NPM
https://docs.npmjs.com/cli/v6/commands/npm-uninstall/
to remove the NPM global package
npm uninstall -g
Use NVM command ( in user/.bashrc ) to install Node, NPM
https://bytearcher.com/articles/ways-to-get-the-latest-node.js-version-on-a-mac/
Ubuntu NVM install
https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version
Uninstall Nodejs on MACOS
Options to Update Node.js
https://phoenixnap.com/kb/update-node-js-version
Use Node config module to manage environment variables
https://zetcode.com/javascript/nodeconfig/
Node-config tutorial shows how to create configuration files for Node applications with node-config module.
Node-config
Node-config creates configuration files for application deployments.
Node-config allows us to define a set of default parameters and extend them for different deployment environments (development, qa, staging, production, etc.).
The configuration files are located in the default config
directory. The location can be overriden with the NODE_CONFIG_DIR
environment variable. The NODE_ENV
environment variable contains the name of our application's deployment environment; it is development
by default.
Node config supports various configuration file formats, including JSON, YAML, properties, or XML. The default configuration file is default.json
(or default.yaml
, default.xml
). If we use a production deployment, then the configuration is loaded from production.json
.
Setting up Node-config
First, we install node-config
.
$ node -v
v11.5.0
We use Node version 11.5.0.
$ npm init -y
We initiate a new Node application.
$ npm i config
We install node-config with nmp i config
.
$ npm i js-yaml
In addition, we install js-yaml
for YAML support.
Node-config example
The following example retrieves configuration data with config
package.
{
"app": {
"port": 3000
},
"db": {
"host": "localhost",
"port": 27017,
"name": "ydb"
}
}
...
$ npm install config
$ mkdir config
$ vi config/default.json
{
// Customer module configs
"Customer": {
"dbConfig": {
"host": "localhost",
"port": 5984,
"dbName": "customers"
},
"credit": {
"initialLimit": 100,
// Set low for development
"initialDays": 1
}
}
}
Edit config overrides for production deployment:
$ vi config/production.json
{
"Customer": {
"dbConfig": {
"host": "prod-db-server"
},
"credit": {
"initialDays": 30
}
}
}
Use configs in your code:
const config = require('config');
//...
const dbConfig = config.get('Customer.dbConfig');
db.connect(dbConfig, ...);
if (config.has('optionalFeature.detail')) {
const detail = config.get('optionalFeature.detail');
//...
}
config.get()
will throw an exception for undefined keys to help catch typos and missing values. Use config.has()
to test if a configuration value is defined.
Start your app server:
$ export NODE_ENV=production
$ node my-app.js
...
https://stackabuse.com/reading-and-writing-csv-files-in-nodejs-with-node-csv/
install the entire node-csv
suite:
npm install node-csv
Read csv file with fileStream and Callback api
csv-parse
package provides multiple approaches for parsing CSV files - using callbacks, a stream + callback as well as the Sync and Async API. We'll be covering the stream + callback API and the Sync API.
var fs = require('fs');
var parse = require('csv-parse');
var parser = parse({columns: true}, function (err, records) {
console.log(records);
});
fs.createReadStream(__dirname+'/chart-of-accounts.csv').pipe(parser);
, we create a parser
which accepts an object literal, containing the options we'd like to set. The second argument is the callback function that's used to access the records - or just print them out, in our case.
Options to specify for the fs include:
The delimiter option defaults to a comma
,
. If the data from the file you’re trying to parse uses some other delimiter like a semi-colon;
, or a pipe|
, you can specify that with this option.The cast option defaults to
false
and is used to indicate whether you want to cast the strings to their native data types. For example, a column that is made up of date fields can be cast into aDate
.The columns option is to indicate whether you want to generate the record in the form of object literals. By default, this column is set to
false
and records are generated by the parser in the form of arrays. If set totrue
, the parser will infer the column name from the first line.
...
Write file using csv-stringify
from the node-csv
suite. Stringification just means that we'll convert some data (JSON in our example) into a string. This string is then written to a file, in CSV format.
The csv-stringify
package also has a couple of API options, though, the Callback API offers a really simple way to stringify data, without the need to handle events like with the Stream API.
reading csv file with Stringifier
stringifier.on('readable', function(){
let row;
while(row = stringifier.read()){
data.push(row)
}
})
URL module
https://www.w3schools.com/nodejs/nodejs_url.asp
...
Mongoose and schema access to MongoDb
Populate on query result
’ll check the endpoint.
This should be setting sellingPrice
as a priceSchema
which is:
{
dollars: Number,
cents: Number (optional),
currency: 'usd' (default)
}
...
/*
nt-mongo-atlas2.js
https://docs.mongodb.com/drivers/node/quick-start
https://docs.mongodb.com/drivers/node/
https://docs.mongodb.com/drivers/node/usage-examples
find by ObjectId ex
https://docs.mongodb.com/drivers/node/usage-examples/findOne
https://kb.objectrocket.com/mongo-db/nodejs-mongodb-find-by-id-686
https://docs.mongodb.com/drivers/node/usage-examples/updateOne
https://docs.mongodb.com/drivers/node/usage-examples/replaceOne
https://wesbos.com/destructuring-objects
*/
var atitle = "\n nt-mongo-atlas2.js - test mongo read write to atlas \n";
console.log(`${atitle}`);
var astep = "start";
const { MongoClient } = require("mongodb");
const uri = "mongodb+srv://dbAdmin:u3KpFTzZBEIEQLzY@cluster0.pfjbe.mongodb.net/test-db";
const connectOptions = {useUnifiedTopology: true};
const client = new MongoClient(uri,connectOptions);
const { ObjectId } = require("mongodb").ObjectId;
var collection = null;
var device = null;
var database = null;
var storageKWH, _id, deviceName, deviceGroup, sumKWH;
async function run() {
try {
await client.connect();
database = client.db("test-db");
collection = database.collection("devices");
await queryDevice();
var {_id, deviceName, deviceGroup, storageKWH} = device;
console.log(`device found = ${deviceName} _id: ${_id}`);
sumKWH = storageKWH + 75;
console.log(` after energy load, sum of storageKWH = ${sumKWH}`);
await updateDevice(device, sumKWH);
console.log(`device energy load completed`);
} finally {
await client.close();
}
};
// https://docs.mongodb.com/drivers/node/usage-examples/findOne
async function queryDevice() {
console.log(`queryDevice called`);
// Query for a movie that has the title 'The Room'
// var query = { deviceName: "solar panel 3000 MW v4" };
var oid1 = new ObjectId("6000908b07564302da69e742");
var query = { _id: oid1};
var options = {
// sort matched documents in descending order by rating
sort: { deviceName: -1 },
// Include only the `title` and `imdb` fields in the returned document
projection: { _id: 1, deviceName: 1, deviceGroup: 1, storageKWH: 1 },
};
// console.log(`query = ${query}`);
device = await collection.findOne(query, options);
// since this method returns the matched document, not a cursor, print it directly
};
// https://docs.mongodb.com/drivers/node/usage-examples/updateOne
async function updateDevice(device, sumKWH) {
var {_id, deviceName, deviceGroup, storageKWH} = device;
var oid1 = new ObjectId(_id);
var filter = {_id: oid1}
var options = {
upsert: true
};
var updateDoc = {
$set: {
storageKWH: sumKWH,
energyStatus: "loaded"
},
};
const result = await collection.updateOne(filter, updateDoc, options );
console.log(`updateDevice "${deviceName}"" matched ${result.matchedCount} count completed with ${sumKWH}`);
};
run().catch(console.dir); result = await collection.updateOne(filter, updateDoc, options );
console.log(`updateDevice "${deviceName}"" matched ${result.matchedCount} count completed with ${sumKWH}`);
};
run().catch(console.dir);
Key Libraries for NodeJS
https://leanylabs.com/blog/npm-packages-for-nodejs/
https://docs.google.com/document/d/1qruyE1PxGCUyv0s7ggYFw59Jd1WizVTv7chmjMIBDoc/edit?usp=sharing
Other NodeJS libraries
MD5 hash
https://gist.github.com/kitek/1579117
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");
https://ourcodeworld.com/articles/read/1547/how-to-create-md5-hashes-in-javascript
// contains: "80244576c6c4e060a8e14b124cebaaa4"
// md5("key", "value")
let hash = md5("carlos", "ourcodeworld");
Overview of Node.js Frameworks
nodejs-frameworks-medium.com-Top 10 Node JS Frameworks to Use in 2023.pdf. link
https://medium.com/@jploft/top-10-node-js-frameworks-to-use-in-2023-60a0d83f405f
nodejs-frameworks-medium.com-Top 10 Node JS Frameworks to Use in 2023.pdf. file
Node JS frameworks have become the top choice to build interactive, cost-effective, scalable, and goal-oriented web and mobile applications. JavaScript is one of the most popular and preferred programming languages for developing enterprise solutions. Node JS offers some of the most useful frameworks for developers to build unique websites quicker than other frameworks available in the market to a Node JS development company. Node JS frameworks are so powerful that businesses, startups, and enterprise solutions can’t reach completion without them.
Here, you will learn a few of the most useful Node JS frameworks that help developers build websites and mobile apps faster and within the budget range.
Potential Value Opportunities
...
NODE_ENV=devLocal PORT=3030 npm start
NODE_ENV=devLocal port=3030 npm #dev
NPM start from shell script passing a config file for environment
...
has been blocked by CORS policy
Access to XMLHttpRequest at 'https://ebc-api-dev.sysopsnetwork.com/authentication' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
What domain are you making your XMLHttpRequest
from and to? CORS is a client-side operation; first you need to identify (1) what page is making the blocked XMLHttpRequest
and then where it is making the request to. The error you pasted seem incomplete, so I'm not clear on how to help. Also it would help if you also included which domain the above Express code is running under as well.
https://github.com/expressjs/cors/issues/184
...
@dougwilson
Member
dougwilson commented on Jan 28, 2020
Gotcha. So which one of those parts are using XMLHttpRequest? It sounds to me based on your description like the XMLHttpRequest is the request to localhost:8090, which is redirected to sso.dol.gov. If this is the case, the sso.dol.gov domain is what needs CORS policy applied to it to allow calls from localhost:3200.
If this is the case, the sso.dol.gov domain is what needs CORS policy applied to it to allow calls from localhost:3200.
Handling CORS error in Nodejs
https://stackabuse.com/handling-cors-with-node-js/
Candidate Solutions
Magic Nodejs REST Angular CRUD generator - 600 per server
see demo - looks good
server pricing may be an issue except for smaller accounts on cloud or on-prem
Magic will read metadata from your database. It will use this metadata to generate an HTTP REST Web API for you, wrapping all CRUD operations inside of REST endpoints. Then it will use metadata from the REST API to automatically generate Angular components, router links, menu items, datagrids, etc. The end result becomes that before you’ve even had to create as much as a single line of code yourself, 90% of your job is already done.
...