Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support providing a repository name to createClient() in place of an API endpoint #224

Merged
merged 2 commits into from
Feb 16, 2022

Conversation

angeloashmore
Copy link
Member

@angeloashmore angeloashmore commented Feb 16, 2022

Types of changes

  • Chore (a non-breaking change which is related to package maintenance)
  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR adds support for providing a repository name to createClient() in place of an API endpoint.

import { createClient } from "@prismicio/client";

const client = prismic.createClient("repo-name");

Passing an API endpoint is still supported:

import { createClient } from "@prismicio/client";

const endpoint = prismic.getRepositoryEndpoint("repo-name");
const client = prismic.createClient(endpoint);

If the first argument for createClient() is not an endpoint, it will build one using getRepositoryEndpoint() automatically.

This takes advantage of the isRepositoryEndpoint() helper introduced in #222.

Related: prismicio/prismic-helpers#42

Checklist:

  • My change requires an update to the official documentation.
  • All TSDoc comments are up-to-date and new ones have been added where necessary.
  • All new and existing tests are passing.

🦄

@angeloashmore angeloashmore changed the title feat: support providing a repository name to createClient() in place of an API endpoint feat: support providing a repository name to createClient() in place of an API endpoint Feb 16, 2022
@github-actions
Copy link

size-limit report 📦

Path Size
dist/index.js 3.98 KB (+0.13% 🔺)
dist/index.cjs 6.81 KB (+0.23% 🔺)

@angeloashmore angeloashmore merged commit 8c88382 into master Feb 16, 2022
@angeloashmore angeloashmore deleted the aa/auto-endpoint-2 branch February 16, 2022 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant