Adapters
Basic

Basic adapter

The basic adapter is the default adapter when none is specified. It is intended for testing purposes only (e.g. on localhost, or when your app is not hosted on a publicly accessible URL).

The basic adapter is simply a request forwarder. The send() will just make a direct POST request to onReceive() at the specified route.

Using the QStash adapter is recommended instead, so that you can control retries, delays etc.

Using the basic adapter

Put your scheduler config somewhere e.g. tasks/send-email.ts:

// tasks/send-email.ts
 
import { makeConfig, BasicAdapter } from "bunnygram";
 
interface JobPayload {
  emailAddress: string;
}
 
interface JobResponse {
  status: boolean;
}
 
export const sendEmail = makeConfig<JobPayload, JobResponse>({
  route: "/api/send-email",
  adapter: BasicAdapter(),
});

And you're done! All other steps should be the same as in Getting started.

Conditionally using the basic adapter on localhost

If your app is on localhost or does not have a publicly accessible URL, you may wish to conditionally use the basic adapter:

// tasks/send-email.ts
 
import { makeConfig, BasicAdapter, QStashAdapter } from "bunnygram";
 
interface JobPayload {
  emailAddress: string;
}
 
interface JobResponse {
  status: boolean;
}
 
export const sendEmail = makeConfig<JobPayload, JobResponse>({
  route: "/api/send-email",
  baseUrl:
    process.env.NODE_ENV === "development"
      ? "http://localhost:3000"
      : undefined, // 👈 leave undefined if you still want Bunnygram to guess your `baseUrl` in production
  adapter:
    process.env.NODE_ENV === "development" ? BasicAdapter() : QStashAdapter(),
});