w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » NODE JS » Page 1
express route handler context is global (node.js)
That's because you're just passing the function itself. Once you do that, the context is gone. There's at least two solutions for this: Create a wrapper function: App.all('/anyRoute', function(req, res, next) { instanciatedClass.REST(req, res, next); }); Use function.bind() to bind the desired context to the function: App.all('/anyRoute', instanciatedClass.REST.bind(instanciatedClass));

Categories : Node Js

How to insert into and update sql using NodeJS, socket.io, postgres correctly?
Ok. I just solved this. After searched for more information about this, i found that i must use UPDATE user set mobile = '+mobileno+' to make it works. It's all about syntax. Now i can do query statements myself. Thank you.

Categories : Node Js

LiveScript's "require 'mymodule'" is not working in browser
After examining prelude-ls project a bit deeper and with the helps of loganfsmyth, here is the example code and here is the receipt to build a browser version of a module: Run server code: $ lsc server.ls You will see the proper output: this is server script, running with lsc my test function has been called Run client code: $ lsc -c myapp.ls $ lsc -c mymodule.ls $ browserify

Categories : Node Js

Strong loop studio with SQL Server
That null comes from the order by clause in the SQL that StrongLoop creates. If it doesn't get an order, it seems to just use null. https://github.com/strongloop/loopback-connector-mssql/blob/master/lib/mssql.js#L667 You can fix this by using an order in the default scope in your model. http://docs.strongloop.com/display/public/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-Defaultscope

Categories : Node Js

Node.js Oriento driver example with error handling
Here is how. Basically, it does auto connect to the server on the first request. For connection errors you need catch on every request. var Oriento = require('oriento'); var server = Oriento({ host: 'localhost', port: 2424, username: 'root', password: 'BDFE8AC356595663AF66ADF08E703DE30DF5755F99DE9D329EFF75A5CB8A9CE8' }); server .list() .then(function (dbs) { cons

Categories : Node Js

NodeJS NPM Proxy error
You need to configure the npm config file, this can be done in the terminal: npm config set proxy http://proxy.company.com:8080 npm config set https-proxy http://proxy.company.com:8080 Your error log suggests to see 'npm help config', so i think the problem comes from there. If you want a link with more explanation see this blog entry (there are plenty more) Good luck!

Categories : Node Js

Creating a client which can interact with asterisk manager using node.js
It's too difficult to get a nodejs compatible client, probably you will have to build a complete module which is compatible with nodejs. My requirement was also the same, I would suggest instead of looking for any nodejs module use sipml5 client with asterisk. The audio part can be handled with sipml5 and other features can be built with nodejs. Thanks

Categories : Node Js

How to extract complete URL without HTTP in Node.js?
just calculate protocol length and drop it: var u = 'http://static01.nyt.com/images/2014/11/17/business/billboardjump/billboardjump-master675.jpg'; var protocol = url.parse(u).protocol; console.log(u.slice((protocol + '//').length));

Categories : Node Js

Sort by a array element (document) field - MongoDB/Mongoose
Assuming the variable objectId holds the ObjectId of the referred Job, you can aggregate the records to get the records sorted by the score of that particular Job. Since the stage operator $project does not support the $elemeMatch operation, we cannot use it to directly get the Job sub document that we want and sort based on it. $project a separate field named temp_score to have a copy of the o

Categories : Node Js

How to get parameter for delete request in express node js
Your question is a bit unclear, but I think you're asking how/whether an HTTP request with a DELETE method can have parameters like any other request. If so, yes, it can, and in all the same ways other requests can. The most general way to get request parameters is using the param(<name>) method on the request object, but there are several others depending upon exactly how the request is f

Categories : Node Js

Express works without app.listen or servers
Your error is saying that you're already using port 3000 on your computer, so you can't run this server. What you should do is look for other processes running, and kill them, then re-try. For instance, if you're on Mac, you open the activity monitor, look for node apps, and kill them. This will fix your issue! UPDATE: Look at your package.json if you want to see what the npm start script is do

Categories : Node Js

Node.js: Getting code to run client side
What you're doing here is just running code on your Node.js server. If you want to run code on a client, you need to get the client's browser to download some JavaScript code to run in the browser (just like any other web-based JavaScript code). However, the JavaScript security model expressly prohibits JavaScript code from doing the kind of thing you have in mind (i.e., view or kill processes).

Categories : Node Js

Storing SSH login credentials?
The best way to encrypt data that is extremely sensitive like that, is to use AES 256. You'll basically want to AES256 encrypt the login credentials in some sort of file (like a CSV), and make sure the encrypt key is stored somewhere extremely safe (on a computer not connected to the internet, for instance). This is really the only way to handle that sort of information.

Categories : Node Js

Rendering data from node in jade
Your code is correct -- I suspect the issue might be your template inheritance -- are you sure the layout.jade file you're extending has a block called content available?

Categories : Node Js

Opening a google drive file using the google drive api while I'm NOT signed in to google drive
The API will allow you to do several actions in your drive account. I haven't been able to reproduce the behavior you mention with files that I haven't granted permissions to another account. When you authenticate through the OAuth process, you will grant access to your account only to the application which created the OAuth request. You can not edit the content of a file without manually openin

Categories : Node Js

Reverse proxy and Socket.io, failed websocket handshake (bounty)
I'll expand a bit on my comments. As far as I understand, you have several options : bypass the reverse proxy after the connection (ugly hack if you ask me) : http://www.guyellisrocks.com/2014/06/using-websockets-when-your-reverse.html upgrade to a more recent version that support native websockets everse-proxying. See this related serverfault thread and this technet features announcement forc

Categories : Node Js

Cascade deletion on paranoid tables - Sequelize
I found out that the cascade option only sets up the database cascade option. There is no cascade deletion being done by sequelize. But the sequelize team is going to work on cascade for paranoid table in the future. There is an open issue for this: https://github.com/sequelize/sequelize/issues/2586

Categories : Node Js

Problems running the ripple emulator on Visual Studio 2013
It seems something went wrong while installing vs-mda, you can try following to re-install: Close Visual Studio Open cmd npm install -g [path to vs-mda example C:Users[user-name]AppDataRoaming pm ode_modulesvs-mda] npm install -g [path to vs-mda-targets example C:Users[user-name]AppDataRoaming pm ode_modulesvs-mda-targets] OR Go to Tools --> Options --> Tools for Apache Cordova --> Cordova T

Categories : Node Js

should i change my nodejs document root?
Yep! Usually you want to have just one 'top-level' directory that holds all of your code (javascript stuff and your web page stuff). Here's an example project structure: project ├── assets │   ├── css │   │   └── style.css │   ├── images │   └── javascript ├── server.js └── views └── index.html In the example above, project

Categories : Node Js

Executing Mongo Inserts commands in text file using Mongo shell
Instead of use mydatabase, you have to prepend db = db.getSiblingDB('<db>'); and the inserts should look like db.mycollection.insert({....}); After this, you can do mongo your.mongo.host yourInsertFile.js In case you don't have a syntax error, it should do all the inserts. See the docs about scripting the mongo shell for details.

Categories : Node Js

Protractor config onPrepare method makes asynchronous call. How can do I block test starting?
You are going to need q to return a promise. Here is an example: https://github.com/angular/protractor/blob/953faf7ebee345f686bfedff61ebcb29c5170083/spec/onPreparePromiseConf.js

Categories : Node Js

How to run Mocha tests written in TypeScript?
Found it. The typescript module is actually like a "main" function; it runs the compiler as soon as the module is loaded. Not very nice design. I poked at Mocha's acceptance tests, which show how to use a custom compiler for foo files. They wire it up via the require.extensions mechanism. I was halfway through writing a module that just calls tsc on the command line when I realized that somebody

Categories : Node Js

Using imagemin to compress images and store in mongodb
This might not be the answer you want -- but you probably don't want to store images in MongoDB. Database systems are not really meant to handle the storage of large, binary files like images. This is because storing images is going to eat up both a lot of diskspace, as well as slow down queries considerably. If you're building a production application, you might instead want to look at storing y

Categories : Node Js

NPM Install Error: Fetch Failed
You're having networking issues on your computer. The ENOTFOUND message is an indicator that your networking might be having issues right now. I'd wait a while and re-try. You should be good to go =)

Categories : Node Js

Issue in inserting multiple documents (Bulk Insert) into a mongoDB collection using monk in Node.JS?
In your question you say realationDoc is an array which I presume looks something like this: realationDoc = [{ id: 1, relation: 2 },{ id: 2, relation: 1 }]; In monk, the insert function is not capable of the MonogoDB 2.4 built-in function Bulk Insert. See http://docs.mongodb.org/manual/reference/method/Bulk.insert/ With your code the way it is, you are creating a collection of a singl

Categories : Node Js

Nodejs express interchangeable session stores
I don't think there's a way to "un-use" a mounted middleware after the app has started, but what you could do is write your own session store (a pretty simple api to follow) that handles switching between the two (or more) stores.

Categories : Node Js

Nodejs/Socketio level of SSL certificate required
Securing a websocket is no different to securing an HTTP connection. A TLS handshake process will happen first to establish a secure connection and then an HTTP connection will be established over this secure link. For a websocket the additional step of upgrading the HTTP session to a socket will be taken. What this means is that whatever works for HTTPS will work for WSS. This link has a useful d

Categories : Node Js

Callback routes with expressjs
You should apply routes for your application, for example var routes = { list: function (req, res, next) { res.sendFile(path.join(__dirname, './public', 'index.html')); } }; // app.get('/list', routes.list); router.get('/list', routes.list); // apply the routes to our application app.use('/', router); app.listen(3000);

Categories : Node Js

NodeJS 100% cpu usage - epoll_wait
Seems like Node JS v0.10.25 bug with event loop, look here. Note, from this github pull request: If the same file description is open in two different processes, then closing the file descriptor is not sufficient to deregister it from the epoll instance (as described in epoll(7)), resulting in spurious events that cause the event loop to spin repeatedly. So always explicitly deregiste

Categories : Node Js

Point multiple TLDs to one node server
Well, first I'll say this can lead to some issues from the user experience perspective unless you're really diligent about branding each site. You're almost always going to be better off maintaining them as separate Node apps as well. That said, it's certainly possible with mod_proxy to set up a reverse proxy pointing to your running node app. Check the docs on how to setup proxy-specific hea

Categories : Node Js

how can manage hangup event in node js?
i find it :) when user hangs up call , client go to StatisEnd , we can write function for this state, and call it. client.on('StasisEnd', [function name for example hangup]); function hangup(){ //code }

Categories : Node Js

node dotenv is not working
i didn't put my environment variables in the right format as was in the dotenv module documentation e.g. i was doing export TWILIO_CALLER_ID="+wwehehe" and so the dotenv module wasn't parsing my file correctly. When i noticed that i removed the export keyword from the declarations and everything worked fine.

Categories : Node Js

what is the difference of production gear and base gear on openshift?
All production gears can be deployed to both the US and Europe hosting regions, while the basic small gear can only be deployed in the US hosting region. Also, all production gears have higher CPU performance than the basic small gear. To change gear sizes, scaling, and/or deployment region you can use rhc app create to clone your existing application. The command below will create a complete cop

Categories : Node Js

AWS Elastic Beanstalk NodeJS and logs
In order to see the logs you can: Press on your elastic beanstalk environment Press 'Logs' (on the left side) Press 'Request Logs' (usually just last 100 lines should be fine) and download the file. You can see a few different log files there. I believe that logs you write using log4js in Node.js will be under: /var/log/nodejs/nodejs.log I like to ssh into the elastic beanstalk instan

Categories : Node Js

Accessing a server from node.js
You need to omit the second argument to the listen method to allow access on any IP: }).listen(8000); see the documentation for more details

Categories : Node Js

Grunt + Node app + livereload
Please look at following example to add files information to be watched: grunt.initConfig({ watch: { /*example Watches files for changes in JS, scss and gruntfile*/ js: { files: ['<%= yeoman.app %>/<%= yeoman.scripts %>/**/*.js'], tasks: ['newer:jshint:all'], options: { livereload: true } }, compas

Categories : Node Js

Mongodb tailable cursor, high cpu usage - nodejs + mongodb
A CPU usage of 10% is nothing. Really. Used resources are good resources since they are actually used for something more useful than idling around. Until a certain threshold, of course. When you reduce the interval in which the tailable cursor is checked, as you did, of course the CPU is used less. It really depends on how your use case looks like. If you can live with the fact that there is a ce

Categories : Node Js

Error connecting to mongodb on Cloud 9
It looks to me like you have done a lot of things criss cross without really understanding what you are doing. But basic understanding is necessary. So, here is a step by step guide to sanitize the environment and hopefully repair the database, annotated. You do have a backup, don't you? Decide wether you want to use mongod as your own user vamsiampolu1 or root or a dedicated user. Contrary to

Categories : Node Js

Unknown error running phantomjs in Ubuntu 14.04
It turns out that ubuntu download different files when I run npm install. So in my computer (OSX) it runs fine while on ubuntu, it crashes. To resolve it, I run npm remove then npm install again.

Categories : Node Js




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.