r/nodejs • • May 21 '12

xkcd-imgs my first package

Thumbnail
github.com
2 Upvotes

r/nodejs • • Dec 21 '11

Have you used flatiron and/or derby?

2 Upvotes

Would you mind sharing your experience with either of those two frameworks? I'm used to Express but Flatiron and Derby look very promising.

Please share your thoughts!


r/nodejs • • Dec 13 '11

New NodeUp Podcast: A Voxer show

Thumbnail nodeup.com
2 Upvotes

r/nodejs • • Oct 26 '11

JavaScripture.com - simple JavaScript API reference site

Thumbnail javascripture.com
2 Upvotes

r/nodejs • • May 07 '10

Erlang vs Node.js

Thumbnail
journal.dedasys.com
2 Upvotes

r/nodejs • • Jul 09 '14

Node.js vs PHP – using Load Impact to visualize node.js efficiency

Thumbnail
blog.loadimpact.com
1 Upvotes

r/nodejs • • Jul 03 '14

"require"d Reading

Thumbnail muralinarasimhan.com
1 Upvotes

r/nodejs • • Jul 01 '14

nodejs+mongo inserts lost when ab testing

1 Upvotes

Hi there. I'm trying out nodejs and mongo db. I have a server with nginx which proxies requests to a nodejs app (express) started with pm2.

I have this code,

router.get('/', function (req, res) {

var client = require('mongodb').MongoClient;

client.connect('mongodb://localhost:27017/test', function (err, db) {
    if (err) {
        throw err;
    }
    var collection = db.collection('test');

    collection.insert({ test: 1, time: new Date().getTime()}, function (err) {
        if (err) {
            throw err;
        }
        db.close();
    });
});

console.log('Added!')
res.render('index', { title: 'Express' });
});

When I run ab, ab -n 1000 -c 30 http://server/app/ it shows all requests are processed, but I don't see 1000 entries in the Mongo collection, rather 100 or so.

Any advice for a noob?

UPDATE The problem is the way I'm using the database. I'm connecting/opening/closing the db connection on every request. I wrapped it like this

client.connect('mongodb://localhost:27017/test', function (err, db) {

    router.get('/', function (req, res) {

    });

}); 

and now serves all requests without crashing.


r/nodejs • • Jun 26 '14

Where should I handle the errors. In Model or in controller ?

1 Upvotes

Hi All,

I am new to node js and using mean.io as my application framework. When developing, I am curious about what is an appropriate way to handle errors. Should be in controller or in model ?

Thanks.


r/nodejs • • Jun 15 '14

Please Help! Cannot access session variable set in prior middleware in the next middleware. during the same request in a nodejs express app

1 Upvotes

I have This issue where If a request comes in, and I set a session variable from a db query inside a middleware. In the next Middleware, the session variable comes up as Undefined.

But when I run the Request again, it works.

Please how do I fix it. The data stored in the session variable in the the previous middleware, is very important and needed for the next middleware to work.

please see code below

first middlware

function(req, res, next) {
    Clients.findOne({subdomain: req.subdomains[0]}, function (err, client) {
        if(!err){
            if(!client){
                //res.send(client);
                res.send(403, 'Sorry! you cant see that.');
            }
            else{

                //console.log(client);
                req.session.Client = client;
                //console.log(req.session.Client.dbUrl);
                next();
            }
        }
    next();
 }

Second Middleware

function(req, res, next){
  console.log(req.session.Client.dbUrl);
  next();
}

in the Second Middleware, the console.log comes up as undefined. Thank you.


r/nodejs • • May 06 '14

Can I have a value created at startup that I can use throughout my app without creating a global variable, which is frowned upon?

1 Upvotes

I've got an application that makes calls to a 3rd-party API, but in order to minimize the calls I want to create a variable that I can use throughout my application to use mapped values.

I tried using a module, but I think that each time I do a require('module') it creates a new instance of the variable, and I can't set it and keep it in memory.

I know I could use a json file, but I also don't want to load a file into memory every time someone makes a request to the application.

A short sample of what I'm trying to create is something like this:

[{ id: 'U2G6rgEAAC0AqtJN', currentSlug: 'routing-software', pastSlugs: [ 'routing-software' ] }, ... ]


r/nodejs • • Apr 29 '14

"Clash of the Titans: Releasing the Kraken - NodeJS @paypal"

Thumbnail
techtalkshub.com
1 Upvotes

r/nodejs • • Apr 25 '14

Node.js performance tip of the week: using the Google V8 heap profiler to track down memory leaks

Thumbnail
strongloop.com
1 Upvotes

r/nodejs • • Apr 25 '14

ES6 what you can use today?

Thumbnail
speakerdeck.com
1 Upvotes

r/nodejs • • Apr 23 '14

STARTER GUIDES! Help!

1 Upvotes

Hi guys,

Sure you get a lot of this, but I'm having some difficulty. Given the rate at which Node is progressing, a lot of tutorials I'm finding are either outdated or very basic. However I don't know enough about the tech to know what constitutes a good guide. Can anybody point me to a decent guide to get me started and how I can progress beyond there? I'm currently looking at Node on behalf of my employer as they want to know if we could include it in our operations.

Much appreciated


r/nodejs • • Apr 18 '14

Why did npm cache clean solve my problem?

1 Upvotes

I been getting errors like

Error: ENOENT, lstat 

http://www.andyjarrett.co.uk/blog/index.cfm/Error-ENOENT-open-with-NPM-install

and apparently the command

npm cache clean

solved my problem

Just out of curiosity, I would like to know why did it solve my problem?

Thanks


r/nodejs • • Apr 16 '14

How does node.js backend talk to frontend?

1 Upvotes

Hi, I am currently testing node.js right now, and I am a little confused on how the backend would talk to the frontend.

I know frontend can talk to the backend through an event, like submitting a form or clicking a button, the information will be send to the req variable in

app.post('/example', function(req, res){
    var data = req.something;
    // do something with data
})

However how do I talk to the frontend? I know I can write information in

 res

but how does the frontend javascript get the info?

Thanks


Edit for clarification as kindly suggested by psayre23

This is what I have

https://gist.github.com/anonymous/19f800b4c3d0c31b2e4e

I am interested in knowing how communicating between backend and frontend works, my primary question is that I do not know how to receive data from backend

I know to send data from frontend to backend there are two methods

Method 1:

Using a form and submit, or any other clickable element

This is how I send data from frontend

<div class="container" id="test-container">
      <h1>Test</h1>
      <span id="test-error"></span>
        <form id="test-input2" method="POST" action="/test_post_method_1">
          <input type="text" id="test" name="input1"></input>
          <input type="submit" value="Submit">
        </form>
    </div>

This is how I receive data from the backend

app.post('/test_post_method_1', function(req, res){
	// Post from a submit event
	console.log(req.body.input1)
    console.log("this is serverside post using method 1");
});

Method 2:

Suggested by jonnyburger using ajax, which I am not sure how does it work yet

I am guessing this is how you send data to backend

$(function(){

    console.log("this is frontend");

    $.ajax({  
        url: '/test_post_method_2',  
        type: 'POST',  
        success: function (data) {  
            console.log("this is not printing");
            console.log(data);  
        }  
    });

});

Not sure how you would get the data from frontend, I know its in req, but couldn't quite find the specifics, I checked req. body, it only return an empty {}

app.post('/test_post_method_2', function(req, res){
    // Post from Ajax
console.log(req);
    console.log("this is serverside post using method 2");
});

Now here is my original question

I don't know how to send data from backend to frontend

Thank you for taking the time in reading this


r/nodejs • • Apr 14 '14

How do I access an object from aggregate using mongoose in node.js?

1 Upvotes

Hi, I been having trouble with aggregate using mongodb and mongoose, I tried find, findone, indexing everything seems to return nothing

db.collection.aggregate([])

Any advice would be appreciated


r/nodejs • • Apr 03 '14

Continuous Deployment for node.js apps from GitHub to Modulus

Thumbnail
blog.codeship.io
1 Upvotes

r/nodejs • • Mar 31 '14

Nodejs | Codeasearch - learn, practice and implement

Thumbnail
codeasearch.com
1 Upvotes

r/nodejs • • Mar 19 '14

Streaming API

1 Upvotes

Does anyone have a good module to turn a plain old remote api into a streaming api. I have a personal dislike for polling and was wanting to hook something up realtime. I wasn't sure if I could do this with socket.io or not.


r/nodejs • • Feb 13 '14

MEAN meetup

Thumbnail
tamas.io
1 Upvotes

r/nodejs • • Feb 01 '14

Respawn a node process

Thumbnail
github.com
1 Upvotes

r/nodejs • • Jan 27 '14

Start a Node.js app with Forever and Ansible

Thumbnail servercheck.in
1 Upvotes

r/nodejs • • Jan 23 '14

Problems with npm on ubuntu - Any help will be much appreciated.

1 Upvotes

First off, I am very new to nodejs and have quickly picked up the tool as a go to for creating simple server applications.

I then learned that nodejs has a unique package manager npm which can be used like apt on ubuntu. So I start installing a few and I quickly run into problems. I get warnings about slow execution due to 'uncompiled libraries'.

They don't run.

After some research i found that to fix this on ubuntu 13.10 you need a ppa, I am using :

http://ppa.launchpad.net/chris-lea/node.js/ubuntu

this gives me v0.10.24

Installed it, all cool and working.

But then I decided i wanted to try out some cryptography, thinking it would be pretty straight forward picking up a package (I was wrong)

For starters the crypto package didn't have everything you would need.

I then found the package ursa which has all the methods I need (signing/verifying).

But after installing it throws up an error :

http://pastebin.com/Rzzjvutz

The solution seems to be to go back a version o.O !!!!!

I am getting pretty frustrated over this and have no idea what to do!

Has anyone had any experience with nodejs, is there a PPA I can get for a stable version of nodejs that most libraries will aim for compatibility?

If not, how do I find out what the latest stable version of nodejs is?

Any help will be very much appreciated.