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

Get rid of initializeDb or fix it #328

Closed
pkarw opened this issue Aug 21, 2019 · 0 comments
Closed

Get rid of initializeDb or fix it #328

pkarw opened this issue Aug 21, 2019 · 0 comments
Assignees
Labels
feature request Requests for new features. Please be as specific as possible

Comments

@pkarw
Copy link
Contributor

pkarw commented Aug 21, 2019

Related to #327
Wev'e got pretty cool feature of passing the db object to any middleware in the api: https://github.com/DivanteLtd/vue-storefront-api/blob/589bb876fd32077124f82d7e0ded67d440ff7129/src/index.ts#L35-L36

... which is not being used because initializeDb does nothing.
Would be super cool to pass something like:

db.redisClient
db.elasticClient

or maybe safer:

db.getRedisClient()
db.getElasticClient() - to make sure that initializeDb is not connecting/executing any queries on it's own; it should be lazy connected as most of the endpoints doesn't really need any connection to Redis and Elasitc in the end ..

@pkarw pkarw added the feature request Requests for new features. Please be as specific as possible label Aug 21, 2019
pkarw added a commit that referenced this issue 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 (#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)
@pkarw pkarw mentioned this issue Aug 21, 2019
@pkarw pkarw closed this as completed Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request Requests for new features. Please be as specific as possible
Projects
None yet
Development

No branches or pull requests

2 participants