Skip to content

Commit

Permalink
clarify api endpoint var, polish readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
anitarua committed Aug 20, 2024
1 parent fffb27b commit 4cfa241
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 35 deletions.
22 changes: 21 additions & 1 deletion README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,33 @@ Or you can manually run each of these steps:
npm run build
```

3. Specify environment variables and deploy.
3. Specify the API_DOMAIN environment variable.

```bash
# The default is to use the API gateway URL that is provided when you deploy the backend stack.
export API_DOMAIN="default"
# Specifying your own domain name will direct your CDK stack to find an existing AWS Route53
# hosted zone in your account and create a 'chat-api' subdomain for it.
export API_DOMAIN=${API_DOMAIN:-your-chosen-domain-name.com}
```

4. Deploy your backend stack.

```bash
AWS_PROFILE=<my profile> AWS_REGION=<my region> npx cdk deploy
```

Once deployed, you can test your application using any of the client applications.

If you used the `API_DOMAIN="default"` option, you'll want to save the API gateway URL that was printed out.
This will be the base API URL you'll provide to the client applications.

```bash
Outputs:
moderated-chat-translation-api-stack.moderatedchatrestapiEndpoint23439914 = https://something.something.something.amazonaws.com/prod/
```

If you used your own API domain name, you'll provide something like `https://chat-api.your-domain-name.com` to the client applications.
{{ ossFooter }}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import kotlin.collections.HashMap
import kotlin.system.exitProcess
import kotlin.time.Duration.Companion.seconds

const val baseApiUrl = "https://chat-api.your-chosen-domain-name.com"
const val baseApiUrl = "https://your-api-endpoint.com"
var momentoApiToken: String = ""
var tokenExpiresAt: Long = 0
var topicClient: TopicClient? = null
Expand Down
6 changes: 6 additions & 0 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@ This directory contains an Android app version of the Moderated Chat demo.
## Running the example using Android Studio

1. Open the `android/ModeratedChat` directory in [Android Studio](https://developer.android.com/studio)

2. Edit the `baseApiUrl` variable to set your API endpoint.

```kotlin
const val baseApiUrl = "https://your-api-endpoint.com"
```

3. Click the run button in the top bar or choose `Run 'app'` in the `Run` menu
26 changes: 14 additions & 12 deletions flutter/moderated_chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ A Flutter version of the Momento Moderated Chat demo. It currently only has a ma

## Running the Demo

In the [lib/config.dart file](./lib/config.dart), specify the base URL for your API endpoints.
1. In the [lib/config.dart file](./lib/config.dart), specify the base URL for your API endpoints.

```dart
class Config {
static const baseUrl = "https://chat-api.your-chosen-domain-name.com";
}
```
```dart
class Config {
static const baseUrl = "https://your-api-endpoint.com";
}
```

From the flutter moderated_chat directory, call `flutter run` to start the app:
2. From the flutter moderated_chat directory, call `flutter run` to start the app:

```bash
cd flutter/moderated_chat
flutter run -d macos
```
```bash
cd flutter/moderated_chat
flutter run -d macos
```

Alternatively, you can open the project in VSCode or IntelliJ with the Flutter plugin and run the app from there.
Alternatively, you can open the project in VSCode or IntelliJ with the Flutter plugin and run the app from there.

Note: see [here](https://github.com/jonataslaw/get_cli/issues/263) if you are using Dart 3.5.0 and get an error about UnmodifiableUint8ListView.
2 changes: 1 addition & 1 deletion flutter/moderated_chat/lib/config.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Config {
static const baseUrl = "https://chat-api.your-chosen-domain-name.com";
static const baseUrl = "https://your-api-endpoint.com";
}
2 changes: 1 addition & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This directory contains a React + TypeScript + Vite web app version of the Moder
Create a `.env` file to specify the base URL for your API endpoints.

```bash
VITE_API_BASE_URL="https://chat-api.your-chosen-domain-name.com"
VITE_API_BASE_URL="https://your-api-endpoint.com"
```

Then run the web app:
Expand Down
19 changes: 11 additions & 8 deletions ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ This directory contains an iOS client of the Moderated Chat demo.

## Running the demo

Create an environment variable to specify the base URL for your API endpoints.
1. Create an environment variable to specify the base URL for your API endpoints.

```bash
API_BASE_URL="https://chat-api.your-chosen-domain-name.com"
```
To create an environment variable in Xcode, navigate to "Product" > "Scheme" > "Edit Scheme".
Select "Run" from the menu on the left, then "Arguments" along the top of that page.

```bash
API_BASE_URL="https://your-api-endpoint.com"
```

You may also need to specify a variable to enable logging output:
2. To run the app using a simulator, simply open the `ios/moderated_chat` directory as an Xcode project and click "Run".

Note: You may also need to specify a variable to enable logging output in order to avoid a `LoggingError` in the output console.

```bash
IDEPreferLogStreaming=YES
```

To run the app using a simulator, simply open the `ios/moderated_chat` directory as an Xcode project and click "Run".
```
22 changes: 11 additions & 11 deletions react-native/ModeratedChat/README.md → react-native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

## Running the example using Expo Go

Create a `.env` file in the the `react-native/ModeratedChat` directory to specify the base URL for your API endpoints.
1. Create a `.env` file in the the `react-native/ModeratedChat` directory to specify the base URL for your API endpoints.

```bash
API_BASE_URL="https://chat-api.your-chosen-domain-name.com"
```
```bash
API_BASE_URL="https://your-api-endpoint.com"
```

Then in the `react-native/ModeratedChat` directory:
2. Then in the `react-native/ModeratedChat` directory:

- run `npm install`
- run `npx expo start`
- run the app on your phone:
- scan QR Code with your phone to open it in the Expo Go app
- or run the app on an emulator:
- launch one of the device emulators as described in the instructions displayed after you start the Expo server
- run `npm install`
- run `npx expo start`
- run the app on your phone:
- scan QR Code with your phone to open it in the Expo Go app
- or run the app on an emulator:
- launch one of the device emulators as described in the instructions displayed after you start the Expo server

## Polyfills

Expand Down

0 comments on commit 4cfa241

Please sign in to comment.