-
Notifications
You must be signed in to change notification settings - Fork 337
Conversation
- The `db` context object - passed to every api endpoint now has two usefull methods: `getElasticClient` and `getRedisClient` for accesing the data stores - @pkarw (#328) - The `lib/utils` got two new methods `getStoreCode(req: Express.Request)` and `getStoreView(code: string)` for getting the current multistore context from `vue-storefront` frontend requests - @pkarw - The way Elastic and Redis clients have been fixed and code duplication removed across the app - @pkarw (#327)
*/ | ||
export function getCurrentStoreView (storeCode = null) { | ||
if (storeCode && config.storeViews[storeCode]) { | ||
storeView = config.storeViews[storeCode] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't we returning the storeView here?
For me it looks like a bug here and the default that we return looks bad to in my eyes. Here we should do it like we do in prepareStoreView in the frontend.
let storeView = { // current, default store
tax: config.tax,
i18n: config.i18n,
elasticsearch: config.elasticsearch,
storeCode: null,
storeId: config.defaultStoreCode && config.defaultStoreCode !== '' ? config.storeViews[config.defaultStoreCode].storeId : 1
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks fixed
One small improvment so we don't have every where the This would then need this in the tsconfig.json. "paths": {
"@lib": "src/lib/*"
} But to clean it up for the future I would add: "paths": {
"@src": "src/*",
"@lib": "src/lib/*"
} With that we could clean up our imports. |
db
context object - passed to every api endpoint now has two usefull methods:getElasticClient
andgetRedisClient
for accesing the data stores - @pkarw (Get rid of initializeDb or fix it #328)lib/utils
got two new methodsgetStoreCode(req: Express.Request)
andgetStoreView(code: string)
for getting the current multistore context fromvue-storefront
frontend requests - @pkarw