stepzen-dev / stepzen-nuxt

2 stars 7 forks source link

Create `.env.sample` for environment variables #1

Closed ajcwebdev closed 3 years ago

ajcwebdev commented 3 years ago

File will have the format:

STEPZEN_API_KEY={{STEPZEN_API_KEY}}
STEPZEN_ENDPOINT={{STEPZEN_ENDPOINT}}

Also include instructions in the README.md for creating your own for local development with:

cp .env.sample .env
virtuoushub commented 3 years ago

🌊 Hello, I will claim this issue.

I ran into having to do this step when setting up the project just now and I have a couple suggestions to speed up onboarding.

  1. Check-in a stepzen.config.json that looks similar to:
{
  "endpoint": "api/stepzen-nuxt-tutorial",
  "root": "stepzen/schema"
}
  1. Update components/NuxtMountains.vue to use the variables read from the .env file
...
      this.mountains = await fetch(
        `${process.env.REACT_APP_STEPZEN_ENDPOINT}`,
        {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
            'Authorization': `apikey ${process.env.REACT_APP_STEPZEN_API_KEY}`
          },
...

@ajcwebdev - any comments/concerns w/ this approach?

ajcwebdev commented 3 years ago

Looks good, thanks a lot @virtuoushub 👍

Merged https://github.com/stepzen-samples/stepzen-nuxt/pull/10