Skip to content

Commit

Permalink
fix(example): fix deployment of websocket example (#3427)
Browse files Browse the repository at this point in the history
  • Loading branch information
KATT committed Dec 19, 2022
1 parent a104f19 commit f1d3f05
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
24 changes: 11 additions & 13 deletions examples/next-prisma-websockets-starter/README.md
@@ -1,10 +1,6 @@
# Prisma + tRPC + WebSockets

> ℹ️ WebSockets is a beta feature & may change without major version bump ℹ️

- Try demo http://websockets.trpc.io/

Try demo http://websockets.trpc.io/

## Features

Expand Down Expand Up @@ -35,6 +31,8 @@ yarn dx

The project contains a [`render.yaml`](./render.yaml) [*"Blueprint"*](https://render.com/docs/blueprint-spec) which makes the project easily deployable on [Render](https://render.com/).

The database is setup with a `starter` plan, but you can use a free plan for 90 days.

Go to [dashboard.render.com/blueprints](https://dashboard.render.com/blueprints) and connect to this Blueprint and see how the app and database automatically gets deployed.

You will either need to create an environment group called `trpc-websockets` with environment variables or remove that from `render.yaml` in favor of manual environment variables that overrides the ones in `/.env`.
Expand Down Expand Up @@ -67,14 +65,14 @@ You will either need to create an environment group called `trpc-websockets` wit
## Commands

```bash
yarn build # runs `prisma generate` + `prisma migrate` + `next build`
yarn db-nuke # resets local db
yarn dev # starts next.js + WebSocket server
yarn dx # starts postgres db + runs migrations + seeds + starts next.js
yarn test-dev # runs e2e tests on dev
yarn test-start # runs e2e tests on `next start` - build required before
yarn test:unit # runs normal jest unit tests
yarn test:e2e # runs e2e tests
pnpm build # runs `prisma generate` + `prisma migrate` + `next build`
pnpm db-nuke # resets local db
pnpm dev # starts next.js + WebSocket server
pnpm dx # starts postgres db + runs migrations + seeds + starts next.js
pnpm test-dev # runs e2e tests on dev
pnpm test-start # runs e2e tests on `next start` - build required before
pnpm test:unit # runs normal jest unit tests
pnpm test:e2e # runs e2e tests
```
---

Expand Down
4 changes: 4 additions & 0 deletions examples/next-prisma-websockets-starter/package.json
Expand Up @@ -2,6 +2,10 @@
"name": "@examples/next-websockets-starter",
"version": "10.5.0",
"private": true,
"engines": {
"node": "^18.0.0"
},
"packageManager": "pnpm@7.18.2",
"scripts": {
"build:1-generate": "prisma generate",
"build:2-migrate": "prisma migrate deploy",
Expand Down
11 changes: 9 additions & 2 deletions examples/next-prisma-websockets-starter/render.yaml
@@ -1,11 +1,17 @@
previewsEnabled: true
previewsExpireAfterDays: 7 # automatically delete the environment after the specified number of days of inactivity
services:
- type: web
name: trpc-websockets
env: node
plan: free
buildCommand: pnpm install && pnpm build
# NODE_ENV is development here in order for pnpm to install dev deps
buildCommand: NODE_ENV=development pnpm install && pnpm build
startCommand: pnpm start
healthCheckPath: /api/trpc/healthcheck
# Preview Environment Initialization
# initialDeployHook: |
# pnpm run db-seed
envVars:
- key: NODE_ENV
value: production
Expand All @@ -19,4 +25,5 @@ services:

databases:
- name: trpc-websockets-db
plan: free
plan: starter
# plan: free
Expand Up @@ -25,6 +25,7 @@ declare interface MyEventEmitter {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
class MyEventEmitter extends EventEmitter {}

// In a real app, you'd probably use Redis or something
const ee = new MyEventEmitter();

// who is currently typing, key is `name`
Expand Down
4 changes: 0 additions & 4 deletions www/docs/further/subscriptions.md
Expand Up @@ -5,10 +5,6 @@ sidebar_label: Subscriptions / WebSockets
slug: /subscriptions
---

:::info
Subscriptions & WebSockets are in beta & might change without a major version bump. However, feel free to use them and report any issue you may find on [GitHub](https://github.com/trpc/trpc).
:::

## Using Subscriptions

:::tip
Expand Down

3 comments on commit f1d3f05

@vercel
Copy link

@vercel vercel bot commented on f1d3f05 Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

www – ./www

www-git-main-trpc.vercel.app
www-trpc.vercel.app
trpc.io
beta.trpc.io
alpha.trpc.io
www.trpc.io

@vercel
Copy link

@vercel vercel bot commented on f1d3f05 Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

og-image – ./www/og-image

og-image-trpc.vercel.app
og-image.trpc.io
og-image-git-main-trpc.vercel.app
og-image-three-neon.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f1d3f05 Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

next-prisma-starter – ./examples/next-prisma-starter

next-prisma-starter-git-main-trpc.vercel.app
nextjs.trpc.io
next-prisma-starter-trpc.vercel.app

Please sign in to comment.