deleteman / vatican

Micro-framework designed to create REST APIs with minor effort
98 stars 6 forks source link

Vatican.getCorrectModel #21

Closed smart--petea closed 10 years ago

smart--petea commented 10 years ago

When there are no database connection the variable this.dbmodels is undefined and as result the snippet this.dbmodels[modelName] throw an error. This is from

Vatican.prototype.getCorrectModel = function(handler) {
    var modelName = handler.handlerName.replace("Hdlr", '')
    return this.dbmodels[modelName]
}

Maybe to write this function in the form

Vatican.prototype.getCorrectModel = function(handler) {
    if( this.dbmodels ) {
      var modelName = handler.handlerName.replace("Hdlr", '')
      return this.dbmodels[modelName]
    }

    return false;
}