Skip to content

Refactor duplicate code for metadata header x-meta- #4

Description

@shulkaolka

Looks like it is a duplicate for one functionality:
https://github.com/elasticio/maester-client/blob/master/src/object.ts#L170

        if (params?.objectFields) {
            Object.entries(params.objectFields).forEach(e => {
                if (e[1].Query) headers[`X-Query-${e[0]}`] = e[1].Query;
                if (e[1].Meta) headers[`X-Meta-${e[0]}`] = e[1].Meta;
            })
        }

and
https://github.com/elasticio/maester-client/blob/master/src/object.ts#L24

export function metaToHeaders(meta: ObjectMetadata): Record<string, string> {
    const headers: Record<string, string> = {};
    for (const [key, value] of Object.entries(meta)) {
        headers[`${USER_META_HEADER_PREFIX}${key}`] = String(value);
    }
    return headers;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions