Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var Backend = require('sharedb').Backend;
var Model = require('./Model');
var util = require('./util');
module.exports = RacerBackend;
function RacerBackend(racer, options) {
Backend.call(this, options);
this.racer = racer;
this.modelOptions = options && options.modelOptions;
this.on('bundle', function(browserify) {
var racerPath = path.join(__dirname, 'index.js');
browserify.require(racerPath, {expose: 'racer'});
});
}
RacerBackend.prototype = Object.create(Backend.prototype);
RacerBackend.prototype.createModel = function(options, req) {
if (this.modelOptions) {
options = (options) ?
util.mergeInto(options, this.modelOptions) :
this.modelOptions;
}
var model = new Model(options);
this.emit('model', model);
model.createConnection(this, req);
return model;
};
RacerBackend.prototype.modelMiddleware = function() {
var backend = this;
function modelMiddleware(req, res, next) {