Skip to content

Latest commit

 

History

History
 
 

README.md

Saleor App Twilio Segment

Local development setup

Prerequisites

Running app locally in development containers

Important

You can use the devcontainer Dockerfile and docker-compose.yaml directly - but remember to run pnpm install and pnpm setup-dynamodb manually

The easiest way to run Saleor for local development is to use development containers. If you have Visual Studio Code, follow their guide on how to open an existing folder in a container.

The development container only creates a container; you still need to start the server.

The development container will have two ports opened:

  1. 3000 - where the app dev server will listen for requests
  2. 8000 - where the local DynamoDB will listen for requests and allow NoSQL Workbench for DynamoDB to connect

Running app in development mode

  1. Install the dependencies by running the following command in the shell:
pnpm install
  1. Create a file named .env and use the contents of the .env.example file as a reference.

  2. Start the development server by running the following command in the shell:

pnpm dev
  1. App will be available under http://localhost:3000

Note

To install app in Saleor Cloud, you need to expose your local server to the internet (tunnel). You can use Saleor CLI to do that. See this guide for more details.

  1. Install app on the Saleor dashboard.
  2. After installation, configure the app as follows:
    • Paste writeKey into app configuration form

Webhook migration scripts

Note

This section refers to apps hosted by Saleor or using REST APL. If you self host AvaTax app you need to write your own logic for updating migration scripts. See [How to update app webhooks](https://docs.saleor.io/developer/extending/apps/updating-app-webhooks for more info.

You need to set REST_APL_TOKEN & REST_APL_ENDPOINT in our .env file first.

Test migration with dry run, operation will not modify any data:

pnpm migrate:dry-run

To start the migration run command:

pnpm migrate

Setting up DynamoDB

Segment app uses DynamoDB as it's internal database.

In order to work properly you need to either set-up local DynamoDB instance or connect to a real DynamoDB on AWS account.

Local DynamoDB

To use a local DynamoDB instance you can use Docker Compose:

docker compose up

After that a local DynamoDB instance will be spun-up at http://localhost:8000.

To set up tables needed for the app run following command for each table used in app:

pnpm setup-dynamodb

After setting up database, you must configure following variables:

DYNAMODB_MAIN_TABLE_NAME=segment-main-table
AWS_REGION=localhost
AWS_ENDPOINT_URL=http://localhost:8000
AWS_ACCESS_KEY_ID=fake_id
AWS_SECRET_ACCESS_KEY=fake_key

Local instance doesn't require providing any authentication details.

To see data stored by the app you can use NoSQL Workbench app provided by AWS. After installing the app go to Operation builder > Add connection > DynamoDB local and use the default values.

Production DynamoDB

To configure DynamoDB for production usage, provide credentials in a default AWS SDK format (see AWS Docs)

DYNAMODB_MAIN_TABLE_NAME=segment-main-table
AWS_REGION=us-east-1 # Region when DynamoDB was deployed
AWS_ACCESS_KEY_ID=AK...
AWS_SECRET_ACCESS_KEY=...

OTEL

Visit @saleor/apps-otel README to learn how to run app with OTEL locally.