Skip to content

Commit

Permalink
chore(backend): Replace shared module with @clerk/shared imports
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkl committed Sep 27, 2023
1 parent e71f408 commit 20c2997
Show file tree
Hide file tree
Showing 10 changed files with 10,879 additions and 14,379 deletions.
25,039 changes: 10,855 additions & 14,184 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"test:cloudflare-workerd": "tests/cloudflare-workerd/run.sh"
},
"dependencies": {
"@clerk/shared": "^0.23.1",
"@clerk/types": "^3.52.1",
"@peculiar/webcrypto": "1.4.1",
"@types/node": "16.18.6",
Expand Down Expand Up @@ -85,4 +86,4 @@
"engines": {
"node": ">=14"
}
}
}
4 changes: 2 additions & 2 deletions packages/backend/src/redirections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default (QUnit: QUnit) => {
assert.raises(
() => redirectToSignIn({ returnBackUrl }),
new Error(
'Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.',
'@clerk/backend: Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.',
),
);
});
Expand Down Expand Up @@ -221,7 +221,7 @@ export default (QUnit: QUnit) => {
assert.raises(
() => redirectToSignUp({ returnBackUrl }),
new Error(
'Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.',
'@clerk/backend: Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.',
),
);
});
Expand Down
7 changes: 3 additions & 4 deletions packages/backend/src/redirections.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { missingPublishableKeyErrorMessage } from './shared';
import { parsePublishableKey } from './shared';
import { errorThrower, parsePublishableKey } from './shared';

type RedirectAdapter = (url: string) => any;

Expand Down Expand Up @@ -46,7 +45,7 @@ export function redirect({ redirectAdapter, signUpUrl, signInUrl, frontendApi, p

const redirectToSignUp = ({ returnBackUrl }: SignUpParams = {}) => {
if (!signUpUrl && !accountsBaseUrl) {
throw new Error(missingPublishableKeyErrorMessage);
errorThrower.throwMissingPublishableKeyError();
}

const accountsSignUpUrl = `${accountsBaseUrl}/sign-up`;
Expand All @@ -55,7 +54,7 @@ export function redirect({ redirectAdapter, signUpUrl, signInUrl, frontendApi, p

const redirectToSignIn = ({ returnBackUrl }: SignInParams = {}) => {
if (!signInUrl && !accountsBaseUrl) {
throw new Error(missingPublishableKeyErrorMessage);
errorThrower.throwMissingPublishableKeyError();
}

const accountsSignInUrl = `${accountsBaseUrl}/sign-in`;
Expand Down
23 changes: 0 additions & 23 deletions packages/backend/src/shared/callWithRetry.ts

This file was deleted.

30 changes: 17 additions & 13 deletions packages/backend/src/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
/*
* This module will contain functionality that will be copied
* from @clerk/shared and will be replaced by imports when the
* bundling issue is fixed.
*/
export { isDevelopmentFromApiKey, isProductionFromApiKey, isStaging } from './instance';
export {
addClerkPrefix,
buildPublishableKey,
callWithRetry,
getClerkJsMajorVersionOrTag,
getScriptUrl,
isDevelopmentFromApiKey,
isProductionFromApiKey,
isPublishableKey,
isStaging,
parsePublishableKey,
} from '@clerk/shared';

export { addClerkPrefix, getScriptUrl, getClerkJsMajorVersionOrTag } from './url';
export { callWithRetry } from './callWithRetry';
import { buildErrorThrower } from '@clerk/shared';
// TODO: replace packageName with `${PACKAGE_NAME}@${PACKAGE_VERSION}` from tsup.config.ts
export const errorThrower = buildErrorThrower({ packageName: '@clerk/backend' });

// TODO: replace it with @clerk/shared errorThrower.throwMissingPublishableKeyError()
export const missingPublishableKeyErrorMessage = `Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.`;

export { isDevOrStagingUrl } from './isDevOrStagingUrl';
export { buildPublishableKey, isPublishableKey, parsePublishableKey } from './parsePublishableKey';
import { createDevOrStagingUrlCache } from '@clerk/shared';
export const { isDevOrStagingUrl } = createDevOrStagingUrlCache();
16 changes: 0 additions & 16 deletions packages/backend/src/shared/instance.ts

This file was deleted.

35 changes: 0 additions & 35 deletions packages/backend/src/shared/isDevOrStagingUrl.ts

This file was deleted.

56 changes: 0 additions & 56 deletions packages/backend/src/shared/parsePublishableKey.ts

This file was deleted.

45 changes: 0 additions & 45 deletions packages/backend/src/shared/url.ts

This file was deleted.

0 comments on commit 20c2997

Please sign in to comment.