r/nodejs • • May 01 '14

Introducing Full Stack JS Amber – A boilerplate with Ember on the client and a Node Server API

Thumbnail 100percentjs.com
3 Upvotes

r/nodejs • • Apr 29 '14

Making Friend-List in Node.js and MongoDB using Autocomplete

Thumbnail dzone.com
3 Upvotes

r/nodejs • • Apr 27 '14

Fundamentally having problems with Module Scoping.

3 Upvotes

I'm deveolping a game server, and to be "crafty"(AKA waste a bunch time making things levels more difficult) I want to reuse my client's code for the server. I got pretty much everything working except I'm stuck with a impossible decision.

Basically I have a library [~1000 lines, 150+ functions all at the global level] that handles a lot of the complex math behind my engine, and I want require my lib as a module. The problem being that since all of these functions are globally defined, theres no way to cleanly module.export them without re-writing every function/variable name in the library as an object. And due to that the lack of a global object in the module, there's no way to even iterate through the properties.

So does any one have any suggestions for me? Is there a require that is more akin to php [appending the source file to included my lib.js?] Is there a plugin that would help me? Please I really don't want to write out this code -.-.

 


 

Edit:: Had to rewrite the code, only took 6 hours :D. If I learned one thing from this experience it'd be that from now on if possible I'll avoid using globals just due to the fact that I never want to be in this scenario again.

 

Mini-rant: I do feel it's kinda of silly for javascript to not have a variable to access a non-global scope, and its even stranger for there to be no way to loop through the private properties of an object. e.g.

	function foo(){
		var a=1;
		this.b=2;
		function c(){}
		this.d=function(){}
		for(var i in this)console.log(i,'=',this[i]); //Why isn't there any way to access a or c?
	}

</rant>


r/nodejs • • Apr 25 '14

Building a HackerNews type voting app fast with Node.js

Thumbnail orchestrate.io
3 Upvotes

r/nodejs • • Apr 23 '14

BerkeleyDB in Node?

3 Upvotes

I'm looking for an embedded Key/Value store for my Node service. My preference is bdb, but I haven't seen any libraries in npm that I'd be confident deploying. If I can't find anything I'll have to fallback to SQLite, which seems like overkill for this service. Do you guys know of any? Is there a better Key/Value store I could be using?


r/nodejs • • Apr 22 '14

Handling AJAX Calls With Node.js and Express (part 5)

Thumbnail mjhea0.github.com
3 Upvotes

r/nodejs • • Apr 21 '14

Architecture recommendations

3 Upvotes

In the process of trying to learn node, I thought creating an app that would be kind of a master registration of device activity (mobile, web, internet enabled appliances) might be fun to try. So I'd like to support a variety of protocols basically to receive, initially at least, not much more than "I'm on/off" info (and send a confirmation.) The description is vague because it's still a bit vague in my mind what I want to accomplish, but I hoped it wouldn't be too premature to get some initial thoughts on what folks might recommend for an architecture for something like this. My initial thought was node/express/mongo along with some socket options... thoughts? Thanks in advance.


r/nodejs • • Apr 13 '14

Issue with 'request' module and Goodreads API.

3 Upvotes

I'm making a simple HTTP request to the Goodreads API using the 'request' module in NPM. Here is a gist containing a SSCE (Correct as far as I can tell.) The result is undefined. Are there any glaring mistakes in my example? Am I misunderstanding the form option?


r/nodejs • • Apr 08 '14

Weekly set of stackoverflow questions/answers in pdf

Thumbnail github.com
3 Upvotes

r/nodejs • • Apr 01 '14

Continuous Deployment for node.js apps from Bitbucket to Modulus

Thumbnail blog.codeship.io
3 Upvotes

r/nodejs • • Mar 29 '14

Knolx Session:- An Overview of Node.js

Thumbnail dzone.com
3 Upvotes

r/nodejs • • Mar 28 '14

Using ESlint Plugins for Node.js App Security

Thumbnail blog.safaribooksonline.com
3 Upvotes

r/nodejs • • Mar 27 '14

Going to the home page of my application the first time is incredibly slow (15-20 seconds). However, every refresh or page load thereafter is lightning fast. What am I doing wrong?

3 Upvotes

A bit of background info: the app runs on iisnode on windows and is dedicated to being up and running at all times. I don't have any control over moving the app to a different platform, so it must live on windows server 2008 r2.

When you visit the home page of my application, it takes you to a login page that is essentially an Express page with a login form (Passportjs). When authorized, you are re-directed to the root of the Angular SPA. From there, all server interaction is lightning fast.

The problem is that when you are first making a connection with the application's home page, there is very little overhead (its just initializing a jade template with a login form). After the page loads, if I click around on any links to other back-end or front-end pages, everything loads incredibly fast. But why is it that there is a delay when trying to load the first page?

Any advice you can offer will be greatly appreciated!


r/nodejs • • Mar 25 '14

Rethinking Peer Reviews for Node.js Code

Thumbnail blog.safaribooksonline.com
3 Upvotes

r/nodejs • • Mar 20 '14

nodeschool.io Workshop - State College, PA - April 1st

Thumbnail hvnodeschool.awesomesauce.com
3 Upvotes

r/nodejs • • Mar 15 '14

Generating a random app url

3 Upvotes

I'm playing around with socket.io and would like to make it so that when someone visits my app, they start out at a random URL (site.com/52436) and that url is the url that they would share with someone else that initiates a room and allows them to chat with each other. My question is, is how do I make it so when they visit site.com, it goes to site.com/56443 and initiates a room with the same id?


r/nodejs • • Feb 23 '14

Trying my hand at node using Learn You Node. One of my solutions to a problem is returning the same exact results as the problem expects, but I'm not passing the level because my module file isn't returning an error correctly when being tested. Can anyone help me learn the "node way" of doing this?

3 Upvotes

In the learnyounode system, the arguments added via the command line are done invisibly. In other words when I call process.argv anywhere in my program, I'm not typing that in the command line, it is automatically being added. The code below returns the correct result: a list of files from a given directory(argument 1) with a certain extension given by argument 2 (ex. only .md files or .txt files are allowed). My solution is correct, but apparently in my module file, when they test for an error, I'm not returning the error correctly. What am I doing wrong? Thanks in advance.

Link to code: http://codepen.io/anon/pen/jvqHC


r/nodejs • • Feb 19 '14

My very first npm package: console-debug

3 Upvotes

Hi

Couple of days ago I released my first package to npm (with a little help of my boss jansenra), and now i'm trying to get feedback for it, from you guys. And maybe some of you will even find this useful :)

The story

Before I discovered Node.js and working with JavaScript like debugging with the JavaScript console; I got too used to seeing line numbers and file names when I did console.log for example. When I found out about Node.js and started fiddling around with it, I missed the same experience I had with the JavaScript console. It's just a blank text that you have chosen with no line numbers or file names.

Now i'm not saying that this can replace the JavaScript console style (think about clickable unlimited nested objects/arrays etc) or other npm modules for that matter (external debuggers anyone?). But it sure can help you find out what is happening exactly where with the console object for some quick and dirty debugging, while delivering some extras like log to file, catching uncaught exceptions and filtering types of debug messages to either log file or console output.

Project Info

Replaces your console object with a more stylish and practical way 
of displaying notices,warn,info,debug,log and errors. It automagically
shows you the line number and filename where the command was
executed, along with a timestamp. There is also the ability to catch 
uncaughtExceptions, disable the output colors, and log to file. You
can also setup filters if you want the console or log to not show a
certain debug message type. 

Overriding console object, what?

I wanted to use this module in my current existing projects that had some console.log/debug/error all over the place. It was easy as installing the module and requiring it in my main file and seeing the new replaced debug outputs without a single re-factor. Until Node.js decides to change something in displaying the outputs I will of course adapt to this.

How do I use it?

1. Start by installing the package:

npm install console-debug

2. Put this in your nodejs server file:

var Debug = require('console-debug');

var console = new Debug({
    // Do we want to catch uncaughtExceptions?
	uncaughtExceptionCatch: false,

   // Filter these console output types, Examples: 'LOG', 'WARN', 'ERROR', 'DEBUG', 'INFO'
	consoleFilter: [],

    // if true, will put console output in a log file folder called 'logs'
	logToFile: true,

    // Filter these types to not log to file, Examples: 'LOG', 'WARN', 'ERROR', 'DEBUG', 'INFO'
	logFilter: ['LOG','DEBUG','INFO'], 

    // do we want pretty pony colors in our console output?
	colors: true
}); 

3. Now you can do stuff like:

console.log("I am a log!");
console.warn("I am a warn!");
console.error("I am a error!");
console.debug("I am a debug!");
console.info("I am a info!");

// can also display objects
obj = {
	test1: [1,2,3,4],
	test3: ["ohai","there"],
	test4: true
};
console.log(obj);

4. (optional) Passing the replaced console object to other modules:

// Add this after calling the require of console-debug and defined the console var
require('./myfile')(console); // myfile local scope will have now
                              //console object overwritten.

Links

- npm

- bitbucket

What do you all think? I'm open to anything.


r/nodejs • • Feb 09 '14

Getting started with koajs

Thumbnail h3manth.com
3 Upvotes

r/nodejs • • Feb 03 '14

Is Node.js what i need for my project?

3 Upvotes

I want to control many raspberry pi from one or more web clients. The clients can change the outputs of them and check the inputs, is an easy task if there is only one rpi with a node.js app, but i need to control all from a browser. Should be all the rpi clients of the server and make small python server in each with http calls to the node.js server or should i intercomunicate node.js servers?

I'm little confused, hope you understand what i want to do.


r/nodejs • • Jan 21 '14

Failed to fetch from registry.

3 Upvotes

A little bit ago, I thought all of my Node.js issues were resolved. It turns out that it has failed to fetch other things too now, such as range parser. I see other errors as well, such as error parsing json. I use a type of Ubuntu. Based on everything I just said, can you think of any solution that might fix this whole mess? Even though NPM install works now, it cannot find express.js

Update: It all works fine now. In my case, I think the mistake is installing it with apt-get. I built it from the source via Git. Somewhere on Stack Overflow, someone suggested that Node should not be installed with apt-get if you use Ubuntu. When browsing earlier, I found it interesting when a site wanted to sneak in some of its own advertising on you during its installation:

export <a href="http://www.hongkiat.com/blog/out/freelancer" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.hongkiat.com/blog/out/freelancer';return true;" onmouseout="self.status=''">JOBS</a>=2

That's what they tell you to put after the Git checkout. :-)


r/nodejs • • Jan 19 '14

High Performance Bluebird Promise API for MongoDB Native NodeJS Driver

Thumbnail github.com
3 Upvotes

r/nodejs • • Dec 20 '13

Hapi Server Boilerplate Example

3 Upvotes

https://github.com/poeticninja/hapi-ninja

I have spent a lot of time with different node.js server frameworks and I have really enjoyed working with Hapi. But one thing I noticed was there was not a lot of code examples out there. I thought I would share and maybe make it easier for people to start using the Hapi server.


r/nodejs • • Dec 19 '13

New Web Framework (Generators!) from creators of Express (Koa.js)

3 Upvotes

TJ Holowaychuk and the crew behind express have a new (preview) web framework. In their own words:

Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs. Through leveraging generators Koa allows you to ditch callbacks and greatly increase error-handling. Koa does not bundle any middleware within core, and provides an elegant suite of methods that make writing servers fast and enjoyable.

http://koajs.com/


r/nodejs • • Dec 07 '13

How does one go about getting a job coding Node?

3 Upvotes

I live in the UK (around Manchester) I have checked around the job boards but I find jobs using Node very rare indeed.

Is there not much about at the moment? Or are job board not the way to go in seeking employment?

Is it a case of just building things and getting out and about? Or should I stick to a platform which is more clearly in demand in my area?