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
| // url : | |
| /user/:userId/upload/delete | |
| //post-body : | |
| { | |
| _id : <imageId> | |
| } |
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 data = { | |
| id : uploaded_file._id, | |
| filters : [ | |
| { | |
| name : 'image', | |
| options : [ | |
| { | |
| operation : 'resize', | |
| width : $placeholder_img.width(), | |
| height : $placeholder_img.height() |
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
| /** | |
| * Very simple Mealy style finite state machine relying on a nodejs event emitter. Absolutely not tested | |
| * and contains absolutely no fancy feature. You can put multiple "from" and "to" states by separating | |
| * them with a space. Putting no "from" or "to" amounts to setting them as "undefined", a supported state. | |
| */ | |
| // Example: | |
| /* | |
| var fsm = new Fsm([ | |
| { name : 'wakingup' , from: 'sleeping' , to : 'awake' }, |
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
| app.get( '/bob', function( req, res, next ){ | |
| if( !req.session ){ | |
| console.log( 'no session!' ); | |
| } | |
| else{ | |
| console.log( req.session ); | |
| req.session.counter++; | |
| } |
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
| { | |
| file: < the file> | |
| name: filename | |
| hook: { | |
| name : "user_avatar", | |
| userid : "09a8019238402a9sdfsa0", | |
| } | |
| } |
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 validation = require( './validation' ); | |
| var v = require('./validators' ); | |
| function lowerCase( value, err ){ | |
| return value.toLowerCase(); | |
| } | |
| var userSchema = { | |
| firstname : [ v.trim() ], | |
| lastname : [ v.trim() ], |
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 user = { | |
| name : [ purity.isString ], //Simple validation that the | |
| //name is a string. | |
| email : [ purity.trim, purity.isString, purity.isEmail ], | |
| age : [ purity.isNumber, purity.greater(0), purity.toInt ], | |
| //Array of friends |
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 findMostRecent(folder){ | |
| var mostRecent = null | |
| var contentList = getFolderContentList(folder.path); | |
| for(var i = 0; i < contentList.length; ++i){ | |
| if(contentList[i].type === 'file' && | |
| (mostRecent === null || contentList[i].date > mostRecent.date)){ | |
| mostRecent = contentList[i]; |
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
| authmethods : [ | |
| { type: 'facebook', | |
| id: '12304912835812304192384' | |
| token : 'asd0fa0sd9fasjdlfasdf9as0d98fasd', | |
| salt: '1029384as0d9fasd8fasdf09asdf8as0df9as8dfasdf0asd9', | |
| data: {...} | |
| }, | |
| { | |
| type: 'password', |
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 purity = require('virtue-purity'); //virtue's validation | |
| //& sanitization lib. | |
| var user = { | |
| name : [ purity.isString ], //Simple validation that the | |
| //name is a string. | |
| email : [ purity.trim, purity.isString, purity.isEmail ], |