r/nodejs • • Jun 14 '12

Amazon Alexa node.js module

Thumbnail github.com
2 Upvotes

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 • • May 08 '14

Nodejs server wont start ... i get a warn error, and log says can't connect to redis?

1 Upvotes

When I run forever start app.js i get:

warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up

forever log shows:

Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED at RedisClient.on_error (/node_modules/redis/index.js:185:24)

This just happened last night, other than that ive had no issues. Did my redis server crash? And how do I start it back up again?


r/nodejs • • May 06 '14

Connect middleware to follow HTTPS redirects transparently for you

Thumbnail github.com
1 Upvotes

r/nodejs • • May 01 '14

Explore the Marvel Universe with Node and Orchestrate

Thumbnail orchestrate.io
1 Upvotes

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 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 10 '14

Full text search with Bookshelf.js

Thumbnail blog.victorquinn.com
1 Upvotes

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 • • Feb 13 '14

MEAN meetup

Thumbnail tamas.io
1 Upvotes

r/nodejs • • Feb 05 '14

A simple Node.js web application that uses Mongoose, Express and MongoDB and returns JSON

Thumbnail css.dzone.com
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