This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns a string representation of a URL pattern , | |
* with its parameters filled in by the passed hash. | |
* | |
* If a key is not found in the hash for a param, it is left alone. | |
* | |
* @param {Object} a hash of parameter names to values for substitution. | |
*/ | |
function realizeUrl(pattern, params) { | |
var p = pattern.replace(/\/:([^/]+)/g, function (match, k) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function capitalize(str) { | |
return (str.charAt(0).toUpperCase() + str.slice(1)); | |
} | |
function uncapitalize(str) { | |
return (str.charAt(0).toLowerCase() + str.slice(1)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys') | |
function Person(age){ | |
this.__defineGetter__('age', function(){ | |
return age | |
}) | |
this.__defineSetter__('age', function(arg){ | |
age = arg | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toCamelCase(str) { | |
return str.toLowerCase().replace(/(?:(^.)|(\s+.))/g, function(match) { | |
return match.charAt(match.length-1).toUpperCase(); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require("util"); | |
/** | |
* HttpError. | |
* | |
* @param code {Number} : http status code | |
* @param status {String} : http status description | |
* @param message {String} : message of error | |
* @constructor | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This module is from mongoose-pagination. | |
* | |
* Copyright (c) 2012 Moveline Inc. | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Wrap express.request.param with decorator. | |
* | |
* @param {HttpRequest} req | |
* @param {String} name | |
* @param {Function} [decorator] | |
* @param {Mixed} [defaultValue] | |
* @returns value of parameter | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require('util'); | |
/** | |
* Convert array to object, | |
* each element of array is as key in object, | |
* and ignores the non-string elements. | |
* | |
* @example | |
* [ 'a', 'b', 'c' ] => { 'a':1, 'b':1, 'c':1 } | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dependecies | |
var express = require('express'); | |
var app = module.exports = express(); | |
// configuration | |
app.configure(function () { | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'jade'); | |
app.use(express.bodyParser()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get filters of query. | |
* | |
* @param {HttpRequest} req | |
* @param {Object} [options] | |
* - {Boolean} [customizable] | |
* whether the filter is customizable | |
* i.e. can be pass from query string with the key $filter | |
* e.g. $filter=id,key,value | |
* - {Object} [allow] |
OlderNewer