protoschool.github.io icon indicating copy to clipboard operation
protoschool.github.io copied to clipboard

Unify data access within codebase

Open zebateira opened this issue 4 years ago • 0 comments

(This is an internal improvement)

The problem

The current way to access data is by using the src/utils/tutorials.js util (same for projects and courses). But this can only be used within the vue application code. In Node Js scenarios (scripts or vue bootup like vue.config.js), we are using a new api (src/api). These two approaches have the same functionality replicated.

Solution

I propose making the API universally accessible. Considering the API has file system operations, I propose the following approach: Communicate the data through json files.

On build time:

  • Read data from static json files (static/tutorials.json, etc)
  • Enhance the data (add lessons array to each tutorial, for example)
  • Write new enhanced data into an uncommitted json file (some sort of cache)

Data access (vue application):

  • Read data only from the new enhanced data json files

Scripts and other node js scenarios:

  • Handle raw data directly

Other notes

Another idea would be to have an extra webpack step to compile the api js code, but considering the different use cases for the API, the above solution seems to be a better one.

zebateira avatar Jan 11 '21 16:01 zebateira