prezly / theme-nextjs-bea

News site built with NextJS, Typescript and Prezly SDK
https://theme-nextjs-bea-the-good-newsroom.vercel.app
MIT License
44 stars 11 forks source link

Environment variables usage #150

Open e1himself opened 2 years ago

e1himself commented 2 years ago

I've noticed that the theme app requires environment variables in order to properly function (at least locally), but the variables themselves are never used within this repo codebase at all. All the usages are actually in the theme-kit package.

I believe this breaks the separation of concerns principle. I cannot modify this theme to do something else with the env variables, or to instantiate the Prezly API client with my own local dev API endpoint.

It would be better if the outsourced theme-kit code was providing entry points expecting the required inputs (like tokens/env variables, or an instantiated API Client instance) and then performed its job.

Of course, this is by all means, not a critical problem. Just something rather good to have.

riffbyte commented 2 years ago

I cannot modify this theme to do something else with the env variables, or to instantiate the Prezly API client with my own local dev API endpoint.

Actually, you can do both of these things :)

I agree that this abstraction might not be the best in terms of intuitiveness, but it does help to reduce the boilerplate. The env variables needed to run the theme locally are documented both in the Theme Kit and the theme repos, so I don't see this as a big problem, at least for now.