Ghost/ghost/dynamic-routing-events/lib/URLResourceUpdatedEvent.js
Naz ec4045cb57
Added dynamic-routing-events package
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
2023-01-23 16:33:41 +08:00

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
});
}
};