Skip to content

Commit 0ddb7ec

Browse files
Add streaming example (#145)
* Add streaming example * Update ts/streaming/frontend/src/components/StreamOutExample.tsx Co-authored-by: Fredrik Enestad <[email protected]> * Add new build --------- Co-authored-by: Fredrik Enestad <[email protected]>
1 parent 37314fc commit 0ddb7ec

36 files changed

+4684
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ environment. Use the appropriate command for your system:
5353
|------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
5454
| [ts/hello-world](ts/hello-world) | REST API Starter | APIs |
5555
| [ts/ai-chat](ts/ai-chat) | LLM chat application which let's you create and chat with personalized bots. Integrates with OpenAI, Anthropic and Slack | Microservices, APIs, SQL Database, Pub/Sub, External Requests, Configs |
56-
| [ts/streaming-chat](ts/streaming-chat) | Simple Chat app using the Streaming API to create a WebSocket stream | Streaming API, Static Endpoint, Frontend |
56+
| [ts/streaming](ts/streaming) | Examples of the different WebSocket Streaming APIs | Streaming API, Static Endpoint, Frontend |
57+
| [ts/streaming-chat](ts/streaming-chat) | Simple Chat app using the Streaming API to create a WebSocket stream | Streaming API, Static Endpoint, Frontend |
5758
| [ts/simple-event-driven](ts/simple-event-driven) | Simple Event-Driven Application | Microservices, SQL Database, Pub/Sub, Secrets |
5859
| [ts/uptime](ts/uptime) | Event-Driven Architecture Starter (Uptime Monitor) | Microservices, SQL Databases, Pub/Sub, Cron Jobs |
5960
| [ts/gpt-functions](ts/gpt-functions) | ChatGPT Functions with Encore Example | APIs |

ts/streaming-chat/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ encore app create --example=ts/streaming-chat
2727
encore run
2828
```
2929

30-
While `encore run` is running, open <http://localhost:4000/> to view the chat frontend.
30+
While `encore run` is running, open <http://localhost:4000/> to view the chat frontend. Open <http://localhost:4000/> in multiple tabs to see the chat in action.
3131

3232
You can also access Encore's [local developer dashboard](https://encore.dev/docs/observability/dev-dash) on <http://localhost:9400/> to view traces, API documentation, and more.
3333

ts/streaming/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.encore
2+
encore.gen.go
3+
encore.gen.cue
4+
/.encore
5+
node_modules
6+
/encore.gen

ts/streaming/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Encore.ts Streaming Examples
2+
3+
This example showcases the different streaming APIs in Encore.ts: `api.streamIn`, `api.streamOut`, and `api.streamInOut`.
4+
5+
Learn more in our [Streaming API docs](https://encore.dev/docs/ts/primitives/streaming-apis)
6+
7+
## Developing locally
8+
### Prerequisite: Installing Encore
9+
10+
If this is the first time you're using Encore, you first need to install the CLI that runs the local development
11+
environment. Use the appropriate command for your system:
12+
13+
- **macOS:** `brew install encoredev/tap/encore`
14+
- **Linux:** `curl -L https://encore.dev/install.sh | bash`
15+
- **Windows:** `iwr https://encore.dev/install.ps1 | iex`
16+
17+
When you have installed Encore, run to clone this example:
18+
19+
```bash
20+
encore app create --example=ts/streaming
21+
```
22+
23+
## Running locally
24+
```bash
25+
encore run
26+
```
27+
28+
While `encore run` is running, open <http://localhost:4000/> to view the frontend which has different pages for showcasing the different streaming endpoints.
29+
30+
You can also access Encore's [local developer dashboard](https://encore.dev/docs/observability/dev-dash) on <http://localhost:9400/> to view traces, API documentation, and more.
31+
32+
In you change the frontend then run `npm run build` to build a new frontend in the `dist` folder.
33+
34+
## Deployment
35+
36+
Deploy your application to a staging environment in Encore's free development cloud:
37+
38+
```bash
39+
git add -A .
40+
git commit -m 'Commit message'
41+
git push encore
42+
```
43+
44+
Then head over to the [Cloud Dashboard](https://app.encore.dev) to monitor your deployment and find your production URL.
45+
46+
From there you can also connect your own AWS or GCP account to use for deployment.
47+
48+
Now off you go into the clouds!

ts/streaming/encore.app

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"id": "",
3+
"lang": "typescript"
4+
}

ts/streaming/frontend/dist/assets/index-30da2f4a.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)