15 lines
343 B
JavaScript
15 lines
343 B
JavaScript
import dayjs from 'dayjs';
|
|
import merge from 'lodash.merge';
|
|
import { randomUUID } from 'node:crypto';
|
|
|
|
export function messageMaker(source) {
|
|
return {
|
|
make(type, data, extras) {
|
|
const timestamp = dayjs().format();
|
|
const uuid = randomUUID();
|
|
|
|
return merge({ uuid, type, timestamp, source, data }, extras);
|
|
}
|
|
};
|
|
}
|