@tozielinski/next-brevo-api-helper 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +66 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -7,4 +7,69 @@
7
7
  ### Install the package:
8
8
  ```bash
9
9
  npm install @tozielinski/next-brevo-api-helper
10
- ```
10
+ ```
11
+ ### Create an API Key in Brevo: and add it to your Next.js environment variables:
12
+ ```
13
+ BREVO_API_KEY=your-brevo-api-key
14
+ ```
15
+ https://www.brevo.com/api-keys
16
+ ### Create a ServerAction, and use it in your Next.js page:
17
+ ```tsx
18
+ 'use server'
19
+
20
+ import {BrevoClient, BrevoEmailRecipient, BrevoSendEmailRequest} from "@tozielinski/next-brevo-api-helper";
21
+
22
+ const brevoClient = new BrevoClient();
23
+
24
+ const mail: BrevoSendEmailRequest = {
25
+ to:
26
+ [{
27
+ email: string
28
+ }]
29
+ ,
30
+ // sender: {
31
+ // email: string
32
+ // } satisfies BrevoEmailRecipient,
33
+ // cc?: BrevoEmailRecipient[];
34
+ // bcc?: BrevoEmailRecipient[];
35
+ // replyTo?: {
36
+ // email: string,
37
+ // name?: string,
38
+ // } satisfies BrevoEmailRecipient,
39
+ // subject: string,
40
+ // htmlContent: string,
41
+ // textContent: "this is a test content for a mail",
42
+ // textContent: mailObject.email + "\n" + (fullName.toString() && "\n") + mailObject.phone + "\nVielen Dank für die Anfrage zum Thema '" + mailObject.topic + "'\n\nDeine Nachricht lautet:\n" + mailObject.message,
43
+ // templateId?: number;
44
+ // params?: Record<string, string | number | boolean>;
45
+ // headers?: Record<string, string>;
46
+ // attachment?: {
47
+ // url?: string;
48
+ // content?: string; // Base64 encoded
49
+ // name?: string;
50
+ // }[];
51
+ // tags?: string[];
52
+ };
53
+
54
+ export async function sendMail() {
55
+ return brevoClient.sendEmail(mail);
56
+ }
57
+
58
+ export async function getFolders(apiKey?:string) {
59
+ const brevoClient = new BrevoClient();
60
+ return brevoClient.getFolders();
61
+ }
62
+
63
+ export async function getFolderDetails(folderId: number, apiKey?:string) {
64
+ const brevoClient = new BrevoClient();
65
+ return brevoClient.getFolderDetails({id: folderId});
66
+ }
67
+
68
+ export async function createFolder(name: string) {
69
+ return brevoClient.createFolder({name: name});
70
+ }
71
+
72
+ export async function deleteFolder(id: number) {
73
+ return brevoClient.deleteFolder({id: id});
74
+ }
75
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tozielinski/next-brevo-api-helper",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Lightweight helper to use Brevo to send mails via the Brevo API and maintain all",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",