-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
64 lines (53 loc) · 1.56 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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?: {
engine?: any;
propertyName?: string;
[key: string]: any;
};
transporter: Transporter;
}
// Define the shape of the mail decorator
export interface FastifyMailDecorator {
sendMail: (message: MailMessage, opts?: SendMailOptions) => Promise<any>;
createMessage: (message: MailMessage, templatePath: string, context: any) => Promise<MailMessage>;
validateMessage: (message: MailMessage) => string[];
}
// Define the shape of the message
interface MailMessage {
to?: string;
from?: string;
subject?: string;
replyTo?: string;
cc?: string;
bcc?: string;
html?: string;
text?: string;
[key: string]: any;
}
interface SendMailOptions {
templatePath?: string;
context?: any;
}
// Extend the FastifyInstance interface to include the new decorators
export interface FastifyInstance {
nodemailer: Transporter;
mail: FastifyMailDecorator;
}
// The exported plugin function
const fastifyMail: FastifyPluginCallback<FastifyMailOptions>;
export { fastifyMail as default };
}
declare function fastifyMail(
...params: Parameters<FastifyMail>
): ReturnType<FastifyMail>;
export = fastifyMail;