Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

#327 and #328 #330

Closed
wants to merge 1 commit into from
Closed

#327 and #328 #330

wants to merge 1 commit into from

Conversation

pkarw
Copy link
Contributor

@pkarw pkarw commented Aug 21, 2019

  • The db context object - passed to every api endpoint now has two usefull methods: getElasticClient and getRedisClient for accesing the data stores - @pkarw (Get rid of initializeDb or fix it #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 (Refactor the way Elastic client is being setup #327)

- 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)
src/lib/elastic.js Show resolved Hide resolved
src/lib/redis.js Show resolved Hide resolved
src/lib/util.js Show resolved Hide resolved
*/
export function getCurrentStoreView (storeCode = null) {
if (storeCode && config.storeViews[storeCode]) {
storeView = config.storeViews[storeCode]
Copy link
Collaborator

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
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks fixed

@ResuBaka
Copy link
Collaborator

ResuBaka commented Aug 31, 2019

One small improvment so we don't have every where the .../../../util as example we could use the paths config in tsconfig.json in the compilerOptions. So we can use it for example "@lib/util"

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.

@pkarw
Copy link
Contributor Author

pkarw commented Sep 15, 2019

Thanks @ResuBaka for CR; I will take care of the changes next week by doing #342

@pkarw
Copy link
Contributor Author

pkarw commented Sep 17, 2019

@ResuBaka thanks for your insights; unfortunately tsconfig paths won't work with *.js files :/
I've applied changes to #342; closing tthis one in favor of #342

@pkarw pkarw closed this Sep 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants