TryGhost/Ghost

View on GitHub
ghost/dynamic-routing-events/lib/URLResourceUpdatedEvent.js

Summary

Maintainability
A
0 mins
Test Coverage
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
        });
    }
};