Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Stuff we share across our projects. It's like a toolbox but it smells good!
JavaScript
branch: master

This branch is 79 commits behind Dijiwan:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
amqp
config
crud
doc
forms
logger
test
.gitignore
.travis.yml
README.md
package.json

README.md

doggybag

Build Status

At Dijiwan, we use JavaScript a lot, especially with node.js. We have common needs across our project, so we decided to package them, and make them available publicly.

A brief word of History While looking a name for this project, we asked to translate the word toolbox in Japanese to our japanese-speaking-guy (Guillaume).

As his answer dôgubako (道具箱) sounded like doggybag, we laughed and decided to call it as is. It's also a way to carry delicious stuff at home, or at work.

Extended forms

This component extends @caolan's forms, providing new features like Twitter Bootstrap templating, new useful validators and fields…

var forms = require('doggybag/forms');

var form = forms.create({
  "username": forms.fields.string({ required:true }),
  "gender":   forms.fields.string({ widget:forms.widgets.multipleCheckbox({}), choices:['M','F','X'], validators:[forms.validators.choices()] }),
  "avatar":   forms.fields.file({ help:"Less than 200K" })
});

See doc/forms.md for more complete documentation.

Config loader

Based on @flatiron's nconf, this component will allow you to use a two-level file-based configuration: a "common" configuration, and some overrides depending on your environment.

// In your bootstrap
require('doggybag/config').add('myApp'); // loads config/myApp.json and config/myApp.production.json

// Later in your code
var key = require('doggybag/config').myApp.get('key');

See doc/config.md for more complete documentation.

Logger

Based on @flatiron's winston, this component acts as a thin wrapper to simply automatically configure several Logger instances and provide easy access to them.

// In your bootstrap
require('doggybag/logger').add('myApp'); // grab config from 'logging.json', key "myApp"

// Later in your code
var logger = require('doggybag/logger').myApp;

logger.warn('This may not occur');

See doc/logger.md for more complete documentation.

Express CRUD

This component acts as an Express app builder you can use in your back-office. It uses doggybag/forms, and works natively with mongoose but could work with any type of data.

var crud = require('doggybag/crud');

var usersApp = crud.init({
  model: mongoose.model('User'),
  form: function (forms, cb) { cb(null, forms.create(…)) },
  listLocals: crud.helpers.defineLocals({table: "users/list_table"})
});

app.mount('/users', usersApp);

See doc/crud.md for more complete documentation.

Something went wrong with that request. Please try again.