Skip to content

Commit

Permalink
feat: more types
Browse files Browse the repository at this point in the history
  • Loading branch information
meghein committed Jan 5, 2024
1 parent 677d4ec commit 88eb99a
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
declare module '@autotelic/fastify-mail' {
import { FastifyInstance, FastifyPluginCallback } from 'fastify';
import { Transporter } from 'nodemailer';
import { FastifyPluginCallback } from 'fastify';
import { Transporter } from 'nodemailer';

type FastifyMail = FastifyPluginCallback<fastifyMail.FastifyMailOptions>;

declare module 'fastify' {
interface FastifyInstance {
mail: fastifyMail.FastifyMailDecorator;
}
}

declare namespace fastifyMail {
// Define the options for the plugin
export interface FastifyMailOptions {
pov?: {
Expand All @@ -13,7 +21,7 @@ declare module '@autotelic/fastify-mail' {
}

// Define the shape of the mail decorator
interface FastifyMailDecorator {
export interface FastifyMailDecorator {
sendMail: (message: MailMessage, opts?: SendMailOptions) => Promise<any>;
createMessage: (message: MailMessage, templatePath: string, context: any) => Promise<MailMessage>;
validateMessage: (message: MailMessage) => string[];
Expand Down Expand Up @@ -46,5 +54,11 @@ declare module '@autotelic/fastify-mail' {
// The exported plugin function
const fastifyMail: FastifyPluginCallback<FastifyMailOptions>;

export default fastifyMail;
export { fastifyMail as default };
}

declare function fastifyMail(
...params: Parameters<FastifyMail>
): ReturnType<FastifyMail>;

export = fastifyMail;

0 comments on commit 88eb99a

Please sign in to comment.