Skip to content

Commit

Permalink
feat(history): add username ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Apr 22, 2020
1 parent 2fba2c8 commit 0284a98
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/helpers/montaineRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ exports.setApiHistory = (result, start, user, api) => ({
status: !!((result.request && result.request.type === 'success')),
data: JSON.stringify(result, null, 2) || null,
time: new Date() - start,
user: user.id || null,
user: user.id || api.user || null,
username: user.id ? `${user.firstName} ${user.lastName}` : String(user),
api: api.id || null,
});

Expand Down
1 change: 1 addition & 0 deletions modules/history/models/historys.model.mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const HistoryMongoose = new Schema({
status: Boolean,
data: String,
time: Number,
username: String,
user: {
type: Schema.ObjectId,
ref: 'User',
Expand Down
3 changes: 2 additions & 1 deletion modules/history/models/historys.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const HistorySchema = Joi.object().keys({
status: Joi.boolean().default(false).required(),
data: Joi.string().optional(),
time: Joi.number().default(0).required(),
user: Joi.string().trim().default(''),
user: Joi.string().trim().default('').optional(),
username: Joi.string().trim().required(),
api: Joi.string().trim().default(''),
});

Expand Down

0 comments on commit 0284a98

Please sign in to comment.