Skip to content

Commit

Permalink
Merge pull request #88 from commercelayer/get-core-api-endpoint
Browse files Browse the repository at this point in the history
Add `getCoreApiEndpoint` helper
  • Loading branch information
malessani authored Sep 10, 2024
2 parents a68f7c1 + 321ef55 commit ca1e628
Show file tree
Hide file tree
Showing 24 changed files with 353 additions and 281 deletions.
15 changes: 15 additions & 0 deletions .ncurc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
reject: [
'pnpm'
],
filterResults: (name, { upgradedVersionSemver }) => {
if (
name === '@types/node' && parseInt(upgradedVersionSemver?.major) >= 22 ||
name === 'eslint' && parseInt(upgradedVersionSemver?.major) >= 9
) {
return false
}

return true
}
}
Binary file modified examples/bun/bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion examples/bun/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { authenticate, AuthenticateOptions, GrantType, jwtVerify } from '@commercelayer/js-auth'
import { authenticate, AuthenticateOptions, getCoreApiBaseEndpoint, GrantType, jwtVerify } from '@commercelayer/js-auth'

const grantType: GrantType = 'client_credentials'

Expand All @@ -15,4 +15,5 @@ const decodedJWT = await jwtVerify(auth.accessToken)

if ('organization' in decodedJWT.payload) {
console.log('organization slug is', decodedJWT.payload.organization.slug)
console.log('base endpoint is', getCoreApiBaseEndpoint(auth.accessToken))
}
3 changes: 2 additions & 1 deletion examples/cjs/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

const { authenticate, jwtVerify, jwtIsSalesChannel } = require('@commercelayer/js-auth')
const { authenticate, jwtVerify, jwtIsSalesChannel, getCoreApiBaseEndpoint } = require('@commercelayer/js-auth')

async function run() {
const auth = await authenticate('client_credentials', {
Expand All @@ -14,6 +14,7 @@ async function run() {

if (jwtIsSalesChannel(decodedJWT.payload)) {
console.log('organization slug is', decodedJWT.payload.organization.slug)
console.log('base endpoint is', getCoreApiBaseEndpoint(auth.accessToken))
}

}
Expand Down
16 changes: 8 additions & 8 deletions examples/cjs/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/cloudflare-workers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"@commercelayer/js-auth": "workspace:*"
},
"devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.4.23",
"@cloudflare/workers-types": "^4.20240815.0",
"typescript": "^5.5.4",
"@cloudflare/vitest-pool-workers": "^0.4.29",
"@cloudflare/workers-types": "^4.20240909.0",
"typescript": "^5.6.2",
"vitest": "2.0.5",
"wrangler": "^3.72.0"
"wrangler": "^3.75.0"
}
}
Loading

0 comments on commit ca1e628

Please sign in to comment.