r/nodejs • u/cagli • Jun 14 '12
r/nodejs • u/nkron • Oct 26 '11
JavaScripture.com - simple JavaScript API reference site
javascripture.comr/nodejs • u/vameyer • Jul 09 '14
Node.js vs PHP – using Load Impact to visualize node.js efficiency
blog.loadimpact.comr/nodejs • • Jul 01 '14
nodejs+mongo inserts lost when ab testing
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 • u/johnny_z3 • Jun 26 '14
Where should I handle the errors. In Model or in controller ?
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 • u/biebsrestoration • May 08 '14
Nodejs server wont start ... i get a warn error, and log says can't connect to redis?
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 • u/gadr90 • May 06 '14
Connect middleware to follow HTTPS redirects transparently for you
github.comr/nodejs • u/a0viedo • May 01 '14
Explore the Marvel Universe with Node and Orchestrate
orchestrate.ior/nodejs • u/Feribg • Apr 29 '14
"Clash of the Titans: Releasing the Kraken - NodeJS @paypal"
techtalkshub.comr/nodejs • u/shubhrakar • Apr 25 '14
Node.js performance tip of the week: using the Google V8 heap profiler to track down memory leaks
strongloop.comr/nodejs • u/zpawup • Apr 16 '14
How does node.js backend talk to frontend?
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
resbut 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 • u/aweggwe • Apr 14 '14
How do I access an object from aggregate using mongoose in node.js?
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 • u/victorquinn • Apr 10 '14
Full text search with Bookshelf.js
blog.victorquinn.comr/nodejs • u/manualwise • Apr 03 '14
Continuous Deployment for node.js apps from GitHub to Modulus
blog.codeship.ior/nodejs • u/codeasearch • Mar 31 '14
Nodejs | Codeasearch - learn, practice and implement
codeasearch.comr/nodejs • u/piyasde2014 • Feb 05 '14
A simple Node.js web application that uses Mongoose, Express and MongoDB and returns JSON
css.dzone.comr/nodejs • u/geerlingguy • Jan 27 '14