How to use the uuidv4.fromString function in uuidv4

To help you get started, we’ve selected a few uuidv4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github guardian / editions / projects / archiver / src / notifications / device-notifications-helpers.ts View on Github external
export const prepareScheduleDeviceNotificationRequest = (
    issueData: IssueNotificationData,
    cfg: { domain: string; apiKey: string },
    scheduleTime: string,
): { reqEndpoint: RequestInfo; reqBody: RequestInit } => {
    const { domain, apiKey } = cfg

    const { key, name, issueDate } = issueData

    /**
     * TODO
     * Payload is hardcoded now for UK
     * In the future we will need to make it more generic (for US and Australia)
     */
    const payload: ScheduleDeviceNotificationPayload = {
        id: uuid.fromString(key),
        type: 'editions',
        topic: [{ type: 'editions', name: 'uk' }],
        key,
        name,
        date: issueDate,
        sender: 'editions-backend',
    }

    console.log('issue Device Notification payload', payload)

    const reqBody: RequestInit = {
        method: 'POST',
        headers: {
            Authorization: `Bearer ${apiKey}`,
            Accept: 'application/json',
            'Content-Type': 'application/json',
github guardian / editions / projects / archiver / src / tasks / notification / helpers / device-notifications-helpers.ts View on Github external
export const prepareScheduleDeviceNotificationRequest = (
    issueData: IssueNotificationData,
    cfg: { domain: string; apiKey: string },
    scheduleTime: string,
): { reqEndpoint: RequestInfo; reqBody: RequestInit } => {
    const { domain, apiKey } = cfg

    const { key, name, issueDate, edition } = issueData

    /**
     * TODO
     * Payload is hardcoded now for UK
     * In the future we will need to make it more generic (for US and Australia)
     */
    const payload: ScheduleDeviceNotificationPayload = {
        id: uuid.fromString(key),
        type: 'editions',
        topic: [{ type: 'editions', name: 'uk' }],
        key,
        name,
        date: issueDate,
        sender: 'editions-backend',
    }

    const reqBody: RequestInit = {
        method: 'POST',
        headers: {
            Authorization: `Bearer ${apiKey}`,
            Accept: 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(payload),

uuidv4

uuidv4 creates v4 UUIDs.

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis