({
ip,
origin,
payload,
projectId,
}: {
ip: string;
origin: string;
payload: Record<string, any>;
projectId: string;
})
| 2 | import fastJsonStableHash from 'fast-json-stable-hash'; |
| 3 | |
| 4 | export async function isDuplicatedEvent({ |
| 5 | ip, |
| 6 | origin, |
| 7 | payload, |
| 8 | projectId, |
| 9 | }: { |
| 10 | ip: string; |
| 11 | origin: string; |
| 12 | payload: Record<string, any>; |
| 13 | projectId: string; |
| 14 | }) { |
| 15 | const locked = await getLock( |
| 16 | `fastify:deduplicate:${fastJsonStableHash.hash( |
| 17 | { |
| 18 | ...payload, |
| 19 | ip, |
| 20 | origin, |
| 21 | projectId, |
| 22 | }, |
| 23 | 'md5', |
| 24 | )}`, |
| 25 | '1', |
| 26 | 100, |
| 27 | ); |
| 28 | |
| 29 | if (locked) { |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | return true; |
| 34 | } |
no test coverage detected