feat(dashboard): add login screen, auth provider, and server-client example

This commit is contained in:
coo1estguy
2026-09-14 23:14:11 +05:30
parent 231fb19349
commit 8d1ff5d816
28 changed files with 837 additions and 186 deletions
+34 -34
View File
@@ -1,63 +1,63 @@
import { NotifkitClient } from 'notifkit';
import { NotifkitClient } from "notifkit";
/**
* Example demonstrating multi-step notification workflows (Notify -> Wait -> Notify)
*/
async function runWorkflowExample() {
const client = new NotifkitClient({
baseUrl: process.env.NOTIFKIT_API_URL || 'http://localhost:4000',
apiKey: process.env.ADMIN_API_KEY || 'your_admin_api_key',
baseUrl: process.env.NOTIFKIT_API_URL || "http://localhost:4000",
apiKey: process.env.ADMIN_API_KEY || "your_admin_api_key",
});
console.log('🔄 Syncing onboarding template...');
console.log("🔄 Syncing onboarding template...");
await client.syncTemplates({
templates: [
{
id: 'onboarding-welcome',
channel: 'email',
id: "onboarding-welcome",
channel: "email",
content: {
subject: 'Welcome to our Platform!',
html: '<h3>Hello {{name}}!</h3><p>Thank you for signing up.</p>',
text: 'Hello {{name}}! Thank you for signing up.',
subject: "Welcome to our Platform!",
html: "<h3>Hello {{name}}!</h3><p>Thank you for signing up.</p>",
text: "Hello {{name}}! Thank you for signing up.",
},
},
{
id: 'onboarding-followup',
channel: 'email',
id: "onboarding-followup",
channel: "email",
content: {
subject: 'Getting Started Tips',
html: '<h3>Tips for {{name}}</h3><p>Check out our documentation to get started.</p>',
text: 'Tips for {{name}}. Check out our documentation to get started.',
subject: "Getting Started Tips",
html: "<h3>Tips for {{name}}</h3><p>Check out our documentation to get started.</p>",
text: "Tips for {{name}}. Check out our documentation to get started.",
},
},
],
});
console.log('✅ Templates synced successfully.');
console.log("✅ Templates synced successfully.");
console.log('🔄 Registering multi-step workflow definition...');
console.log("🔄 Registering multi-step workflow definition...");
// No step names a recipient: each one inherits the user the instance was
// triggered with, so the same definition serves every subscriber.
const workflow = await client.createWorkflow({
name: 'user-onboarding-drip',
name: "user-onboarding-drip",
steps: [
{
action: 'notify',
action: "notify",
payload: {
template: 'onboarding-welcome',
channels: ['email'],
data: { name: 'Jane Doe' },
template: "onboarding-welcome",
channels: ["email"],
data: { name: "Jane Doe" },
},
},
{
action: 'wait',
duration: '1h', // Wait 1 hour before next step
action: "wait",
duration: "1h", // Wait 1 hour before next step
},
{
action: 'notify',
action: "notify",
payload: {
template: 'onboarding-followup',
channels: ['email'],
data: { name: 'Jane Doe' },
template: "onboarding-followup",
channels: ["email"],
data: { name: "Jane Doe" },
},
},
],
@@ -65,20 +65,20 @@ async function runWorkflowExample() {
console.log(`✅ Workflow registered: ${workflow.name}`);
console.log('🔄 Registering the recipient...');
await client.addUser({ id: 'user-1001', email: 'user@example.com' });
console.log("🔄 Registering the recipient...");
await client.addUser({ id: "user-1001", email: "user@example.com" });
console.log('🚀 Triggering workflow execution for recipient...');
console.log("🚀 Triggering workflow execution for recipient...");
// input.user.id is who every notify step in this instance sends to.
const execution = await client.triggerWorkflow({
name: 'user-onboarding-drip',
input: { user: { id: 'user-1001' } },
name: "user-onboarding-drip",
input: { user: { id: "user-1001" } },
});
console.log('🎉 Workflow triggered. Instance ID:', execution.instanceId);
console.log("🎉 Workflow triggered. Instance ID:", execution.instanceId);
}
runWorkflowExample().catch((err) => {
console.error('❌ Error executing workflow example:', err);
console.error("❌ Error executing workflow example:", err);
process.exit(1);
});