Comparing version 0.1.0 to 0.2.0
@@ -76,8 +76,9 @@ /** | ||
constructor(apiKey: string, { inngestApiUrl }?: InngestClientOptions); | ||
private getResponseError; | ||
/** | ||
* Send an event to Inngest | ||
* Send event(s) to Inngest | ||
*/ | ||
send(payload: EventPayload): Promise<boolean>; | ||
send(payload: EventPayload | EventPayload[]): Promise<boolean>; | ||
} | ||
export { Inngest }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -29,10 +29,3 @@ "use strict"; | ||
} | ||
/** | ||
* Send an event to Inngest | ||
*/ | ||
async send(payload) { | ||
const response = await axios_1.default.post(this.inngestApiUrl, payload, this.axiosConfig); | ||
if (response.status >= 200 && response.status < 300) { | ||
return true; | ||
} | ||
getResponseError(response) { | ||
let errorMessage = "Unknown error"; | ||
@@ -66,6 +59,16 @@ switch (response.status) { | ||
} | ||
throw new Error(`Inngest API Error: ${response.status} ${errorMessage}`); | ||
return new Error(`Inngest API Error: ${response.status} ${errorMessage}`); | ||
} | ||
/** | ||
* Send event(s) to Inngest | ||
*/ | ||
async send(payload) { | ||
const response = await axios_1.default.post(this.inngestApiUrl, payload, this.axiosConfig); | ||
if (response.status >= 200 && response.status < 300) { | ||
return true; | ||
} | ||
throw this.getResponseError(response); | ||
} | ||
} | ||
exports.Inngest = Inngest; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "inngest", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Official SDK for Inngest.com", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -7,2 +7,4 @@ # inngest-node | ||
👋 _**Have a question or feature request? [Join our Discord](https://www.inngest.com/discord)!**_ | ||
## Usage | ||
@@ -18,2 +20,3 @@ | ||
// Send a single event | ||
await inngest.send({ | ||
@@ -29,2 +32,14 @@ name: "user.signup", | ||
}); | ||
// Send events in bulk | ||
const events = ["+12125551234", "+13135555678"].map(phoneNumber => ({ | ||
name: "sms.response.requested", | ||
data: { | ||
message: "Are you available for work today? (y/n)" | ||
}, | ||
user: { | ||
phone: phoneNumber | ||
} | ||
}}) | ||
await inngest.send(events); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43436
153
43