Skip to content

Commit

Permalink
docs: added full list of environement credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivelin Ivanov authored Jun 15, 2021
2 parents 6067d3d + f074e41 commit 3d9c15b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Run the semantic-release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Code Coverage Report
Expand Down
73 changes: 65 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,83 @@ The image below shows the architecture of these serverless functions in connecti

## Running Locally

The serverless functions within this project are managed using [netlify-dev](https://www.netlify.com/products/dev/). Start the functions emulator from the `netlify` directory using `yarn netlify-dev` to listen for requests to any of created functions on port `5050`.
The serverless functions within this project are managed using [netlify-dev](https://www.netlify.com/products/dev/).
Start the function emulator using `yarn netlify-dev` command to handle any HTTP request made to any of the created functions on port `5050`.

Credentials within this project are managed using environment variables and [GitHub Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets). To run the functions here locally using the `netlify dev` command, create a `.env` file in the root directory with the following values;
Service credentials used within the serverless functions in this project are loaded as environment variables using [dotenv](https://www.npmjs.com/package/dotenv).
Before executing the `netlify dev` command, create a `.env` file in the root directory with the following values to store the needed credentials;

**Note:** It is recommended to test the Stripe integration in a test mode using [Test API Keys ](https://stripe.com/docs/keys#test-live-modes) from Stripe.

```
# Access key from Stripe to access your Stripe resources
STRIPE_KEY=STRIPE_KEY
# The product ID which users are subscribed to.
EMAIL_PRODUCT_ID=STRIPE_KEY
# The ID of the email price product used in billing subscribers.
EMAIL_PRODUCT_PRICE_ID=EMAIL_PRODUCT_PRICE_ID
# Your Auth0 Domain
AUTHO_DOMAIN=AUTHO_DOMAIN
# Auth0 Management Application Client ID
MGT_CLIENT_ID=MGT_CLIENT_ID
# Auth0 Management Application Client Secret
MGT_CLIENT_SECRET=MGT_CLIENT_SECRET
# Email SMTP host
SMTP_HOST=SMTP_HOST
# Email SMTP Password
SMTP_PASSWORD=SMTP_PASSWORD
# Email Sender Address
SMTP_SENDER=SMTP_SENDER
# Email SMTP Username
SMTP_USERNAME=SMTP_USERNAME
```

## CI / CD Pipeline

All serverless function endpoints within this Cloud API all tested using [Postman Tests](https://www.postman.com/automated-testing/). The API documentation explaining the endpoints can be found in the GitHub pages for this repository [here](https://ambianic.github.io/ambianic-subscriptions.github.io/). An exported file of the postman collection in json format is available at `./tests/postman/ambianic-functions-collection.postman_collection.json`.

The three currently available serverless function endpoints are all tested using [Postman Tests](https://www.postman.com/automated-testing/). The API documentation explaining the endpoints can be found in the GitHub pages for this repository [here](https://ambianic.github.io/ambianic-subscriptions.github.io/). An exported file of the postman collection in json format is available at `./tests/postman/ambianic-functions-collection.postman_collection.json`.

Continuous integration for this project is managed using [GitHub Actions](https://github.com/features/actions), driven using the steps in the `.github/workflows/ci.yaml` file. The following sensitive credentials used within the CI jobs are managed using [Github Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets);
Continuous integration for this project is managed using [GitHub Actions](https://github.com/features/actions), driven using the steps in the `.github/workflows/ci.yaml` file.
The following sensitive credentials are used within the CI jobs are stored using [Github Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) and are retrieved and used within each workflow build;

- STRIPE_KEY
- GITHUB_TOKEN
- NPM_TOKEN
- REPOSITORY_ACCESS_TOKEN

## Cloud Deployment
All serverless functions within this project were designed to be deployed and executed as [Netlify Functions](https://www.netlify.com/products/functions/).
The following environment variables used within the serverless functions, and should be added in your application's [Build Environment Variables](https://docs.netlify.com/configure-builds/environment-variables/) when the project is deployed to [Netlify](https://www.netlify.com).

```
# Access key from Stripe to access your Stripe resources
STRIPE_KEY=STRIPE_KEY
# The ID of the email price product used in billing subscribers.
EMAIL_PRODUCT_PRICE_ID=EMAIL_PRODUCT_PRICE_ID
# Your Auth0 Domain
AUTHO_DOMAIN=AUTHO_DOMAIN
# Auth0 Management Application Client ID
MGT_CLIENT_ID=MGT_CLIENT_ID
# Auth0 Management Application Client Secret
MGT_CLIENT_SECRET=MGT_CLIENT_SECRET
# Email SMTP host
SMTP_HOST=SMTP_HOST
# Email SMTP Password
SMTP_PASSWORD=SMTP_PASSWORD
# Email Sender Address
SMTP_SENDER=SMTP_SENDER
# Email SMTP Username
SMTP_USERNAME=SMTP_USERNAME
```
2 changes: 1 addition & 1 deletion netlify/functions/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports.handler = async (
customer: customerID,
items: [
{
price: process.env.EMAIL_PRODUCT_ID,
price: process.env.EMAIL_PRODUCT_PRICE_ID,
},
],
})
Expand Down

0 comments on commit 3d9c15b

Please sign in to comment.