Boards = new Mongo.Collection('board');

  // Global API configuration
  var Api = new Restivus({
    useDefaultAuth: false,
    auth: {
      user: function() {
        //TODO: check token auth first
        if (this.queryParams.token && this.queryParams.username) {
          if (this.queryParams.token !== Meteor.settings.authToken) {
            return null;
          }
          
          return { user : Meteor.users.findOne({"username": this.queryParams.username})};
        }
      }
    },
    prettyJson: true,
    onLoggedIn: function () {
      console.log(this.user.username + ' (' + this.userId + ') logged in');
    },
  });
  
  // Generates: GET, POST on /api/items and GET, PUT, DELETE on
  // /api/items/:id for the Items collection
  Api.addCollection(Boards);

  Api.addRoute('users', { authRequired: true }, {
    get: { 
      roleRequired: ['admin'],
      action: function () {
          var stampedToken = Accounts._generateStampedLoginToken();
          var hashStampedToken = Accounts._hashStampedToken(stampedToken);
          
          //push resume token
          Meteor.users.update(this.user._id, 
            {$push: {'services.resume.loginTokens': hashStampedToken}}
          );
          var when = stampedToken.when;
          
          when.setDate(when.getDate() + 365);
          return { 
            'username': this.user.username,
            'userId': this.userId,
            'token': stampedToken.token, 
            'tokenExpire': when.toString()
          };
      }
    },
    
    post: { 
      roleRequired: ['admin'],
      action: function () {
        var existingUser = Meteor.users.findOne({ "username": this.bodyParams.username });
        if (existingUser != null) {
          return { userId: existingUser._id };
        }
        
        var userId = Accounts.createUser({ username: this.bodyParams.username, email: this.bodyParams.email, password: this.bodyParams.password });
        if (userId) {
          return { userId : userId };
        }
        
        return { stausCode: 500 };  
      }
    }
  });

  // Maps to: /api/articles/:id
  Api.addRoute('boards/:id', {authRequired: true}, {
    get: function () {
      return Boards.findOne(this.urlParams.id);
    }
  });
@@ -30,24 +30,462 @@
 ('board');%0A%0A
+function boostrapAdmin()%7B%0A  // Roles.createRole(%22admin%22);%0A  // var userId = Accounts.createUser(%7B %0A  //   username: %22admin%22, %0A  //   email: %22wonderxboy+ctaskAdmin@gmail.com%22, %0A  //   password: %22%7Badd password here%7D%22, %0A  //   roles: %5B'admin'%5D %7D);%0A    %0A  // if (!userId) %7B%0A  //   return 'admin not created';%0A  // %7D%0A  // var adminUser = Meteor.users.findOne(%7B %22username%22: %22admin%22 %7D);%0A  // Roles.addUsersToRoles(adminUser._id, %22admin%22); %0A%7D%0A  %0A
   // Global 
@@ -1214,16 +1214,18 @@
 oards);%0A
+  
 %0A  Api.a
@@ -1238,16 +1238,20 @@
 e('users
+/:id
 ', %7B aut
@@ -1291,35 +1291,8 @@
     
-  roleRequired: %5B'admin'%5D,%0A
     
@@ -1321,24 +1321,28 @@
 %7B%0A          
+    
 var stampedT
@@ -1387,16 +1387,20 @@
 oken();%0A
+    
         
@@ -1468,33 +1468,41 @@
 ken);%0A          
+   
-%0A
+ %0A    
           //push
@@ -1525,16 +1525,20 @@
         
+    
 Meteor.u
@@ -1555,21 +1555,25 @@
 e(this.u
-ser._
+rlParams.
 id, %0A   
@@ -1581,16 +1581,20 @@
         
+   
+ 
 %7B$push: 
@@ -1654,19 +1654,27 @@
         
-);%0A
+    );%0A    
         
@@ -1707,33 +1707,41 @@
 when;%0A          
+  
-%0A
+  %0A    
           when.s
@@ -1770,16 +1770,20 @@
 + 365);%0A
+    
         
@@ -1802,24 +1802,28 @@
             
+    
 'username': 
@@ -1850,24 +1850,28 @@
             
+    
 'userId': th
@@ -1889,24 +1889,28 @@
             
+   
+ 
 'token': sta
@@ -1927,16 +1927,20 @@
 token, %0A
+    
         
@@ -1988,30 +1988,98 @@
     
-%7D;%0A      %7D%0A    %7D,%0A    
+    %7D;%0A          %7D%0A      %7D%0A    %7D);%0A    %0A  Api.addRoute('users', %7B authRequired: false %7D, %7B
 %0A   
@@ -2629,40 +2629,8 @@
 );%0A%0A
-  // Maps to: /api/articles/:id%0A
   Ap
@@ -2655,16 +2655,17 @@
 /:id', %7B
+ 
 authRequ
@@ -2674,16 +2674,17 @@
 ed: true
+ 
 %7D, %7B%0A   

add bootstrap admin function; adjust user api