diff --git a/index.ts b/index.ts index 83234d4..72f1f27 100644 --- a/index.ts +++ b/index.ts @@ -18,7 +18,14 @@ app.get('/', (req, res) => { const functions = getFunctions(); -app.use('/api/inngest', serve(inngest, [...functions])); +app.use( + '/api/inngest', + serve(inngest, [...functions], { + signingKey: process.env.IS_PULL_REQUEST + ? process.env.INNGEST_BRANCH_SIGNING_KEY + : process.env.INNGEST_SIGNING_KEY, + }) +); app.listen(PORT, async () => { console.log(`✅ Server started on localhost:${PORT} diff --git a/inngest/client.ts b/inngest/client.ts index 1320a6e..9d080b2 100644 --- a/inngest/client.ts +++ b/inngest/client.ts @@ -5,5 +5,8 @@ import type { Events } from './events'; export const inngest = new Inngest({ name: 'Demo App', schemas: new EventSchemas().fromRecord(), + eventKey: process.env.IS_PULL_REQUEST + ? process.env.INNGEST_BRANCH_EVENT_KEY + : process.env.INNGEST_EVENT_KEY, env: process.env.RENDER_GIT_BRANCH, }); diff --git a/inngest/emails.ts b/inngest/emails.ts index 8fd1fdf..4f2e98a 100644 --- a/inngest/emails.ts +++ b/inngest/emails.ts @@ -21,3 +21,14 @@ export const sendUpgradeEmail = inngest.createFunction( }; } ); + +export const sendChurnEmail = inngest.createFunction( + { name: 'Send Churn Email' }, + { event: 'billing/subscription.cancelled' }, + async ({ event }) => { + return { + success: true, + message: `churn email sent to user: ${event.user.id}`, + }; + } +); diff --git a/inngest/index.ts b/inngest/index.ts index 8a352d7..876f4e7 100644 --- a/inngest/index.ts +++ b/inngest/index.ts @@ -6,7 +6,6 @@ const functions = [...Object.values(emails), ...Object.values(payments)]; // We use a function to do this in order to dynamically add the cron test function export function getFunctions() { - console.log('Get functions', process.env.RENDER_GIT_BRANCH); // Only set the cron trigger to run in production, not branch envs if ( !Boolean(process.env.RENDER_GIT_BRANCH) || diff --git a/package.json b/package.json index 0f314d4..c2bc9db 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "engine": { "node": ">=20", - "pnpm": "^8.6.2" - } + "pnpm": "8.6.2" + }, + "packageManager": "pnpm@8.6.2" }