Node.js

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Share tech news, updates, or what's on your mind.

Sign up to Post

In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
0
Database Backup and Recovery Best Practices
LVL 2
 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

Team, I need some help diagnosing this issue, asked by one of our DBA's, server is part of a cluster, the cluster was manually failed over to the other node around the time this issue/error occurred?
errorSQL.png
Message
Login failed for user 'XXX\WINXXXX$'. Reason: Token-based server access validation failed with an infrastructure error. Check for previous errors. [CLIENT: XX.XXX.XX.XX] - Any ideas where/how I diagnose what the issue is here?

Many thanks
0
I have this function 'loadSong' that I got from an example on the net. It works fine.

I now want to make 'songName' assigned the value retrieved from a QueryString, such as
localhost:3000?songName=Imagine

How can I do that please?

This is a Node.js application I have running on my local machine where I am testing. Eventually it will be on a Node hosting plan (Heroku).

Thanks!



function loadSong(songName) {
    resetAllBeforeLoadingANewSong();

    // This function builds the current
    // song and resets all states to default (zero muted and zero solo lists, all
    // volumes set to 1, start at 0 second, etc.)
    currentSong = new Song(songName, context);

// I NEED THE VARIABLE songName to be the value of a querystring. For example, from
// localhost:3000?songName=Imagine

// THE REST OF THE CODE IS INFO ONLY



    var xhr = new XMLHttpRequest();
    xhr.open('GET', currentSong.url, true);

    xhr.onload = function (e) {
        // get a JSON description of the song
        var song = JSON.parse(this.response);

        // resize canvas depending on number of samples
        resizeSampleCanvas(song.instruments.length);

        // for eah instrument/track in the song
        song.instruments.forEach(function (instrument, trackNumber) {
            // Let's add a new track to the current song for this instrument
            currentSong.addTrack(instrument);

            // Render HTMl
            var span = document.createElement('tr');
         

Open in new window

0
I'm using one of the free Wordpress themes 'SELA'.

On this page I want the lower iFrame (the multitrack player) to extend across the page. At the moment it is restricted, even though the page template is called 'Wide Page'. The width of the iFrame is set to 1200px.
http://www.ontaraj.com/test-wide-page/

These seems to be a restriction on the theme that prevents a full width iFrame. How can I get round that please?
0
I'm trying to understand how this works so that I can make a few small tweeks.
https://github.com/squallooo/MT5

When the page opens a dropdown list is populated, and a song selection can be made.
I can see that a Function loadSong(songName) { ...} is fired off at that point. (it is in sounds.js)

I have found that I can force the song by doing this on line 342
currentSong = new Song("Londres Appelle", context);

Open in new window

"Londres Appelle" is a song in the demo list.

My question is, would it be possible to force a 'song' in this function by using a URL parameter?
eg.
http://www.mydomain.com/index.html?songName="Londres Appelle"

My background: JavaScript and Node.js newbie. Worked extensively with Classic ASP and VBScript back in the day  (2001-2003). I understand using QueryString to pass a variable to a page, but I don't know if I need to think differently in Node.js.

Thanks.
0
Hi, please need guidance on how to fix the npm error. Thanks so much in advance.

# rpm --query centos-release
centos-release-6-6.el6.centos.12.2.x86_64

Open in new window


# node --version
v0.10.48

Open in new window


# npm --version

module.js:340
    throw err;
          ^
Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at /usr/lib/node_modules/npm/bin/npm-cli.js:18:11
    at Object.<anonymous> (/usr/lib/node_modules/npm/bin/npm-cli.js:86:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

Open in new window

0
Hello,

I am very new to nodejs but have been learning a lot these past few weeks.  I am trying to use passport to implement authentication but I am getting an error that I need to fix.  Any assistance would be much appreciated.  Here is the error I get..
node error
Below is part of my code:

index.js
const express = require('express');
const mongoose = require('mongoose');
const hbs = require('express-handlebars');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser')
const passport = require('passport')
const LocalStrategy = require('passport-local').Strategy
var User = require('./models/account')

mongoose.connect('mongodb:cluster0-shard-00-00-yng8g.mongodb.net:27017,cluster0-shard-00-01-yng8g.mongodb.net:27017,cluster0-shard-00-02-yng8g.mongodb.net:27017/vendorCollection?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin');


app.use(cookieParser())
//Persists data in memory inside of application
app.use(require('express-session')({
    secret: 'vendorSecret',
    resave: false,
    saveUninitialized: false
}))
app.use(passport.initialize())
app.use(passport.session())

//Allows you to use static files
app.use(express.static('public'))

app.use('/vendor', vendorRouter)
app.use('/admin', adminRouter)

passport.use( new LocalStrategy(User.authenticate()) )     //<---Error on this line
passport.serializeUser(User.serialize())
passport.deserializeUser(User.deserialize())

app.listen(3000, ()=>{
  console.log("Server Listening");
})

Open in new window

0
I am building a registration form in node.js using mongoDB.  When I submit my form, it shows blank.  Any ideas?

Here's my code.

vendor.js in my models forlder
//Create model for vendor
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

//Schema for vendor
const vendorSchema = new Schema({
  firstName: String,
  lastName: String,
  phoneNumber: String,
  email: String,
  description: String,
  businessName: String
})

const Vendor = mongoose.model( 'Vendor', vendorSchema );

module.exports = Vendor

Open in new window


vendor.js in my routes folder
const express = require('express')

const Vendor = require('../models/vendor.js')

const vendorRouter = express.Router()

//define Routers
//url: Localhost:3000/vender/registration
console.log("Vendor Router")

vendorRouter.get('/', (req,res) =>{
  res.render('registration')
})
vendorRouter.post('/thanks', (req, res) => {
  console.log(req.body.firstName);
  let newVendor = new Vendor({
    firstName: req.body.firstName,
    lastName: req.body.lastName,
    phoneNumber: req.body.phoneNumber,
    email: req.body.email,
    description: req.body.description,
    businessName: req.body.businessName
  })
	newVendor.save()
	res.redirect('thanks')
})

vendorRouter.get('/thanks', (req,res) =>{
  res.render('thanks')
})

vendorRouter.get('/forgotpassword', (req, res) => {
  res.render('forgotpassword')
})

module.exports = vendorRouter

Open in new window


img dir
Here's how I know blanks are coming in.  Table is populated but noting is showing
img
Here's the page using handlebars
<table id="tblArtist" class="display" cellspacing="0" width="100%" border="1">
<thead>
	<tr>
    <th>First Name</th>
    <th>Last Name</th>
		<th>Phone Number</th>
		<th>Email</th>
	</tr>
</thead>	
<tbody>
{{#each vendors }}
  <tr>
    <td>{{ firstName }}</td>
    <td>{{ lastName }}</td>
    <td>{{ phoneNumber }}    </th>
    <td>{{ email }} </td>
  </tr>
{{/each}}
</tbody>
</table>

Open in new window

0
Hi, I got this Multitrack Player to work on Node.js on a Node hosting service heroku.com
https://github.com/squallooo/MT5
I also got it to work locally on my PC.

I have Wordpress hosting at Dreamhost.

Now I want to include the Multitrack Player into the Wordpress page.
I need some help with that.

For a start, how can I simply 'insert' the player into my WP page?

Thanks.
0
Hi experts,
aI'm trying to update nodejs version , i try this command lines :
f.png
I don't understand why  it can't be updated
PS: am using linux mint 17.2
0
Database Solutions Engineer FAQs
LVL 2
Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Hello Experts,

I have a webpage and I need to get the data from a postgres db.  I will probably hire someone to actually do this, but I'd like to understand the process prior.  I think that I have to use node.js to get the data from the database.  Does that sound right?  Or is there a better way to get at the data?
0
HI experts ,
I have to  update nodejs version. I checked several links but  noway .  
This  is  the last link i tried


But  i find the same nodejs version
f.pngps : am using linux mint 17.2

Thankx for help .
0
Hello I want to change my node location from "TOP" to "warehouse". Can someone please tell me the command?
0
Hi all

The UI for my react app has a main section (takes up most of the screen) and a left hand side pane.
I'm using 3 separate ag-grids:
-One as the main one on the main screen holding the important data.
-the other two are in the left hand side pane (the less important grids for assistance/statistic holding).

This left pane uses (two) tabs, i.e. click on one tab to see one ag-grid, click the other tab to see the other ag-grid

For the tab functionality, i used npm to install the NPM react-bootstrap-tabs node module.

Recently I managed to set up one of the left pain ag-grids to hold filtering information from the main grid.
This was quite a hassle since the grids were effectively grand-sibling components which needed to communicate. without touching AG-grid src code, I had to set up ag-grid callbacks to take note of the filtering data from the main ag-grid, send it up to the grandparent component of my app, and then send it back down to the other grand child ag-grid component.

It all works however I noticed a glitch. When initially loading the whole page, the first tab in the left pane is active by default. The left pane ag-grid that holds the filter information is in the second tab. What I want is to click on this second tab, and see filter data be populated automatically as i filter the main ag-grid. However when I have the second tab active and i filter the main ag-grid (i.e. adding filter …
0
Hello nodejs experts

Is there is anything more on node js standards?  


All urls must be in lower case

Ex: /notification/sendotp

Use HTTP verbs (GET, POST, PUT, DELETE) to operate on the collections and elements.

Use GET – for retrieving single or list data

Use POST – for create data

Use PUT – for update data

Use DELETE – for delete data

HTTP METHOD

POST

GET

PUT

DELETE

CRUD OP

CREATE

READ

UPDATE

DELETE


URLs should include nouns, not verbs in API names. Avoid get,update,save, delete, list in API names.

Maintain singular and plural nouns for APIs.

Ex: for single image retrive – GET - /user/image

For list of images – GET – user/images

User Token must be in headers only. Not as path param or in json body

Use resource, sub-resources for relations

Ex: for user videos use - /user/videos

Put the version number at the base of your URL. /v1/user/images

Controller will have only mandatory parameter validations and sending success, error responses no business logic. Use Service and Helper files for business logic. DAO for db calls

Handle Errors with HTTP status codes

200 – OK – Everything is fine. Created, Saved, Data found

400 – Validations Failed, Missing Mandatory Params, No data found, User already exists, already voted, in valid comment, comment not allowed within a hour, invalid user, invalid video, Video not found

500 – Unknown error, Database error, ES down, timeout from third-party. …
0
I successfully got this example to work on my Windows 10 pc. (thanks to help from Expert it_saige)
https://www.experts-exchange.com/questions/29039118/Running-a-Hello-World-on-Node-js-on-Windows-10-newbie.html?anchor=a42185760¬ificationFollowed=191140277#a42185760

I now want to host it on a GoDaddy hosting account I just signed up for.

I've never setup a Node.js website before - though I have worked with IIS/ASP sites for years.
Is it just a matter of copying the files to a particular folder (eg. root)?

Thanks for any help.
0
I'm trying to run this example here https://github.com/squallooo/MT5 (of an HTML5 application)

It needs to run on Node.js - I am unfimilar with Node.js. (though ok with IIS)

I have downloaded Node.js and installed it. I have downloaded the ZIP file from GitHub.

Can someone please give me a step-by-step to enable me to open/run this one-page web file?

A demo is here http://mainline.i3s.unice.fr/
(pretty cool if you're a musician)

Thanks
0
I am trying to connect to MongoDB in mongoDBatlas from my javascript but I keep getting the following error.

MongoError: connection 5 to isaaccluster-shard-00-02-yng8g.mongodb.net:27017 closed
    at Function.MongoError.create (C:\Users\558642\ga\js-dc-5\11-crud-and-dbs\assignment\todo\node_modules\mongodb-core\lib\error.js:29:11)
    at TLSSocket.<anonymous> (C:\Users\558642\ga\js-dc-5\11-crud-and-dbs\assignment\todo\node_modules\mongodb-core\lib\connection\connection.js:202:22)
    at Object.onceWrapper (events.js:293:19)
    at emitOne (events.js:101:20)
    at TLSSocket.emit (events.js:191:7)
    at _handle.close (net.js:511:12)
    at Socket.done (_tls_wrap.js:332:7)
    at Object.onceWrapper (events.js:293:19)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at TCP._handle.close [as _onclose] (net.js:511:12)


Here's my code
const express = require('express')
const hbs = require('express-handlebars')
const mongoose = require('mongoose')
const bodyParser = require('body-parser')

mongoose.connect('mongodb://XXXXXXXXXXXX@isaaccluster-shard-00-00-yng8g.mongodb.net:27017,isaaccluster-shard-00-01-yng8g.mongodb.net:27017,isaaccluster-shard-00-02-yng8g.mongodb.net:27017/<DATABASE>?ssl=true&replicaSet=IsaacCluster-shard-0&authSource=admin')

const itemEntry = require('./models/toDoEntry.js')
const app = express()

app.get('/', function( req, res ) {
	itemEntry.find({}, function( err, itemEntries ) {
			res.render('todoList',

Open in new window

0
I am looking into Webpack 2 Code Splitting for a project but I'm not sure if I understand how code splitting works.

In my project I have 2 features.

Each feature consists of 4 or 5 files so the code for each feature has several javascript files where the code lives.

These javascript files are NOT ES6 Modules, just standard javascript files with code.

With Webpack 2 Code Splitting I intend to break all these files into 2 groups so that can load them on demand when needed.

So, what I'm thinking of doing with it is ...

1. Project Loads just the core

2. On demand the features will load when needed.

Would code splitting work in this circumstance and is this what it's for?
0
Percona Live Europe 2017 | Sep 25 - 27, 2017
LVL 2
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

I am working on a project using, node, Webpack, babel and ES6.

Inside my project I've created a module which I want to load into the project at runtime.

The end result I'm looking for is that when the application will have different features. The code for each feature will be in a module.

The user can then enable or disable certain features at runtime.

How can I do this?
0
As a junior, I'm a bit new to front end programming (crammed learning JS/other languages/NPM/NodeJS/etc within three months for my current role) so apologies if what I say doesn't make sense.

I've helped to build a UI for an application with the use of NPM/Node JS. The application stores data on a UNIX server. The UI accesses the data on the server (https://myhostname:8090/blah/blah) and presents the results with a nice UI. With the help of GIT, I've managed to do move all the src UI code onto the UNIX server. The purpose is for automation

While a specific file (in my UI code) specifies the UNIX server configuration, I've used NPM to build a bundle.js (Which bundles all the JS files into a single file) file. I move this bundles.js along with the index.html and CSS styling files to an appropriate directory in order to use Maven to build a JAR file. And with a start/stop server script to run the process to run  the code, I can just enter the UNIX hostname/port number in my browser window in order to access the UI and data. This all works.

However. I now need to generalise the server configuration in my bundle.js file as well as properties file on server side such that I'm not hard coding server configuration anywhere (meaning I can deploy the UI on any server with no issue). i.e. playing with "localhost" instead of the actual server hostname etc.

I want to try my best, but I need to acknowledge that I have no real server configuration experience and hence need a …
0
Hi,
I'm trying to setup a new webrtc instance behind the firewall where tcp 80 and 443 ports are only available.
All is fine as long as udp ports are enabled. Once I block udp, I can't establish a client connection.
The stun/turn server has been setup however connections are not redirected from webrtc.

RTCMultiConnection.js config:

var IceServersHandler = (function() {
        function getIceServers(connection) {
            var iceServers = [];
iceServers.push(getTURNObj('turn:my.domain.com:443?transport=tcp', 'user', 'pass'));
            if (window.RMCExternalIceServers) {
                iceServers = iceServers.concat(getExtenralIceFormatted());
            } else if (typeof window.getExternalIceServers !== 'undefined' && window.getExternalIceServers == true) {
                connection.iceServers = iceServers;
                window.iceServersLoadCallback = function() {
                    connection.iceServers = connection.iceServers.concat(getExtenralIceFormatted());
                };
            }

            return iceServers;
        }

        return {
            getIceServers: getIceServers
        };
    })();

turnserver.conf config

listening-port=80
tls-listening-port=443
listening-ip=10.10.10.10
relay-ip=1.1.1.1
external-ip=1.1.1.1/10.10.10.10
lt-cred-mech
user=user:pass
realm=domain.com
no-udp
no-dtls
no-udp-relay
cert=/usr/local/etc/cert.pem
pkey=/usr/local/etc/pkey.pem

All is running in AWS cloud.

0
Which Database Choose?

This Article about choose the NOSQL database based on application requirement. Different NoSQL DB’s available, there are three primary concerns you must balance when choosing a data management system: consistency, availability, and partition tolerance.

 

* Consistency means that each client always has the same view of the data. * Availability means that all clients can always read and write.

* Partition tolerance means that the system works well across physical network partitions.

 

Chose the Database system based on your application requirement.

 Example Comparing MongoDB and CouchDB.

As you can see in the diagram, MongoDB and CouchDB are built with a slightly different focus. Both scale across multiple nodes easily, but MongoDB favours consistency while CouchDB favours availability.

In the MongoDB replication model, a group of database nodes host the same data set and are defined as a Replica set. One of the nodes in the set will act as primary and the others will be secondary nodes. The primary node is used for all write operations, and by default all read operations as well. This means that replica sets provide strict consistency. Replication is used to provide redundancy - to recover from hardware failure or service interruptions.

CouchDB uses a replication model called Eventual consistency. In this system, clients can write data to one node of the database without waiting for other nodes to come into agreement. The …
0
Hi

In Facebook, 1000's of people can like or frown or comment on certain columns.

In the Facebook API, am I able to easily message those people interested in the topic? are there ways, Apps to do this? Any costs?

This message page suggests billions? Really . . . .? . . .  here

Do I need to use Java or PHP coding in any way?

Thanks
0
I am learning Angular, Node, npm, deployd, mongodb, etc.  I am making my way through a book titled "Pro AngularJS" by Adam Freeman.

on page 120 I am attempting to prepare the data for a "real world" application called "sportsstore".

I was instructed to install a module called "deployd" which apparently is used for modelling  API's for web applications.

I did that and when I try to start start the "deployd" service I get an error:

C:\PROGRA~2\deployd>dpd -p 5500 sportsstore\app.dpd --mongod
starting deployd v0.8.9...
internal/child_process.js:289
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:289:26)
    at exports.spawn (child_process.js:380:9)
    at Object.exports.restart (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\lib\util\mongod.js:38:14)
    at Command.start (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\bin\dpd:149:16)
    at Command.listener (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\node_modules\commander\index.js:301:8)
    at emitOne (events.js:96:13)
    at Command.emit (events.js:188:7)
    at Command.parseArgs (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\node_modules\commander\index.js:617:12)
    at Command.parse (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\node_modules\commander\index.js:458:21)
    at Object.<anonymous> 

Open in new window

0

Node.js

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Related Topics