'use strict'; const Backbone = require('backbone'); const model = Backbone.Model.extend({ idAttribute: 'id', defaults: function () { return { id: 0, created_on: null, modified_on: null, domain_names: [], forward_ip: '', forward_port: null, access_list_id: 0, ssl_enabled: false, ssl_provider: false, ssl_forced: false, caching_enabled: false, block_exploits: false, meta: {}, // The following are expansions: owner: null, access_list: null }; }, /** * @param {String} type 'letsencrypt' or 'other' * @returns {Boolean} */ hasSslFiles: function (type) { let meta = this.get('meta'); return typeof meta[type + '_certificate'] !== 'undefined' && meta[type + '_certificate'] && typeof meta[type + '_certificate_key'] !== 'undefined' && meta[type + '_certificate_key']; } }); module.exports = { Model: model, Collection: Backbone.Collection.extend({ model: model }) };