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:
giancarlo
2024-04-08 12:23:15 +08:00
parent 2b447167f7
commit 9fca45c2de
33 changed files with 369 additions and 250 deletions

View File

@@ -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!'
});
});
}
```

View File

@@ -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');