DailyJS

DailyJS

The JavaScript blog.


Tagcouchdb
Featured

tutorials node couchdb

Getting Started with Hoodie

Posted on .

Fast ship?

Hoodie (GitHub: hoodiehq / hoodie.js, License: Apache 2.0, npm: hoodie) is a noBackend framework that uses Node, with a focus on client-side development.

noBackend is an approach to decouple apps from backends, by abstracting backend tasks with frontend code. This allows frontend developers to focus on user experience and gives backend developers more flexibility on the implementation side.

Hoodie applications are based around documents, and are backed by CouchDB. It embraces event-based APIs, JSON across the whole stack, and uses npm for plugins. It's also designed to be easy to deploy to Nodejitsu.

Applications are instances of Hoodie objects. This provides the entry point to most functionality, including user accounts -- Hoodie comes with a baked-in account system. Data is stored per-user through hoodie.store, which is accessible from client-side code. In this respect it's reminiscent of Meteor.

Data lifecycle stages trigger events, so you can easily see when data is changed in some way:

hoodie.store.on('add:task', function(event, changedObject) {  
  // Update the view with the changedObject
});

The API is chainable and will remind client-side developers of jQuery.

As a teaser, here are some of the account handling method calls:

hoodie.account.signUp('joe@example.com', 'secret');  
hoodie.account.changeUsername('currentpassword', 'newusername');  
hoodie.account.resetPassword('joe@example.com');  
hoodie.account.destroy();  

To start your own project you'll need CouchDB installed locally. Then you can npm install -g hoodie-cli, which will allow you to run hoodie new to create a new project. The process is straightforward if you're already using Node and don't mind running CouchDB, and it's fully documented on Hoodie's website.

The documentation for Hoodie is solid, and I've found it easy to follow so far. Although I only learned about it at the Great British Node Conference, the developers have been working on it for over a year. It has sponsors, and is looking for more. It's a well-presented, open source project, with momentum behind it.

Talking to Sven Lito at the Great British Node Conference I got the impression that the team are treating it as a commercial project, while believing in the open source model. This made me want to get on board and use it myself, so I suggest you give it a try.

Featured

libraries redis node modules couchdb streams

Node Roundup: redis-stream, DataGen, Cushion

Posted on .

You can send in your Node projects for review through our contact form or @dailyjs.

redis-stream

redis-stream (License: MIT, npm: redis-stream) by Thomas Blobaum is a stream-based wrapper around the Redis protocol. It's actually an extremely lightweight module, but the author has included tests and some interesting examples. The standard Node stream methods work, so data can be piped:

var Redis = require('redis-stream')  
  , client = new Redis(6379, localhost, 0)
  , rpop = client.stream('rpop');

rpop.pipe(process.stdout);  
rpop.write('my-list-key');  

This doesn't just apply to rpop, other Redis commands will also work in a similar way.

DataGen

DataGen (GitHub: cliffano / datagen, License: MIT, npm: datagen) by Cliffano Subagio is a multi-process test data file generator. It can be used to generate files in various formats, including CSV and JSON, based on template files that describe the output. Random numbers, dates, and strings can be generated.

The underlying random data generation is based on the Faker library, and Mocha tests are included.

Cushion

Cushion (GitHub: Zoddy / cushion, License: MIT, npm: cushion) by André Kussmann is a CouchDB API. It has Node-friendly asynchronous wrappers around the usual CouchDB API methods, and it also supports low-level requests by calling cushion.request. Fetching documents returns a document object that can be modified and saved like this:

var doc = db.document('id');  
doc.load(function(err, document) {  
  document.body({ name: 'Quincy' });
  document.save();
});

Designs and users can also be fetched and manipulated.

Featured

databases node modules documentation couchdb

Node Roundup: 0.7.12, nd, futoncli

Posted on .

You can send in your Node projects for review through our contact form or @dailyjs.

Node 0.7.12: Prepare for 0.8!

Node 0.7.12 is here, and Isaac Schlueter said Node 0.8.0 will be released later this week:

Please try out this release. There will be very virtually no changes between this and the v0.8.x release family. This is the last chance to comment before it is locked down for stability. The API is effectively frozen now.

That means it's crunch time! Efforts have been made to preserve support for binary addons that use libeio and libev, but libev will be officially deprecated in 0.8 and gone in 0.9.

The 0.6 era feels like halcyon days -- a time when Node received a huge amount of attention from the mainstream technology press, and stronger than ever developer interest. I'd like to wish the core team the best of luck with the 0.8 release.

nd

Back in April, TJ Holowaychuk released mad(1), an alternative manual page system based on Markdown. Now Russ Frank has released nd (License: MIT, npm: nd), which is similar to mad but focused on displaying documentation for npm modules and is written in JavaScript.

Typing nd module will display the documentation associated with module. The project's readme contains lots of tips for finding documentation within modules and displaying it, and it also points out that it supports Windows -- it'll run fine in the standard cmd.exe command interpreter.

futoncli

Futon

If you're working with CouchDB, then futoncli (License: Apache 2.0, npm: futon) by Nuno Job may be useful. It's a command-line tool for managing CouchDB, and is based on the author's nano database driver.

Once installed, the futon binary will accept commands, and configuration can be persisted to the ~/.futoncliconf file. The author has made a video of futoncli to demonstrate the main features.

Featured

games databases node modules couchdb linq

Node Roundup: OneJS, node-pad, CouchPress, node-linq

Posted on .

You can send in your Node projects for review through our contact form or @dailyjs.

OneJS

OneJS (npm: one) by Azer Koculu is a command-line utility for converting CommonJS-style packages to browser-friendly JavaScript. It provides Node-compatible APIs, and the output can also be run with Node if required.

All it needs is a suitable package.json file:

$ onejs build package.json bundle.js

Some of Node's standard library is technically supported by most browsers, and OneJS supports this by providing the install command:

$ onejs install assert

This will create a module in ./node_modules/assert/ with a package.json and a OneJS version of Node's assert module.

Azer said he created this project for Multiplayer Chess, which is a web-based chess game that supports up to 25 players.

node-pad

Do you like video games, or at least the DualShock 3 controller? node-pad (npm: node-pad) by Andre Tangen is a game controller library that currently supports Sony's controller:

controller.rthumb.on('move', function(event) {  
  player.updateCameraDirection({
    x: event.x
  , y: event.y
  });
});

The author has included Jasmine tests, and the project depends on Andre's node-hid fork which is built using node-waf.

CouchPress

CouchPress (GitHub: koostudios / couchpress, License: MIT, npm: couchpress) by Alexander Yuen is a CouchDB and Express-based publishing platform. It's currently very simple, but includes a minimal administration interface, a WYSIWYG editor, and the beginnings of a theming engine.

The author is planning on adding a Markdown editor, and support for plugins. He's very open to suggestions, so if you're interested in supporting a Node-based CMS then try getting in touch with him. Contact details are available in his 0.1 announcement post: CouchPress: Announcing Version 0.1.

node-linq

node-linq (License: MIT, npm: node-linq) from Fractal is a LINQ implementation for node:

{LINQ} = require 'node-linq'
fs = require 'fs'  
{extname} = require 'path'

files = ['test.txt', 'choni.txt', 'legacy.zip', 'secrets.txt', 'etc.rar']

arr = new LINQ(files)  
.Where((file) -> extname(file) is 'txt')
.OrderBy((file) -> fs.lstatSync(file).mtime)
.ToArray()

# arr == [ 'choni.txt',  'text.txt', 'secrets.txt']

It also supports Asynchronous LINQ. The readme has examples, and there are Mocha tests.

Featured

mac backbone.js couchdb

Kanso Repository, Recipes with Backbone, Appify UI

Posted on .

Kanso Package Repository

Kanso (GitHub: kanso ) has been changed to work more like a generic build system for
CouchApps. It's more framework agnostic, and includes a package repository, which is
available at kan.so/packages. From Caolan
McMahon in the New Kanso release and change of direction
thread
:

Essentially, all you need to add to your project is a kanso.json file describing how it should be built. Once your app is in this format, it's possible to merge it with other design docs written in the same way. Using this basic principle, we've developed a library of JavaScript modules, build-steps, and more, all of which can be easily shared between projects.

If you're working with CouchDB and want a relatively easy way to run
JavaScript apps, then it's worth giving Kanso a try. The community on
the Kanso Google Group is still
relatively small and helpful.

Recipes with Backbone

Recipes with Backbone (price: \$24) is an ebook by Nick Gauthier and Chris Strom that covers an introduction
to Backbone.js, namespacing, view templates, collection views, actions,
animations, non-REST models, routes, and more. The full table of
contents is here: Recipes with
Backbone
and excerpts are
available for Collection View
(PDF)
and Changes Feed (PDF).

I haven't yet bought a copy for review, but the sample content looks
promising. If you buy it, please let everyone know what you think in the
comments!

Appify UI

Appify UI by Thomas Aylott helps package web apps as Mac OS X bundles. The thing that makes
it slightly special is Node apps can be bundled just as easily as
anything else. There's a Node demo app, and instructions on how to make
them in the project's documentation.