diff --git a/modules/apis/models/apis.model.mongoose.js b/modules/apis/models/apis.model.mongoose.js index b605c7516..c98af191a 100644 --- a/modules/apis/models/apis.model.mongoose.js +++ b/modules/apis/models/apis.model.mongoose.js @@ -29,6 +29,8 @@ const ApiMongoose = new Schema({ savedb: Boolean, autoRequest: Boolean, expiration: Date, + cron: String, + alert: String, user: { type: Schema.ObjectId, ref: 'User', diff --git a/modules/apis/models/apis.schema.js b/modules/apis/models/apis.schema.js index d112df618..a4b43a04e 100644 --- a/modules/apis/models/apis.schema.js +++ b/modules/apis/models/apis.schema.js @@ -19,11 +19,14 @@ const ApiSchema = Joi.object().keys({ banner: Joi.string().trim().default('').allow('') .optional(), description: Joi.string().allow('').default('').optional(), - user: Joi.string().trim().default(''), - history: Joi.array().items(Joi.string().trim()).optional(), savedb: Joi.boolean().default(false).required(), autoRequest: Joi.boolean().default(false).required(), expiration: Joi.date().optional(), + cron: Joi.string().trim().allow(null).optional(), + alert: Joi.string().email({ minDomainAtoms: 2 }).trim().allow(null) + .optional(), + user: Joi.string().trim().default(''), + history: Joi.array().items(Joi.string().trim()).optional(), }); module.exports = { diff --git a/modules/apis/services/apis.service.js b/modules/apis/services/apis.service.js index 87b3c2f29..a033e62f4 100644 --- a/modules/apis/services/apis.service.js +++ b/modules/apis/services/apis.service.js @@ -65,8 +65,14 @@ exports.update = async (api, body) => { api.description = body.description; api.savedb = body.savedb; api.autoRequest = body.autoRequest; + if (body.expiration && body.expiration !== '') api.expiration = body.expiration; else api.expiration = null; + if (body.cron && body.cron !== '') api.cron = body.cron; + else api.cron = null; + if (body.alert && body.alert !== '') api.alert = body.alert; + else api.alert = null; + if (body.typing && body.typing !== '') api.typing = body.typing; else api.typing = null; if (body.mapping && body.mapping !== '') api.mapping = body.mapping;