baselinejs
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,4 +0,4 @@ | ||
var _ = require( "underscore" ); | ||
var Class = require( "class-con-leche" ); | ||
var steamer = require( "steamer" ); | ||
var _ = require( 'underscore' ); | ||
var Class = require( 'class-con-leche' ); | ||
var steamer = require( 'steamer' ); | ||
@@ -59,10 +59,10 @@ module.exports = Class.extend( { | ||
// on the client side we have to do a remote sync request via our sync url. | ||
if( ! this._syncUrl ) return callback( new Error( "Attempt to sync but no syncUrl has been supplied." ) ); | ||
if( ! this._syncUrl ) return callback( new Error( 'Attempt to sync but no syncUrl has been supplied.' ) ); | ||
return $.ajax( { | ||
url : this._syncUrl, | ||
contentType : "application/json", | ||
type : "POST", | ||
contentType : 'application/json', | ||
type : 'POST', | ||
data : JSON.stringify( manifest ), | ||
dataType : "json", | ||
dataType : 'json', | ||
success : function( boatContents ) { | ||
@@ -72,3 +72,3 @@ onGotResults( null, boatContents ); | ||
error : function( errorObj, error ) { | ||
callback( new Error( "Baseline sync failed: " + errorObj.responseText ) ); | ||
callback( new Error( 'Baseline sync failed: ' + errorObj.responseText ) ); | ||
} | ||
@@ -94,4 +94,4 @@ } ); | ||
if( obj.dependencies ) { | ||
var dependencies = _.result( obj, "dependencies" ); | ||
if( ! _.isArray( dependencies ) ) throw new Error( "`dependencies` property must be an array of service identifiers." ); | ||
var dependencies = _.result( obj, 'dependencies' ); | ||
if( ! _.isArray( dependencies ) ) throw new Error( '`dependencies` property must be an array of service identifiers.' ); | ||
@@ -101,3 +101,3 @@ _.each( dependencies, function( thisDependency ) { | ||
if( _.isUndefined( thisDependencyService ) ) | ||
throw new Error( "The service \"" + thisDependency + "\" is not available on this page." ); | ||
throw new Error( 'The service \'' + thisDependency + '\' is not available on this page.' ); | ||
@@ -111,3 +111,3 @@ obj[ thisDependency ] = thisDependencyService; | ||
function _isServer() { | ||
return( typeof window === "undefined" ); | ||
return( typeof window === 'undefined' ); | ||
} |
var Class = require( 'class-con-leche' ); | ||
var CollectionService = module.exports = Class.extend( { | ||
module.exports = Class.extend( { | ||
initialize : function() { | ||
@@ -18,3 +18,7 @@ | ||
merge : function( data ) { | ||
}, | ||
_isServer : function() { | ||
return( typeof window === 'undefined' ); | ||
} | ||
} ); |
@@ -5,2 +5,3 @@ var _ = require( 'underscore' ); | ||
var Events = require( 'backbone-events-standalone' ); | ||
var uuid = require( 'node-uuid' ); | ||
@@ -14,3 +15,3 @@ var mMachineId = parseInt( Math.random() * 0xFFFFFF, 10 ); | ||
options = _.defaults( {}, options, { | ||
idFieldName : "_id" | ||
idFieldName : "id" | ||
} ); | ||
@@ -79,3 +80,3 @@ | ||
if( ! _.isArray( fields ) ) fields = Array.prototype.slice.apply( arguments, 1 ); | ||
if( ! _.isArray( fields ) ) fields = Array.prototype.slice.apply( arguments, [ 1 ] ); | ||
var values = {}; | ||
@@ -253,15 +254,3 @@ | ||
_getUniqueId : function() { | ||
var timestamp = Math.floor( new Date().valueOf() / 1000 ).toString( 16 ).substr( 0, 8 ); | ||
var machineId = mMachineId.toString( 16 ).substr( 0, 6 ); | ||
var processId = mProcessId.toString( 16 ).substr( 0, 4 ); | ||
if( mUniqueIdIncrement > 0xffffff ) mUniqueIdIncrement = 0; | ||
var increment = mUniqueIdIncrement.toString( 16 ).substr( 0, 6 ); | ||
mUniqueIdIncrement++; | ||
return '00000000'.substr( 0, 8 - timestamp.length ) + timestamp + | ||
'000000'.substr( 0, 6 - machineId.length ) + machineId + | ||
'0000'.substr( 0, 4 - processId.length ) + processId + | ||
'000000'.substr( 0, 6 - increment.length ) + increment; | ||
return uuid.v4(); | ||
} | ||
@@ -268,0 +257,0 @@ } ); |
{ | ||
"name": "baselinejs", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Share code and data between the client and the server in full stack JavaScript applications.", | ||
@@ -5,0 +5,0 @@ "main": "baseline.js", |
@@ -12,3 +12,3 @@ # baseline.js | ||
req.baseline = new Baseline( { | ||
rt : new RouteService( { routes : routeHash } ) | ||
rt : new ContactsService( { collectionName : 'contacts' } ) | ||
} ); | ||
@@ -22,3 +22,3 @@ } ); | ||
window.Wikkem.baseline = new Baseline( { | ||
rt : new RouteService(), | ||
rt : new ContactsService(), | ||
} ); | ||
@@ -49,3 +49,13 @@ ``` | ||
To | ||
```javascript | ||
app.use( function( req, res, cb ) { | ||
req.baseline = new Baseline( { | ||
rt : new ContactsService( { collectionName : 'contacts' } ) | ||
} ); | ||
req.bootstrapBoat = req.baseline.createBoat(); | ||
steamer.stuffMiddleware( 'bootstrapBoat' )( req, res, cb ); | ||
} ); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59
106346
318