meilisearch-js icon indicating copy to clipboard operation
meilisearch-js copied to clipboard

Separate token specific code into its own export

Open flevi29 opened this issue 1 year ago • 6 comments

Pull Request

Related issue

Fixes #1690

What does this PR do?

  • generalizes the MeiliSearch client into a single universal export by stripping Node.js crypto specific token code into its own separate exported module
  • apiKey option is now mandatory in generateTenantToken function

Migration

Old:

import { MeiliSearch } from "meilisearch";

const client = new MeiliSearch({ host: "http://127.0.0.1:7700", apiKey: "masterKey" });
const token = await client.generateTenantToken("e489fe16-3381-431b-bee3-00430192915d");

// ...

New:

import { generateTenantToken } from "meilisearch/token";

const token = await generateTenantToken("e489fe16-3381-431b-bee3-00430192915d", [], { apiKey: "masterKey" });

// ...

PR checklist

Please check if your PR fulfills the following requirements:

  • [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • [x] Have you read the contributing guidelines?
  • [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

flevi29 avatar Oct 04 '24 17:10 flevi29