-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5361 from vuestorefront/api-middleware-1
Api Middleware
- Loading branch information
Showing
53 changed files
with
846 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
lib | ||
node_modules | ||
coverage | ||
client | ||
server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pkg from './package.json'; | ||
import typescript from 'rollup-plugin-typescript2'; | ||
|
||
export default { | ||
input: 'src/index.client.ts', | ||
output: [ | ||
{ | ||
file: pkg.client, | ||
format: 'cjs', | ||
sourcemap: true | ||
} | ||
], | ||
external: [...Object.keys(pkg.dependencies || {})], | ||
plugins: [ | ||
typescript({ | ||
// eslint-disable-next-line global-require | ||
typescript: require('typescript') | ||
}) | ||
] | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pkg from './package.json'; | ||
import typescript from 'rollup-plugin-typescript2'; | ||
import graphql from 'rollup-plugin-graphql'; | ||
|
||
export default { | ||
input: 'src/index.server.ts', | ||
output: [ | ||
{ | ||
file: pkg.server, | ||
format: 'cjs', | ||
sourcemap: true | ||
} | ||
], | ||
external: [...Object.keys(pkg.dependencies || {})], | ||
plugins: [ | ||
typescript({ | ||
// eslint-disable-next-line global-require | ||
typescript: require('typescript') | ||
}), | ||
graphql() | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/commercetools/api-client/src/helpers/apiClient/defaultSettings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const defaultSettings = { | ||
locale: 'en', | ||
acceptLanguage: ['en'], | ||
auth: { | ||
onTokenChange: () => {}, | ||
onTokenRead: () => '', | ||
onTokenRemove: () => {} | ||
}, | ||
cookies: { | ||
currencyCookieName: 'vsf-currency', | ||
countryCookieName: 'vsf-country', | ||
localeCookieName: 'vsf-locale' | ||
} | ||
}; |
75 changes: 0 additions & 75 deletions
75
packages/commercetools/api-client/src/helpers/apiClient/index.ts
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
packages/commercetools/api-client/src/helpers/commercetoolsLink/helpers.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/commercetools/api-client/src/helpers/commercetoolsLink/linkHandlers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const isAnonymousSession = (token) => token?.scope?.includes('anonymous_id'); | ||
export const isUserSession = (token) => token?.scope?.includes('customer_id'); | ||
export const getAccessToken = (token) => token ? token.access_token : null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { apiProxyFactory } from '@vue-storefront/core'; | ||
import { defaultSettings } from './helpers/apiClient/defaultSettings'; | ||
import isGuest from './api/isGuest'; | ||
|
||
const onCreate = (settings: any) => { | ||
const languageMap = settings.languageMap || {}; | ||
const acceptLanguage = settings.acceptLanguage || defaultSettings.acceptLanguage; | ||
const locale = settings.locale || defaultSettings.locale; | ||
|
||
const config = { | ||
...defaultSettings, | ||
...settings, | ||
languageMap, | ||
acceptLanguage: languageMap[locale] || acceptLanguage, | ||
auth: settings.auth || defaultSettings.auth | ||
} as any; | ||
|
||
return { config }; | ||
}; | ||
|
||
const { createApiProxy, integrationPlugin } = apiProxyFactory({ | ||
tag: 'ct', | ||
onCreate, | ||
api: { isGuest } | ||
}); | ||
|
||
export { | ||
createApiProxy, | ||
integrationPlugin | ||
}; |
Oops, something went wrong.