racer-access deprecated

91 views
Skip to first unread message

Lucas

unread,
Oct 6, 2014, 9:40:00 AM10/6/14
to der...@googlegroups.com
Hello,
 I"m fan of racerjs. I came across https://github.com/codeparty/racer-access/blob/master/README.md  and it is stated already deprecated. May i know what is the new replacement library for this? I'm looking for racer library to ease me in writing access control for webapp

Artur Zayats

unread,
Oct 6, 2014, 10:11:44 AM10/6/14
to der...@googlegroups.com
If you wish you can use my one - https://github.com/dmapper/share-access

Curran Kelleher

unread,
May 3, 2016, 3:21:16 AM5/3/16
to Derby
Hello,

I'm a bit confused at the current state of access control with Derby - which repo is currently the recommended one to use - sharedb-access or share-access?

Racer has an access control section in its README saying access control is "Under development", but somehow I have the feeling it's said that for years. I made a pull request updating that section to point to sharedb-access.

Best regards,
Curran

Carl-Johan Blomqvist

unread,
May 4, 2016, 2:07:02 AM5/4/16
to Derby
Sharedb is the one to use.

Curran Kelleher

unread,
May 4, 2016, 3:39:42 AM5/4/16
to der...@googlegroups.com
Thanks!

On Wed, May 4, 2016 at 11:37 AM, Carl-Johan Blomqvist <carljohan...@gmail.com> wrote:
Sharedb is the one to use.

--
You received this message because you are subscribed to a topic in the Google Groups "Derby" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/derbyjs/LaiCtRrsB8k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to derbyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Curran Kelleher

unread,
Jun 2, 2016, 6:56:15 AM6/2/16
to Derby
Hi all,

I'm attempting to start using sharedb-access. I'm getting the following error:

/Users/curran/repos/myApp/node_modules/racer/lib/util.js:178
    plugin(this, options);
    ^

TypeError: plugin is not a function
    at Racer.use (/Users/curran/repos/myApp/node_modules/racer/lib/util.js:178:5)
    at new ShareDBAccess (/Users/curran/repos/myApp/node_modules/sharedb-access/lib/index.js:29:11)
    at ShareDBAccess (/Users/curran/repos/myApp/node_modules/sharedb-access/lib/index.js:22:48)
    at Racer.use (/Users/curran/repos/myApp/node_modules/racer/lib/util.js:178:5)
    at store (/Users/curran/repos/myApp/server/store.js:10:9)
    at /Users/curran/repos/myApp/server.js:17:40
    at Racer.Derby.run (/Users/curran/repos/myApp/node_modules/derby/lib/Derby.server.js:17:5)
    at Object.<anonymous> (/Users/curran/repos/myApp/server.js:8:7)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)


Here we can see the source of the error within sharedb-access:

https://github.com/dmapper/sharedb-access/blob/master/lib/index.js#L29

backend.use('doc', this.docHandler.bind(this));

The definition of `use` can be found here in racer:

https://github.com/derbyjs/racer/blob/master/lib/util.js#L173

function use(plugin, options) {
  // Don't include a plugin more than once
  var plugins = this._plugins || (this._plugins = []);
  if (plugins.indexOf(plugin) === -1) {
    plugins.push(plugin);
    plugin(this, options);
  }
  return this;
}


It seems the `use` function does not take a string as the first argument. This can be traced to a change by @nateps in 2014

https://github.com/derbyjs/racer/commit/4317c8b72b066bcda7c44afae8d4a0b34afb50f0#diff-3deb3f32958bb937ae05c6f3e4abbdf5L170

I'm not sure if this is actually the cause of the error though, because sharedb-access was updated more recently than that by @cjblomqvist

https://github.com/dmapper/sharedb-access/commit/9aa2d9edbe4b9db2a23ed0c125bd266ea8c1bfa2

Here are the versions from my package.json:

  "dependencies": {
    "async": "^2.0.0-rc.5",
    "bcryptjs": "^2.3.0",
    "body-parser": "^1.15.1",
    "compression": "^1.6.2",
    "connect-mongo": "^1.2.0",
    "cookie-parser": "^1.4.3",
    "derby": "^0.8.5",
    "derby-debug": "^0.1.0",
    "derby-login": "^1.1.1",
    "express": "^4.13.4",
    "express-session": "^1.13.0",
    "racer-bundle": "^0.2.4",
    "racer-highway": "^7.0.2",
    "redis-url": "^1.2.1",
    "serve-favicon": "^2.3.0",
    "serve-static": "^1.10.3",
    "sharedb-access": "^3.0.0",
    "sharedb-mongo": "^0.8.7",
    "sharedb-redis-pubsub": "^0.3.1"


Here's where I'm adding sharedb-access (inside store.js from generator-derby):

var shareDbMongo = require("sharedb-mongo");
var shareDbAccess = require("sharedb-access");

module.exports = store;

function store(derby, publicDir) {
  var db = shareDbMongo(process.env.MONGO_URL + "?auto_reconnect=true", {safe: true});

  derby.use(require("racer-bundle"));
  derby.use(shareDbAccess);

  var redis = require("redis-url");
  var redisPubSub = require("sharedb-redis-pubsub");
  ...

Also posted as an issue in sharedb-access: TypeError: plugin is not a function #4.

Any ideas why this error is occurring or how it can be fixed? Thank you.

Best regards,
Curran

Curran Kelleher

unread,
Jun 2, 2016, 8:35:08 AM6/2/16
to Derby

Hello,


After a bit more research, I realized that the wrong use is getting invoked from within sharedb-access. If the text of use is printed like this:

function ShareDBAccess(backend, options){
  if (!(this instanceof ShareDBAccess)) return new ShareDBAccess(backend, options);

  this.options = options || {};

  this.allow = {};
  this.deny = {};

  console.log(backend.use.toString());

  backend.use('doc', this.docHandler.bind(this));
  backend.use('apply', this.applyHandler.bind(this));
  backend.use('commit', this.commitHandler.bind(this));

  this.initBackend(backend);
}

The following gets printed:

function use(plugin, options) {
  // Don't include a plugin more than once
  var plugins = this._plugins || (this._plugins = []);
  if (plugins.indexOf(plugin) === -1) {
    plugins.push(plugin);
    plugin(this, options);
  }
  return this;
}

This is the use function from Racer, but really what it should be is the use function from ShareDB Backend.


Any ideas how to change this so the correct use function gets used?


Also, does it perhaps depend on whether or not derby.use(require("sharedb-access")); is invoked before or after setting up the store?


Regards,
Curran

Curran Kelleher

unread,
Jun 2, 2016, 8:46:03 AM6/2/16
to Derby

I think I found the solution, to invoke sharedb-access like this after the store gets created:

require("sharedb-access")(store);
Reply all
Reply to author
Forward
0 new messages