Example code
To quickly get things started we have created an example-app and an example-server. This will allow you to browse, view and configure your catalogue data.
tip
If you are using Public AccessTokens you will not need the example-server.
Prerequisite
First, let’s make sure that your development environment is ready.
- Make sure you have Node.js installed
- You’ll need Node.js version 10.X or later, but we recommend 12.X.
- Make sure you have Yarn installed.
- Don't forget to do the "Path Setup" part if you are on Linux / macOS.
- You'll need Yarn 1. Currently it's not compatible with Yarn 2 or later.
To manage our packages we use Lerna, which is a tool that optimizes the workflow around managing multi-package repositories with git and npm.
yarn global add lerna
The code for our Example App and Example Server is hosted in a GitLab repository, so you'll need to clone it. Please note that this is private repository and is invite only.
git clone git@git.configura.com:web/rnd/cfg-web-sdk.git
cd cfg-web-sdk
Before starting the app you'll need to install all dependencies and build our packages.
lerna bootstrap
lerna run build --stream --ignore='@configura/web-sdk-docs' --ignore='@configura/example-*' --ignore='@configura/test-app'
Get started
- With Public AccessToken
- With Private AccessToken
To use Public AccessToken you need to modify the useAuth.ts
file in the example-app. Set the PUBLIC_ACCESS_TOKEN
constant to your Public AccessToken ID.
Once the useAuth.ts
file has been modified and saved it is time to start the Example App.
- Bash
- PowerShell
lerna run start --scope='@configura/example-app'
lerna run start --scope='@configura/example-app'
Now it's time to start our Example App and Example Server. When running this command you'll need to provide your Private AccessToken to be able to access your catalogue data.
- Bash
- PowerShell
CATALOGUE_API_ACCESS_TOKEN="Your AccessToken here" lerna run start --stream --parallel --scope='@configura/example-app' --scope='@configura/example-server'
$env:CATALOGUE_API_ACCESS_TOKEN="Your AccessToken here"; lerna run start --stream --parallel --scope='@configura/example-app' --scope='@configura/example-server'
Running test app
We have developed a test tool where you can step through all products in your catalogues. To run the test app add --scope='@configura/test-app'
to the lerna run start
command.
If you run with Public AccessTokens you will need to modify useAuth.ts in the test-app in the same way as for the Example App.
Running documentation locally
If you want to run this documentation locally you can do so by adding --scope='@configura/web-sdk-docs'
to the lerna run start
command.