Replace Logger with getLogger and update next version
This commit replaces the use of Logger with getLogger in various parts of the code to handle logging. The Logger has been replaced with getLogger, which assists in getting logs in an asynchronous manner. In addition to this, it updates the next version in pnpm-lock.yaml from next@14.2.0-canary.61 to next@14.2.0-canary.62 and various other dependencies. Also made minor annotations and comments to the function 'isBrowser' and 'formatCurrency' in the 'utils.ts' file.
This commit is contained in:
@@ -27,13 +27,17 @@ MAILER_PROVIDER=cloudflare
|
||||
|
||||
### Send an email
|
||||
|
||||
```javascript
|
||||
import { Mailer } from '@kit/mailers';
|
||||
```tsx
|
||||
import { getMailer } from '@kit/mailers';
|
||||
|
||||
Mailer.sendEmail({
|
||||
async function sendEmail() {
|
||||
const mailer = await getMailer();
|
||||
|
||||
return mailer.sendEmail({
|
||||
to: '',
|
||||
from: '',
|
||||
subject: 'Hello',
|
||||
text: 'Hello, World!'
|
||||
});
|
||||
});
|
||||
}
|
||||
```
|
||||
@@ -5,28 +5,10 @@ const MAILER_PROVIDER = z
|
||||
.default('nodemailer')
|
||||
.parse(process.env.MAILER_PROVIDER);
|
||||
|
||||
/**
|
||||
* @description A mailer interface that can be implemented by any mailer.
|
||||
* We export a single mailer implementation using Nodemailer. You can add more mailers or replace the existing one.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Mailer } from '@kit/mailers';
|
||||
*
|
||||
* const mailer = new Mailer();
|
||||
*
|
||||
* mailer.sendEmail({
|
||||
* from: '',
|
||||
* to: '',
|
||||
* subject: 'Hello',
|
||||
* text: 'Hello, World!'
|
||||
* });
|
||||
*/
|
||||
export const Mailer = await getMailer();
|
||||
|
||||
/**
|
||||
* @description Get the mailer based on the environment variable.
|
||||
*/
|
||||
async function getMailer() {
|
||||
export async function getMailer() {
|
||||
switch (MAILER_PROVIDER) {
|
||||
case 'nodemailer': {
|
||||
const { Nodemailer } = await import('./impl/nodemailer');
|
||||
|
||||
Reference in New Issue
Block a user