Durable Jobs
Real-World Examples
LiveCommon backend flows that fit Durable Jobs: verification email, payment provisioning, and file processing.
Goal
Copy a realistic starting point for common backend workflows.
Current status
Live
This area is documented as current, user-reliable behavior.
Workflow
- 1Pick the example closest to your flow.
- 2Replace external services with your own app functions.
- 3Keep the idempotency and event correlation patterns.
Send verification email
Signup flow
tsawait stackshift.queue('emails').enqueue(
'sendVerificationEmail',
{ userId: 'user_123', email: 'ada@example.com' },
{ idempotencyKey: 'verify:user_123' }
)Payment to provisioning workflow
Payment confirmed
tsstackshift.job<{ paymentId: string; customerId: string }>('provisionAfterPayment', async ({ payload, step }) => {
const payment = await step.run('verify-payment', () => verifyPayment(payload.paymentId))
if (payment.status !== "paid") {
throw new Error('Payment is not complete')
}
await step.run('provision-customer-resources', () => provisionCustomerResources(payload.customerId))
await step.run('enable-plan', () => enablePaidPlan(payload.customerId))
await step.run('send-receipt', () => sendReceipt(payment.customerEmail))
return { provisioned: true }
})File processing pipeline
Process upload
tsstackshift.job<{ fileId: string }>('processUpload', async ({ payload, step, state }) => {
const file = await step.run('download-file', () => downloadFile(payload.fileId))
const parsed = await step.run('parse-file', () => parseCsv(file))
for (const batch of parsed.batches) {
await importRows(batch)
await state.increment(`files:${payload.fileId}:rows`, batch.length)
}
await step.run('mark-complete', () => markFileComplete(payload.fileId))
return { rows: parsed.totalRows }
})Expected result
You have practical templates for common production backend work.