Search Results

Search found 5157 results on 207 pages for 'node'.

Page 7/207 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Getting-started: Setup Database for Node.js

    - by Emile Petrone
    I am new to node.js but am excited to try it out. I am using Express as a web framework, and Jade as a template engine. Both were easy to get setup following this tutorial from Node Camp. However the one problem I am finding is I can't find a simple tutorial for getting a DB set up. I am trying to build a basic chat application (store session and message). Does anyone know of a good tutorial? This other SO post talks about dbs to use- but as this is very different from the Django/MySQL world I've been in, I want to make sure I understand what is going on. Thanks!

    Read the article

  • JQuery XML option node

    - by JD
    hi, I am having an issue with parsing XML with JQuery when there is a node with an option node <preferences><dashboard> <report id="si_pg_vw" order="0"> <header> <data> <option type="reportname" value="Page View"/> </data> </header> </report> the following code in firebug returns no children $reportElement.find("data")[0] however if I change option to any other value ("option2", "test" etc) then the line above returns one child which is correct. Am I mising something or is there a bug? Thanks John

    Read the article

  • node.js with SQL Server Native Client 11 scope_identity not being returned

    - by binderbound
    I'm having trouble with inserting a value into a database through node.js. Here is the offending code: sql.query(conn_str ,"INSERT INTO Login(email, hash, salt, firstName, lastName) VALUES(?, ?, ?, ?, ?); SELECT SCOPE_IDENTITY() AS 'Identity';" , [email, hash, salt, firstName, lastName], function(err, results){ console.log(results) } Unfortunately, the console is just echoing [], meaning results is an empty array, I suppose. Does anyone know why the identity is not being returned? Even if it was null, why isn't results then [{Identity: null }] ? Database is on Azure, which does have a "Scope_Identity" function, and the native client also recognises this function. Using node package "msnodesql" Please Help

    Read the article

  • Organize routes in Node.js

    - by NilColor
    Hello! I start to look at Node.js. Aslo I'm using Express. And I have a question - how can I organize web application routes? All examples just put all this app.get/post/put() handlers in app.js and it works just fine. This is good but if I have something more than simple HW Blog? Is it possible to do something like this: var app = express.createServer(); app.get( '/module-a/*', require('./module-a').urls ); app.get( '/module-b/*', require('./module-b').urls ); and // file: module-a.js urls.get('/:id', function(req, res){...}); // <- assuming this is handler for /module-a/1 In other words - I'd like something like Django's URLConf but in Node.js.

    Read the article

  • Best way to use Cradle with Express.js (CouchDB, Node.js)

    - by Costa
    I'm building my website ( http://tedxgramercy.jit.su ) with express.js and so far I've been using the http.request method in node to access couch, and that's been cool. I've learned lots about how http, couch, and node work, which is awesome. Anyways, I'm thinking of moving over to cradle now (Let me know if you have a strong opinion about this) and I'd like to know the "right" way to set this up. Should I... require() cradle and make a new connection to my db in each separate route? create my database connection once, and then just pass that connection by require()ing the connection in each route? (if so, how do I do that?) Thanks!!!

    Read the article

  • Digester: Extracting node name

    - by CaptainHastings
    Hi Guys, Is it possible to extract the node name using apache digester? So, if the xml looks like <furniture> <sofa> ..... </sofa> <coffeeTable> ..... </coffeeTable> </furniture> is it possible to extract the node name "sofa", "coffeeTable"? I know it is possible using xpath but is it possible using digester? Cheers

    Read the article

  • Understanding Node.js and concept of non-blocking I/O

    - by Saif Bechan
    Recently I became interested in using Node.js to tackle some of the parts of my web-application. I love the part that its full JavaScript and its very light weight so no use anymore to call an JavaScript-PHP call but a lighter JavaScript-JavaScript call. I however do not understand all the concepts explained. Basic concepts Now in the presentation for Node.js Ryan Dahl talks about non-blocking IO and why this is the way we need to create our programs. I can understand the theoretical concept. You just don't wait for a response, you go ahead and do other things. You make a callback for the response, and when the response arrives millions of clock-cycles later, you can fire that. If you have not already I recommend to watch this presentation. It is very easy to follow and pretty detailed. There are some nice concepts explained on how to write your code in a good manner. There are also some examples given and I am going to work with the basic example given. Examples The way we do thing now: puts("Enter your name: "); var name = gets(); puts("Name: " + name); Now the problem with this is that the code is halted at line 1. It blocks your code. The way we need to do things according to node puts("Enter your name: "); gets(function (name) { puts("Name: " + name); }); Now with this your program does not halt, because the input is a function within the output. So the programs continues to work without halting. Questions Now the basic question I have is how does this work in real-life situations. I am talking here for the use in web-applications. The application I am writing does I/O, bit is still does it in am blocking matter. I think that most of the time, if not all, you need to block, because you have to wait on what the response is you have to work with. When you need to get some information from the database, most of the time this data needs to be verified before you can further with the code. Example 1 If you take a login for example. You have to wait for the database to response to return, because you can not do anything else. I can't see a way around this without blocking. Example 2 Going back to the basic example. The use just request something from a database which does not need any verification. You still have to block because you don't have anything to do more. I can not come up with a single example where you want to do other things while you wait for the response to return. Possible answers I have read that this frees up recourses. When you program like this it takes less CPU or memory usage. So this non-blocking IO is ONLY meant to free up recourses and does not have any other practical use. Not that this is not a huge plus, freeing up recourses is always good. Yet I fail to see this as a good solution. because in both of the above examples, the program has to wait for the response of the user. Whether this is inside a function, or just inline, in my opinion there is a program that wait for input. Resources I looked at I have looked at some recourses before I posted this question. They talk a lot about the theoretical concept, which is quite clear. Yet i fail to see some real-life examples where this is makes a huge difference. Stackoverflow: What is in simple words blocking IO and non-blocking IO? Blocking IO vs non-blocking IO; looking for good articles tidy code for asynchronous IO Other recources: Wikipedia: Asynchronous I/O Introduction to non-blocking I/O The C10K problem

    Read the article

  • Node.js + express.js + passport.js : stay authenticated between server restart

    - by Arnaud Rinquin
    I use passport.js to handle auth on my nodejs + express.js application. I setup a LocalStrategy to take users from mongodb My problems is that users have to re-authenticate when I restart my node server. This is a problem as I am actively developing it and don't wan't to login at every restart... (+ I use node supervisor) Here is my app setup : app.configure(function(){ app.use('/static', express.static(__dirname + '/static')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieParser()); app.use(express.session({secret:'something'})); app.use(passport.initialize()); app.use(passport.session()); app.use(app.router); }); And session serializing setup : passport.serializeUser(function(user, done) { done(null, user.email); }); passport.deserializeUser(function(email, done) { User.findOne({email:email}, function(err, user) { done(err, user); }); }); I tried the solution given on this blog using connect-mongodb without success app.use(express.session({ secret:'something else', cookie: {maxAge: 60000 * 60 * 24 * 30}, // 30 days store: MongoDBStore({ db: mongoose.connection.db }) }));

    Read the article

  • Java SAX ContentHandler to create new objects for every root node

    - by behrk2
    Hello everyone, I am using SAX to parse some XML. Let's say I have the following XML document: <queue> <element A> 1 </element A> <element B> 2 </element B> </queue> <queue> <element A> 1 </element A> <element B> 2 </element B> </queue> <queue> <element A> 1 </element A> <element B> 2 </element B> </queue> And I also have an Elements class: public static Elements { String element; public Elements() { } public void setElement(String element){ this.element = element; } public String getElement(){ return element; } } I am looking to write a ContentHandler that follows the following algorithm: Vector v; for every <queue> root node { Element element = new Element(); for every <element> child node{ element.setElement(value of current element); } v.addElement(element); } So, I want to create a bunch of Element objects and add each to a vector...with each Element object containing its own String values (from the child nodes found within the root nodes. I know how to parse out the elements and all of those details, but can someone show me a sample of how to structure my ContentHandler to allow for the above algorithm? Thanks!

    Read the article

  • Node.js fetching Twitter Streaming API - EADDRNOTAVAIL

    - by Jordan Scales
    I have the following code written in node.js to access to the Twitter Streaming API. If I curl the URL below, it works. However, I cannot get it to work with my code. var https = require('https'); https.request('https://USERNAME:[email protected]/1.1/statuses/sample.json', function(res) { res.on('data', function(chunk) { var d = JSON.parse(chunk); console.log(d); }); }); But I receive the following node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: connect EADDRNOTAVAIL at errnoException (net.js:642:11) at connect (net.js:525:18) at Socket.connect (net.js:589:5) at Object.<anonymous> (net.js:77:12) at new ClientRequest (http.js:1073:25) at Object.request (https.js:80:10) at Object.<anonymous> (/Users/jordan/Projects/twitter-stream/app.js:3:7) at Module._compile (module.js:441:26) at Object..js (module.js:459:10) at Module.load (module.js:348:31) If anyone can offer an alternative solution, or explain to me why this doesn't work, I would be very grateful.

    Read the article

  • Using Pastebin API in Node.js

    - by wiill
    I've been trying to post a paste to Pastebin in Node.js, but it appears that I'm doing it wrong. I'm getting a Bad API request, invalid api_option, however I'm clearly setting the api_option to paste like the documentation asks for. var http = require('http'); var qs = require('qs'); var query = qs.stringify({ api_option: 'paste', api_dev_key: 'xxxxxxxxxxxx', api_paste_code: 'Awesome paste content', api_paste_name: 'Awesome paste name', api_paste_private: 1, api_paste_expire_date: '1D' }); var req = http.request({ host: 'pastebin.com', port: 80, path: '/api/api_post.php', method: 'POST', headers: { 'Content-Type': 'multipart/form-data', 'Content-Length': query.length } }, function(res) { var data = ''; res.on('data', function(chunk) { data += chunk; }); res.on('end', function() { console.log(data); }); }); req.write(query); req.end(); console.log(query) confirms that the string is well encoded and that api_option is there and set to paste. Now, I've been searching forever on possible causes. I also tried setting the encoding on the write req.write(query, 'utf8') because the Pastebin API mentions that the POST must be UTF-8 encoded. I rewrote the thing over and over and re-consulted the Node HTTP documentation many times. I'm pretty sure I completely missed something here, because I don't see how this could fail. Does anyone have an idea of what I have done wrong?

    Read the article

  • problems piping in node.js

    - by alvaizq
    We have the following example in node.js var http = require('http'); http.createServer(function(request, response) { var proxy = http.createClient(8083, '127.0.0.1') var proxy_request = proxy.request(request.method, request.url, request.headers); proxy_request.on('response', function (proxy_response) { proxy_response.pipe(response); response.writeHead(proxy_response.statusCode, proxy_response.headers); }); setTimeout(function(){ request.pipe(proxy_request); },3000); }).listen(8081, '127.0.0.1'); The example listen to a request in 127.0.0.1:8081 and sends it to a dummy server (always return 200 OK status code) in 127.0.0.1:8083. The problem is in the pipe among the input stream (readable) and output stream (writable) when we have a async module before (in this case the setTimeOut timing). The pipe doesn't work and nothing is sent to dummy server in 8083 port. Maybe, when we have a async call (in this case the setTimeOut) before the pipe call, the inputstream change to a state "not readable", and after the async call the pipe doesn't send anything. This is just an example...we test it with more async modules from node.js community with the same result (ldapjs, etc)... We try to fix it with: - request.readable =true; //before pipe call - request.pipe(proxy_request, {end : false}); with the same result (the pipe doesn't work). Can anybody help us? Many thanks in advanced and best regards,

    Read the article

  • Node.js appears to be missing the multipart module

    - by Brenton Alker
    I am trying to parse form data, including upload files with a node.js http server. All of the tutorial type articles I have found use a require("multipart"); to include the multipart module, but when I try the same I get: Error: Cannot find module 'multipart' I also can't find it in the current api docs (though it is in the google cached version). So, has this module been removed from the standard installation or is there something else that does the job?

    Read the article

  • drupal module alter view or node

    - by bert
    I have been using hook_alter to modify forms in a custom PHP module. I started to take the same approach modifying the result page of "node add" form. However this page is not a form so I don't have a form ID to hook on to. Actually it contains a login form, but that does not contain the elements that I am looking for, What approach should I use in this situation?

    Read the article

  • Form data sent to Node via Post is undefined

    - by user185812
    I know this has been asked countless times on here, however I tried all the solutions and am still having the issue. Most people say to set the content-type (which I did) and to name the inputs that I wish to Post to node. I have done both of these things, yet still get "undefined" when trying to send data from an HTML form to node. JADE Templating HTML Code (Sorry I can't seem to get the indenting to show up here, however I think I should leave the code intact when posting here instead of converting it to normal HTML so that if the error is in here, you are still able to help) Form(action="/registration", method="post", enctype="application/x-www-form-urlencoded") div(class="control-group-Username") label(class="control-group", for="username") Username: div.controls input#Username(id="Username", type="text", placeholder="Username Here", maxlength="23", name="username") //Other divs and stuff here button.btn#submit_button(type="submit") Submit app.js code /** * Module dependencies. */ express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = require('http') , path = require('path'); app = express(); // all environments app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('view engine','jade'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieParser('your secret here')); app.use(express.session()); app.use(app.router); app.use(require('less-middleware')({ src: __dirname + '/public' })); app.use(express.static(path.join(__dirname, 'public'))); // development only if ('development' == app.get('env')) { app.use(express.errorHandler()); } app.use(express.static(__dirname + '/public')); app.get('/', routes.index); app.get('/users', user.list); app.get('/register', routes.register); http.createServer(app).listen(app.get('port'), function(){ console.log('Express server listening on port ' + app.get('port')); }); require('./Register.js'); register.js code app.post('/registration', function(req, res) { var Email=req.body.username console.log(username); });

    Read the article

  • Clientside going serverside with node.js

    - by Sveisvei
    Hello, I`ve been looking for a serverside language for some time, and python got my attention somewhat. But as I already know and love javascript, I now want learn to code on the server with js and node.js. Now, what books and what subjects do I need to learn to understand the serverside world better? (let me know if Im to vague)

    Read the article

  • node.js express app won't start (or debug) in Eclipse (Nodeclipse)

    - by Ultra
    When I do on my app.js Debug As > Node Application it says Launching STANDALONE_V8 has encountered a problem. Failed to connect to Standalone V8 VM connect timed out It should start an app. Doing so directly on my terminal works fine. When I start a debug session in my terminal and than try to debug it in Eclipse works fine too. So is there anything that has to be done in order to make it work in Eclipse?

    Read the article

  • In node.js slow readable stream attached to a faster pushing message queue eats up memory

    - by Vishal
    In my node.js program I have a response stream attached to a message queue (zeromq) delivering data at a very high rate. Due to slow network connection the response stream and its underlying implementation is unable to consume data at that pace thus occupying a lot of memory. Do you have any suggestion to solve this problem. For reference please see the code snippet below: zmq.on("message", function(data) { res.write(data); // End response on some event });

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >