Skip to content

Commit 9437c7e

Browse files
committed
Merge remote-tracking branch 'origin/main' into checkpoint-cleanup
2 parents 6ecf4ac + f154fcc commit 9437c7e

File tree

4 files changed

+201
-57
lines changed

4 files changed

+201
-57
lines changed

docs/guides/examples/ffmpeg-video-processing.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const ffmpegCompressVideo = task({
132132
});
133133
```
134134

135-
### Testing
135+
### Testing your task
136136

137137
To test this task, use this payload structure:
138138

@@ -241,7 +241,7 @@ export const ffmpegExtractAudio = task({
241241
});
242242
```
243243

244-
### Testing
244+
### Testing your task
245245

246246
To test this task, use this payload structure:
247247

@@ -351,7 +351,7 @@ export const ffmpegGenerateThumbnail = task({
351351
});
352352
```
353353

354-
## Testing your task
354+
### Testing your task
355355

356356
To test this task in the dashboard, you can use the following payload:
357357

@@ -361,4 +361,4 @@ To test this task in the dashboard, you can use the following payload:
361361
}
362362
```
363363

364-
<LocalDevelopment packages={"ffmpeg"} />
364+
<LocalDevelopment packages={"ffmpeg"} />

docs/guides/examples/supabase-database-operations.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export const supabaseUpdateUserSubscription = task({
181181
sure you have the correct permissions set up for your project.
182182
</Note>
183183

184-
## Testing your task
184+
### Testing your task
185185

186186
To test this task in the [Trigger.dev dashboard](https://cloud.trigger.dev), you can use the following payload:
187187

docs/guides/frameworks/prisma.mdx

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
---
2+
title: "Prisma setup guide"
3+
sidebarTitle: "Prisma"
4+
description: "This guide will show you how to setup Prisma with Trigger.dev"
5+
icon: "Triangle"
6+
---
7+
8+
import Prerequisites from "/snippets/framework-prerequisites.mdx";
9+
import CliInitStep from "/snippets/step-cli-init.mdx";
10+
import CliDevStep from "/snippets/step-cli-dev.mdx";
11+
import CliRunTestStep from "/snippets/step-run-test.mdx";
12+
import CliViewRunStep from "/snippets/step-view-run.mdx";
13+
import UsefulNextSteps from "/snippets/useful-next-steps.mdx";
14+
15+
## Overview
16+
17+
This guide will show you how to set up Prisma with Trigger.dev, test and view an example task run.
18+
19+
## Prerequisites
20+
21+
- An existing Node.js project with a `package.json` file
22+
- Ensure TypeScript is installed
23+
- A [PostgreSQL](https://www.postgresql.org/) database server running locally, or accessible via a connection string
24+
- Prisma ORM [installed and initialized](https://www.prisma.io/docs/getting-started/quickstart) in your project
25+
- A `DATABASE_URL` environment variable set in your `.env` file, pointing to your PostgreSQL database (e.g. `postgresql://user:password@localhost:5432/dbname`)
26+
27+
## Initial setup
28+
29+
<Steps>
30+
<CliInitStep />
31+
<CliDevStep />
32+
<CliRunTestStep />
33+
<CliViewRunStep />
34+
</Steps>
35+
36+
## Creating a task using Prisma and deploying it to production
37+
38+
<Steps>
39+
<Step title="Writing the Prisma task">
40+
41+
First, create a new task file in your `trigger` folder.
42+
43+
This is a simple task that will add a new user to the database.
44+
45+
<Note>
46+
For this task to work correctly, you will need to have a `user` model in your Prisma schema with
47+
an `id` field, a `name` field, and an `email` field.
48+
</Note>
49+
50+
```ts /trigger/prisma-add-new-user.ts
51+
import { PrismaClient } from "@prisma/client";
52+
import { task } from "@trigger.dev/sdk/v3";
53+
54+
// Initialize Prisma client
55+
const prisma = new PrismaClient();
56+
57+
export const addNewUser = task({
58+
id: "prisma-add-new-user",
59+
run: async (payload: { name: string; email: string; id: number }) => {
60+
const { name, email, id } = payload;
61+
62+
// This will create a new user in the database
63+
const user = await prisma.user.create({
64+
data: {
65+
name: name,
66+
email: email,
67+
id: id,
68+
},
69+
});
70+
71+
return {
72+
message: `New user added successfully: ${user.id}`,
73+
};
74+
},
75+
});
76+
```
77+
78+
</Step>
79+
<Step title="Configuring the build extension">
80+
81+
Next, configure the Prisma [build extension](https://trigger.dev/docs/config/extensions/overview) in the `trigger.config.js` file to include the Prisma client in the build.
82+
83+
This will ensure that the Prisma client is available when the task runs.
84+
85+
For a full list of options available in the Prisma build extension, see the [Prisma build extension documentation](https://trigger.dev/docs/config/config-file#prisma).
86+
87+
```js /trigger.config.js
88+
export default defineConfig({
89+
project: "<project ref>", // Your project reference
90+
// Your other config settings...
91+
build: {
92+
extensions: [
93+
prismaExtension({
94+
version: "5.20.0", // optional, we'll automatically detect the version if not provided
95+
// update this to the path of your Prisma schema file
96+
schema: "prisma/schema.prisma",
97+
}),
98+
],
99+
},
100+
});
101+
```
102+
103+
<Note>
104+
[Build extensions](/config/config-file#extensions) allow you to hook into the build system and
105+
customize the build process or the resulting bundle and container image (in the case of
106+
deploying). You can use pre-built extensions or create your own.
107+
</Note>
108+
109+
</Step>
110+
111+
<Step title="Optional: adding Prisma instrumentation">
112+
113+
We use OpenTelemetry to [instrument](https://trigger.dev/docs/config/config-file#instrumentations) our tasks and collect telemetry data.
114+
115+
If you want to automatically log all Prisma queries and mutations, you can use the Prisma instrumentation extension.
116+
117+
```js /trigger.config.js
118+
import { defineConfig } from "@trigger.dev/sdk/v3";
119+
import { PrismaInstrumentation } from "@prisma/instrumentation";
120+
import { OpenAIInstrumentation } from "@traceloop/instrumentation-openai";
121+
122+
export default defineConfig({
123+
//..other stuff
124+
instrumentations: [new PrismaInstrumentation(), new OpenAIInstrumentation()],
125+
});
126+
```
127+
128+
This provides much more detailed information about your tasks with minimal effort.
129+
130+
</Step>
131+
<Step title="Deploying your task">
132+
With the build extension and task configured, you can now deploy your task using the Trigger.dev CLI.
133+
134+
<CodeGroup>
135+
136+
```bash npm
137+
npx trigger.dev@latest deploy
138+
```
139+
140+
```bash pnpm
141+
pnpm dlx trigger.dev@latest deploy
142+
```
143+
144+
```bash yarn
145+
yarn dlx trigger.dev@latest deploy
146+
```
147+
148+
</CodeGroup>
149+
150+
</Step>
151+
152+
<Step title="Adding your DATABASE_URL environment variable to Trigger.dev">
153+
154+
In the sidebar select the "Environment Variables" page, then press the "New environment variable"
155+
button. ![Environment variables page](/images/environment-variables-page.jpg)
156+
157+
You can add values for your local dev environment, staging and prod. in this case we will add the `DATABASE_URL` for the production environment.
158+
159+
![Environment variables
160+
page](/images/environment-variables-panel.jpg)
161+
162+
</Step>
163+
164+
<Step title="Running your task">
165+
166+
To test this task, go to the 'test' page in the Trigger.dev dashboard and run the task with the following payload:
167+
168+
```json
169+
{
170+
"name": "John Doe",
171+
"email": "john@doe.test",
172+
"id": 12345
173+
}
174+
```
175+
176+
Congratulations! You should now see a new completed run, and a new user with the credentials you provided should be added to your database.
177+
178+
</Step>
179+
180+
</Steps>
181+
182+
<UsefulNextSteps />

docs/mint.json

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
"$schema": "https://mintlify.com/schema.json",
33
"name": "Trigger.dev",
4-
"openapi": [
5-
"/openapi.yml",
6-
"/v3-openapi.yaml"
7-
],
4+
"openapi": ["/openapi.yml", "/v3-openapi.yaml"],
85
"api": {
96
"playground": {
107
"mode": "simple"
@@ -106,41 +103,26 @@
106103
"navigation": [
107104
{
108105
"group": "Getting Started",
109-
"pages": [
110-
"introduction",
111-
"quick-start",
112-
"how-it-works",
113-
"upgrading-beta",
114-
"limits"
115-
]
106+
"pages": ["introduction", "quick-start", "how-it-works", "upgrading-beta", "limits"]
116107
},
117108
{
118109
"group": "Fundamentals",
119110
"pages": [
120111
{
121112
"group": "Tasks",
122-
"pages": [
123-
"tasks/overview",
124-
"tasks/scheduled"
125-
]
113+
"pages": ["tasks/overview", "tasks/scheduled"]
126114
},
127115
"triggering",
128116
"apikeys",
129117
{
130118
"group": "Configuration",
131-
"pages": [
132-
"config/config-file",
133-
"config/extensions/overview"
134-
]
119+
"pages": ["config/config-file", "config/extensions/overview"]
135120
}
136121
]
137122
},
138123
{
139124
"group": "Development",
140-
"pages": [
141-
"cli-dev",
142-
"run-tests"
143-
]
125+
"pages": ["cli-dev", "run-tests"]
144126
},
145127
{
146128
"group": "Deployment",
@@ -150,9 +132,7 @@
150132
"github-actions",
151133
{
152134
"group": "Deployment integrations",
153-
"pages": [
154-
"vercel-integration"
155-
]
135+
"pages": ["vercel-integration"]
156136
}
157137
]
158138
},
@@ -164,13 +144,7 @@
164144
"errors-retrying",
165145
{
166146
"group": "Wait",
167-
"pages": [
168-
"wait",
169-
"wait-for",
170-
"wait-until",
171-
"wait-for-event",
172-
"wait-for-request"
173-
]
147+
"pages": ["wait", "wait-for", "wait-until", "wait-for-event", "wait-for-request"]
174148
},
175149
"queue-concurrency",
176150
"versioning",
@@ -189,10 +163,7 @@
189163
"management/overview",
190164
{
191165
"group": "Tasks API",
192-
"pages": [
193-
"management/tasks/trigger",
194-
"management/tasks/batch-trigger"
195-
]
166+
"pages": ["management/tasks/trigger", "management/tasks/batch-trigger"]
196167
},
197168
{
198169
"group": "Runs API",
@@ -231,9 +202,7 @@
231202
},
232203
{
233204
"group": "Projects API",
234-
"pages": [
235-
"management/projects/runs"
236-
]
205+
"pages": ["management/projects/runs"]
237206
}
238207
]
239208
},
@@ -279,11 +248,7 @@
279248
},
280249
{
281250
"group": "Help",
282-
"pages": [
283-
"community",
284-
"help-slack",
285-
"help-email"
286-
]
251+
"pages": ["community", "help-slack", "help-email"]
287252
},
288253
{
289254
"group": "Frameworks",
@@ -292,6 +257,7 @@
292257
"guides/frameworks/bun",
293258
"guides/frameworks/nextjs",
294259
"guides/frameworks/nodejs",
260+
"guides/frameworks/prisma",
295261
"guides/frameworks/remix",
296262
{
297263
"group": "Supabase",
@@ -325,20 +291,16 @@
325291
},
326292
{
327293
"group": "Dashboard",
328-
"pages": [
329-
"guides/dashboard/creating-a-project"
330-
]
294+
"pages": ["guides/dashboard/creating-a-project"]
331295
},
332296
{
333297
"group": "Migrations",
334-
"pages": [
335-
"guides/use-cases/upgrading-from-v2"
336-
]
298+
"pages": ["guides/use-cases/upgrading-from-v2"]
337299
}
338300
],
339301
"footerSocials": {
340302
"twitter": "https://twitter.com/triggerdotdev",
341303
"github": "https://github.com/triggerdotdev",
342304
"linkedin": "https://www.linkedin.com/company/triggerdotdev"
343305
}
344-
}
306+
}

0 commit comments

Comments
 (0)