Skip to content

Commit

Permalink
feat(apis): add cron & mail ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Apr 22, 2020
1 parent a177e38 commit b58129e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions modules/apis/models/apis.model.mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const ApiMongoose = new Schema({
savedb: Boolean,
autoRequest: Boolean,
expiration: Date,
cron: String,
alert: String,
user: {
type: Schema.ObjectId,
ref: 'User',
Expand Down
7 changes: 5 additions & 2 deletions modules/apis/models/apis.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 6 additions & 0 deletions modules/apis/services/apis.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b58129e

Please sign in to comment.