Skip to content

re1ro/racer-server-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Server Request for racer

Request data from racer server. Can be used with racer or derby

Install

$ npm i racer-server-request

Using

You need to connect plugin for Store and Model. You will get store.serverRequest.register and model.serverRequest methods.

Warning!

model.serverRequest can be used only with model.fetch.

server/index.js example

var derby = require('derby');

derby.use(require('racer-server-request').storePlugin());

store = derby.createStore({
  listen: server
});

/*
 * You have `this.session` and `this.done()` context
 */
store.serverRequest.register('tumblrInfo', function(param1, param2) {
  var done = this.done;
  
  if (this.session.name === param1)
    tumblr.get('/user/info', function(err, data) {
      done(err, data);
    });
  else
    done('Access denied', null);
});

app/index.js example

var derby = require('derby');

derby.use(require('racer-server-request').modelPlugin());

var app = derby.createApp(module);

app.get('/', function(page, model, params, next) {
  var serverRequest = model.serverRequest('tumblrInfo', 'param1', 'param2');
  
  model.fetch(serverRequest, function(err, scopedInfo) {
    model.ref('_tumblrInfo', scopedInfo);
    page.render();
  });
});

Developing

You need to install grunt command globally:

$ npm i -g grunt-cli
  • Watch coffee:
$ grunt

About

Request data from racer server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published