inngest-setup은(는) 무엇을 하나요?
TypeScript 프로젝트에 지속적 실행(durable execution)을 추가할 때 사용 — 재시도 가능한 웹훅 핸들러, 충돌에 강한 백그라운드 작업, 예약된 태스크 또는 단일 요청을 넘어 실행되는 장기 워크플로우를 구축합니다. Inngest SDK 설치, 클라이언트 구성, 환경 변수, 서브 엔드포인트(Next.js, Express, Hono, Fastify), connect-as-worker 모드 및 로컬 개발 서버를 다룹니다.
설치
npm install inngest
클라이언트 설정
import { Inngest } from "inngest";
export const inngest = new Inngest({ id: "my-app" });
환경 변수
.env.local 파일에 다음을 추가하세요:
INNGEST_EVENT_KEY=your-event-key
INNGEST_SIGNING_KEY=your-signing-key
서브 엔드포인트 (Next.js)
app/api/inngest/route.ts:
import { serve } from "inngest/next";
import { inngest } from "@/lib/inngest";
export const { GET, POST, PUT } = serve({
client: inngest,
functions: [
// 함수 등록
],
});
서브 엔드포인트 (Express)
import express from "express";
import { serve } from "inngest/express";
import { inngest } from "./lib/inngest";
const app = express();
app.use(express.json());
app.use("/api/inngest", serve({
client: inngest,
functions: [
// 함수 등록
],
}));
app.listen(3000);
서브 엔드포인트 (Hono)
import { Hono } from "hono";
import { serve } from "inngest/hono";
import { inngest } from "./lib/inngest";
const app = new Hono();
app.route("/api/inngest", serve({
client: inngest,
functions: [
// 함수 등록
],
}));
서브 엔드포인트 (Fastify)
import Fastify from "fastify";
import { serve } from "inngest/fastify";
import { inngest } from "./lib/inngest";
const app = Fastify();
app.register(serve({
client: inngest,
prefix: "/api/inngest",
functions: [
// 함수 등록
],
}));
Connect-as-worker 모드
import { Inngest } from "inngest";
import { connect } from "inngest/connect";
const client = new Inngest({ id: "my-app" });
connect({
client,
functions: [
// 함수 등록
],
});
로컬 개발 서버
npx inngest-cli dev
또는 package.json에 스크립트를 추가하세요:
{
"scripts": {
"dev": "inngest-cli dev"
}
}