luanvdw / pulse-starter

A starter project to get you up and running with pulse.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pulse Starter Example

Getting started

Be sure to have the following set up before using this project. Check the docs for more information.

  • A database with the following configuration
    • Postgres version 12+
    • Ensure your database is publicly accessible
    • Enable logical replication on your database
    • A database superuser that can be used for connections inside Pulse
  • An invitation to Pulse's Early Access program.
  • A Pulse Cloud Projects API key

Download and install dependencies

Clone this repository:

git clone https://github.com/prisma/pulse-starter.git

Install dependencies:

cd pulse-starter
npm i

Configure your project

Create your .env file:

cp .env.example .env

Open your new .env file and set your two variables:

DATABASE_URL=""
PULSE_API_KEY=""

Run prisma migrate:

npx prisma migrate dev --name init

Run this example

To run a Pulse subscription, execute the index.ts file. This file contains multiple function calls, each with comments explaining their purpose. Feel free to use these to test different subscriptions.

npx ts-node index.ts

ℹ️ Note: that you can only run one subscription per file. Therefore, do not uncomment more than one call, as it will cause the code to break.

In a seperate terminal run prisma studio and create a user:

npx prisma studio

Create a user

Add a user row

If you are running the userCreateSub() function in the index.ts file you should see the following output in your termainl where you ran npx ts-node index.ts

just received a user create event: {
  action: 'create',
  after: {
    id: 1,
    email: 'marc@pulseiscool.io',
    name: 'Marc'
  }
}

Learn more about Pulse

About

A starter project to get you up and running with pulse.


Languages

Language:TypeScript 100.0%