Initial push of Plunk Next
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "@plunk/email",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "email dev -p 1001 --dir=src/emails",
|
||||
"clean": "rimraf node_modules .turbo dist",
|
||||
"build": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@plunk/typescript-config": "*",
|
||||
"@react-email/preview-server": "5.0.1",
|
||||
"@types/react": "^19",
|
||||
"react-email": "5.0.1",
|
||||
"typescript": "5.7.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^19",
|
||||
"react-dom": "^19"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plunk/db": "*",
|
||||
"@plunk/types": "*",
|
||||
"@react-email/components": "^1.0.0"
|
||||
},
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import {Img} from '@react-email/components';
|
||||
import * as React from 'react';
|
||||
|
||||
export function Header() {
|
||||
return (
|
||||
<>
|
||||
<Img src="https://www.swyp.be/favicon/web-app-manifest-192x192.png" alt="Swyp Logo" width="40" height="40" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './emails';
|
||||
export * from './lib';
|
||||
@@ -0,0 +1 @@
|
||||
export * from './send';
|
||||
@@ -0,0 +1,27 @@
|
||||
interface SendEmailParams {
|
||||
to: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
}
|
||||
|
||||
export async function sendEmail({to, subject, body}: SendEmailParams) {
|
||||
const apiUrl = process.env.API_URI ?? 'http://localhost:8080';
|
||||
const res = await fetch(`${apiUrl}/v1/send`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${process.env.PLUNK_API_KEY}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
to,
|
||||
subject,
|
||||
body,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const errorText = await res.text();
|
||||
console.log(errorText);
|
||||
throw new Error('Failed to send email');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "@plunk/typescript-config/react-library.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
Reference in New Issue
Block a user