{"id":19683878,"url":"https://github.com/prisma/pulse-starter","last_synced_at":"2025-04-29T05:31:32.695Z","repository":{"id":185422130,"uuid":"673523672","full_name":"prisma/pulse-starter","owner":"prisma","description":"A Pulse starter project. To be used inside of a railway.app template, locally, or with another Pulse-ready database.","archived":false,"fork":false,"pushed_at":"2024-06-03T13:02:58.000Z","size":72,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":12,"default_branch":"main","last_synced_at":"2024-06-03T15:06:49.154Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prisma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-01T20:31:54.000Z","updated_at":"2024-06-03T15:06:51.879Z","dependencies_parsed_at":null,"dependency_job_id":"9f56ec58-868e-4b43-91fe-5d98f3415f72","html_url":"https://github.com/prisma/pulse-starter","commit_stats":null,"previous_names":["prisma/pulse-railway-starter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fpulse-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fpulse-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fpulse-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fpulse-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prisma","download_url":"https://codeload.github.com/prisma/pulse-starter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224151098,"owners_count":17264436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T18:15:57.630Z","updated_at":"2024-11-11T18:15:57.702Z","avatar_url":"https://github.com/prisma.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prisma Pulse starter project\n\nThis repository has been created to help you get started with [Pulse](https://prisma.io/pulse). You will be able to use this project with any Pulse-ready PostgreSQL database. This project comes with a basic [`schema.prisma`](./prisma/schema.prisma) file as well as a Pulse subscription found in the [`index.ts`](./index.ts) file.\n\n## Prerequisites\n\nTo successfully run the project, you will need the following:\n\n- The **connection string** of a Pulse-compatible database (if you don't have one yet, you can configure your database following the instructions in our [docs](https://www.prisma.io/docs/pulse/database-setup) or [use a Railway template](https://railway.app/template/pulse-pg?referralCode=VQ09uv))\n- A **Pulse API key** which you can get by enabling Pulse in a project in your [Prisma Data Platform](https://pris.ly/pdp) account\n  \n## Getting started\n\n### 1. Clone the respository\n\nClone the repository, navigate into it and install dependencies:\n\n```bash\ngit clone https://github.com/prisma/pulse-starter.git\ncd pulse-starter\nnpm install\n```\n\n### 2. Create and fill out a `.env` file\n\nRename the existing `.env.example` to `.env`:\n\n```bash\nmv .env.example .env\n```\n\nNow go into the `.env` file and update the `DATABASE_URL` and `PULSE_API_KEY` environment variables:\n\n```bash\nDATABASE_URL=\"postgres://postgres:password@host:PORT/database_name\" \nPULSE_API_KEY=\"your_secure_pulse_api_key\"\n```\n\n- `DATABASE_URL`: The connection string to your database.\n- `PULSE_API_KEY`: Reference the [Environment API Keys](https://www.prisma.io/docs/platform/concepts/environments#api-keys) section in our documentation to learn how get an API key for your Pulse project.\n\n### 3. Run the database migration\n\nThe `prisma/schema.prisma` contains three models based on our [hello-prisma](https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/using-prisma-migrate-typescript-postgresql) example project:\n\n```bash\nnpx prisma migrate dev --name init\n```\n\n### 4. Start the Pulse subscription\n\nRun the [script](./index.ts) that contains the code to subscribe to database events:\n\n```bash\nnpx ts-node index.ts\n```\n\nThis will run a basic subscription on the `User` table. The code can be found in the [`index.ts`](./index.ts) file. To learn more about the Pulse API and how to use it, check out our [documentation](https://www.prisma.io/docs/data-platform/pulse/api-reference#subscribe).\n\n\u003cdetails\u003e\u003csummary\u003ePulse user table subscription\u003c/summary\u003e\n\n```ts\nasync function main() {\n  const subscription = await prisma.user.stream();\n\n  if (subscription instanceof Error) {\n    throw subscription;\n  }\n\n  for await (const event of subscription) {\n    console.log(\"just received an event:\", event);\n  }\n}\n```\n\n\u003c/details\u003e\n\n### 5. Test the subscription\n\nThe following instructions uses [Prisma Studio](https://www.prisma.io/studio) to create a new record in the `User` table. However, you can use any other method to write to the `User` table (e.g. a SQL client like `psql` or [TablePlus](https://tableplus.com/)) in order to trigger a database change event in Pulse.\n\n1. Start Prisma Studio in a new terminal: `npx prisma studio`\n2. Add a new record to the `User` table from Prisma Studio.\n3. Return to your terminal where you ran the `npx ts-node index.ts` command.\n4. If everything is set up properly you will see an output that is similar to the following.\n\n    ```json\n    {\n      \"action\": \"create\",\n      \"created\": {\n        \"id\": 1,\n        \"email\": \"test@prisma.io\",\n        \"name\": \"test\"\n      }\n    }\n    ```\n\n## Deployment\n\nYou can also deploy this project on Railway by following the instructions in our [docs](https://www.prisma.io/docs/pulse/database-setup/railway#setup-with-template-prisma-pulse-db--app).\n\n[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/pulse-starter?referralCode=VQ09uv)\n\n## Resources\n\n- [Prisma Pulse examples](https://pris.ly/pulse-examples)\n- [Pulse documentation](https://pris.ly/pulse-docs)\n- [Pulse GA announcement blog post](https://pris.ly/gh/pulse-ga)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fpulse-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprisma%2Fpulse-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fpulse-starter/lists"}