mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 13:22:39 +03:00
ec4045cb57
refs https://github.com/TryGhost/Toolbox/issues/503 - Reusing existing events inside of dynamic routing would only contribute to general confusion that is already there. Having separate "DomainEvents" is the best practice used throughout the code which is substituting generic events. - The URLResourceUpdatedEvent is supposed to be emmited whenever there's an updated to the resource already associated with the URL circumventing full url regeneration process inside of DynamicRouting
34 lines
568 B
JavaScript
34 lines
568 B
JavaScript
module.exports = class URLResourceUpdatedEvent {
|
|
/**
|
|
* @readonly
|
|
* @type {Object}
|
|
*/
|
|
data;
|
|
|
|
/**
|
|
* @readonly
|
|
* @type {Date}
|
|
*/
|
|
timestamp;
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
constructor({timestamp, ...data}) {
|
|
this.data = data;
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {Object} data URL Resource
|
|
* @returns
|
|
*/
|
|
static create(data) {
|
|
return new URLResourceUpdatedEvent({
|
|
...data,
|
|
timestamp: data.timestamp || new Date
|
|
});
|
|
}
|
|
};
|