@tonightpass/nestjs-mailjet
Version:
NestJS module for integrating Mailjet email service with your NestJS applications
40 lines (33 loc) • 1.73 kB
TypeScript
import { ModuleMetadata, Type, DynamicModule, Provider } from '@nestjs/common';
import { Contact, SendEmailV3_1 } from 'node-mailjet';
interface MailjetModuleOptions {
apiKey: string;
apiSecret: string;
sandboxMode?: boolean;
}
interface MailjetOptionsFactory {
createMailjetOptions(): Promise<MailjetModuleOptions> | MailjetModuleOptions;
}
interface MailjetModuleAsyncOptions extends Pick<ModuleMetadata, "imports"> {
inject?: any[];
useClass?: Type<MailjetOptionsFactory>;
useExisting?: Type<MailjetOptionsFactory>;
useFactory?: (...args: any[]) => Promise<MailjetModuleOptions> | MailjetModuleOptions;
}
declare class MailjetModule {
static forRoot(options: MailjetModuleOptions): DynamicModule;
static forRootAsync(options: MailjetModuleAsyncOptions): DynamicModule;
private static createAsyncProviders;
private static createAsyncOptionsProviders;
}
declare function createMailjetProviders(options: MailjetModuleOptions): Provider[];
declare class MailjetService {
private readonly client;
constructor(options: MailjetModuleOptions);
findContact(id: string | number): Promise<Contact.Contact>;
addContact(contact: Contact.PostContactBody): Promise<Contact.Contact>;
subscribeContactToList(contactId: string | number, listId: string | number): Promise<Contact.Contact>;
unsubscribeContactFromList(contactId: string | number, listId: string | number): Promise<Contact.Contact>;
sendEmail<TVars>(messages: SendEmailV3_1.Body<undefined, TVars>): Promise<SendEmailV3_1.ResponseMessage[]>;
}
export { MailjetModule, type MailjetModuleAsyncOptions, type MailjetModuleOptions, type MailjetOptionsFactory, MailjetService, createMailjetProviders };