@@ -7,6 +7,7 @@ A Next.js application demonstrating how to integrate Outpost with an API platfor
77- ** API Platform Dashboard** : Complete user dashboard for an API/SaaS platform
88- ** Integrated Event Management** : Seamless Outpost integration for webhook/event destinations
99- ** Automatic Tenant Provisioning** : Users get Outpost tenants created automatically when they sign up
10+ - ** Event Testing Playground** : Interactive interface for testing event publishing to configured destinations
1011- ** Unified User Experience** : Event destination management feels like a native part of the platform
1112- ** Production-Ready Patterns** : Demonstrates real-world integration patterns for API platforms
1213
@@ -42,13 +43,22 @@ A Next.js application demonstrating how to integrate Outpost with an API platfor
4243
4344 The default configurations should work for local development. For production, update the secrets in both files.
4445
46+ Update the ` TOPICS ` environment variable in ` .env.outpost ` to include the event topics you want to support:
47+
48+ ``` bash
49+ TOPICS=user.created,user.updated,order.completed,payment.processed,subscription.created
50+ ```
51+
52+ For a full list of Outpost configuration options, see [ Outpost Configuration] ( https://outpost.hookdeck.com/docs/references/configuration )
53+
45544 . ** Start the complete stack** (PostgreSQL, Redis, RabbitMQ, and Outpost):
4655
4756 ``` bash
4857 docker-compose up -d
4958 ```
5059
5160 This will start:
61+
5262 - ` postgres ` - PostgreSQL with separate databases for dashboard and Outpost (port 5432)
5363 - ` redis ` - Redis for Outpost (port 6379)
5464 - ` rabbitmq ` - Message queue for Outpost (port 5672, management UI on 15672)
@@ -72,31 +82,81 @@ A Next.js application demonstrating how to integrate Outpost with an API platfor
7282
73837 . ** Access the application** :
7484 - Dashboard: [ http://localhost:3000 ] ( http://localhost:3000 )
75- - Outpost API: [ http://localhost:3333 ] ( http://localhost:3333 )
85+ - Outpost API: ` http://localhost:3333/api/v1 `
7686 - RabbitMQ Management: [ http://localhost:15672 ] ( http://localhost:15672 ) (guest/guest)
7787
78- ## Usage
88+ ## Application Structure
89+
90+ ### Pages
91+ - ` / ` - Landing page with registration and login links
92+ - ` /auth/register ` - User registration form
93+ - ` /auth/login ` - User login form
94+ - ` /dashboard ` - Main dashboard with overview statistics and recent events
95+ - ` /dashboard/playground ` - Interactive event testing interface
96+ - ` /dashboard/event-destinations/[...path] ` - Portal integration routes
97+
98+ ### Core Functionality
99+
100+ #### User Registration and Authentication
101+ - User registration creates platform account and automatically provisions Outpost tenant
102+ - NextAuth.js handles authentication with credential-based login
103+ - User ID from platform database becomes tenant ID in Outpost
104+ - JWT tokens secure API routes
105+
106+ #### Dashboard Overview
107+ - Displays real-time statistics from Outpost API (total destinations, total events)
108+ - Shows recent events with status indicators
109+ - Lists configured destinations with type, URL, and enabled status
110+ - Provides navigation to destination management and playground
111+
112+ #### Event Playground
113+ - Interactive form for testing event publishing
114+ - Destination dropdown populated from user's configured destinations
115+ - Topic dropdown populated from Outpost API (` /api/topics ` )
116+ - JSON payload editor with validation
117+ - Real-time event publishing to selected destination
118+ - Response display with success/error details
119+
120+ #### Portal Integration
121+ - Seamless redirection to Outpost portal for destination management
122+ - Server-side portal URL generation with authentication
123+ - Deep linking support for specific portal pages
124+ - Branded portal experience with return navigation
125+
126+ ## API Endpoints
127+
128+ ### Dashboard APIs
129+ - ` GET /api/overview ` - Returns dashboard statistics and recent events from Outpost
130+ - ` GET /api/topics ` - Returns available topics from Outpost configuration
131+ - ` POST /api/playground/trigger ` - Publishes test events via Outpost SDK
132+
133+ ### Authentication APIs
134+ - ` POST /api/auth/register ` - Creates user account and Outpost tenant
135+ - NextAuth.js provides login/logout/session endpoints
136+
137+ ### Portal Integration
138+ - ` GET /dashboard/event-destinations ` - Redirects to Outpost portal root
139+ - ` GET /dashboard/event-destinations/[...path] ` - Redirects to specific portal pages
79140
80- 1 . ** Sign up for the API platform** - Register as a new user of the fictitious API platform
81- 2 . ** Access your platform dashboard** - View your API usage, account info, and available features
82- 3 . ** Manage Event Destinations** - Click "Event Destinations" to configure webhooks for your API events
83- 4 . ** Seamless Portal Experience** - Get redirected to Outpost's full-featured destination management interface
84-
85- ## Use Case
86-
87- This demo represents a common integration scenario where:
141+ ## Architecture
88142
89- - ** API Platform** : Your SaaS provides APIs that generate events (user signups, payments, data processing, etc.)
90- - ** Customer Need** : Your customers need to receive these events via webhooks to their own systems
91- - ** Outpost Integration** : Instead of building webhook infrastructure from scratch, you integrate Outpost
92- - ** User Experience** : Your customers manage event destinations through what feels like your native platform
143+ ### Frontend (Next.js)
144+ - React components with Tailwind CSS for styling
145+ - NextAuth.js for authentication
146+ - Custom hooks for data fetching (` useOverview ` , ` useTopics ` )
147+ - Responsive design with loading states and error handling
93148
94- ## Architecture
149+ ### Backend Integration
150+ - Next.js API routes for server-side operations
151+ - Outpost TypeScript SDK for all Outpost interactions
152+ - PostgreSQL for platform user management (separate from Outpost database)
153+ - JWT tokens for API authentication
95154
96- - ** Platform Frontend** : Next.js application representing your API platform's dashboard
97- - ** User Management** : Auth.js with PostgreSQL for platform user accounts
98- - ** Outpost Integration** : Official TypeScript SDK for tenant and portal management
99- - ** Seamless Handoff** : Server-side route handlers for transparent portal access
155+ ### Integration Points
156+ 1 . User registration triggers Outpost tenant creation
157+ 2 . Dashboard aggregates data from Outpost API
158+ 3 . Portal access generates authenticated Outpost URLs
159+ 4 . Playground publishes events directly via Outpost SDK
100160
101161## Environment Variables
102162
@@ -119,6 +179,7 @@ This demo represents a common integration scenario where:
119179| ` POSTGRES_URL ` | Outpost PostgreSQL connection | ` postgres://outpost:outpost@postgres:5432/outpost ` |
120180| ` REDIS_HOST ` | Redis hostname | ` redis ` |
121181| ` RABBITMQ_SERVER_URL ` | RabbitMQ connection | ` amqp://guest:guest@rabbitmq:5672 ` |
182+ | ` TOPICS ` | Available event topics (comma-separated) | ` user.created,order.completed,payment.processed ` |
122183| ` PORTAL_ORGANIZATION_NAME ` | Portal branding | ` API Platform Demo ` |
123184| ` PORTAL_REFERER_URL ` | Dashboard URL for "Back to" navigation link in portal | ` http://localhost:3000 ` |
124185
@@ -153,7 +214,7 @@ docker-compose ps
153214
154215# View logs for a specific service
155216docker-compose logs outpost-api
156- docker-compose logs dashboard- postgres
217+ docker-compose logs postgres
157218
158219# Restart services
159220docker-compose restart
@@ -177,19 +238,57 @@ curl http://localhost:3333/healthz
177238docker-compose logs outpost-api
178239```
179240
180- ## Integration Points
241+ ### Topics not loading in playground
242+
243+ Ensure the ` TOPICS ` environment variable is set in ` .env.outpost ` :
244+
245+ ``` bash
246+ TOPICS=user.created,user.updated,order.completed,payment.processed
247+ ```
181248
182- 1 . ** User Onboarding** → Platform user registration automatically provisions Outpost tenant
183- 2 . ** Dashboard Overview** → Display event/webhook statistics from Outpost API in platform dashboard
184- 3 . ** Destination Management** → "Event Destinations" nav item seamlessly redirects to Outpost portal
185- 4 . ** Branded Experience** → Users experience webhook management as part of your platform, not a separate tool
249+ Restart the Outpost services after updating:
186250
187- ## Key Integration Patterns
251+ ``` bash
252+ docker-compose restart outpost-api
253+ ```
188254
189- This demo illustrates several important patterns for API platform integration:
255+ ## Use Case
256+
257+ This demo represents a common integration scenario where:
258+
259+ - ** API Platform** : Your SaaS provides APIs that generate events (user signups, payments, data processing, etc.)
260+ - ** Customer Need** : Your customers need to receive these events via webhooks to their own systems
261+ - ** Outpost Integration** : Instead of building webhook infrastructure from scratch, you integrate Outpost
262+ - ** User Experience** : Your customers manage event destinations through what feels like your native platform
190263
191- - ** Transparent Tenant Management** : Outpost tenants are created automatically and hidden from users
192- - ** Single Sign-On Experience** : Users don't need separate Outpost accounts
193- - ** Embedded Navigation** : Event destinations appear as a natural part of the platform navigation
194- - ** Contextual Data Display** : Platform dashboard shows relevant Outpost data (destination counts, recent events)
195- - ** Seamless Handoff** : Clicking "Event Destinations" feels like navigating to another page in your app
264+ ## Integration Patterns
265+
266+ This demo demonstrates several integration patterns:
267+
268+ - ** Transparent Tenant Management** : Outpost tenants are created automatically during user registration and hidden from end users
269+ - ** Embedded Navigation** : Event destinations appear as a native part of the platform navigation
270+ - ** Portal Integration** : Server-side URL generation provides seamless access to Outpost's management interface
271+ - ** Data Aggregation** : Platform dashboard displays relevant Outpost statistics alongside application metrics
272+ - ** Event Testing** : Built-in playground allows testing events against real configured destinations
273+
274+ ## Technical Implementation
275+
276+ ### User Flow
277+ 1 . User registers account → Creates Outpost tenant automatically
278+ 2 . User logs in → Receives platform session with JWT
279+ 3 . User views dashboard → Data aggregated from Outpost API
280+ 4 . User manages destinations → Redirected to authenticated Outpost portal
281+ 5 . User tests events → Playground publishes to actual destinations via Outpost SDK
282+
283+ ### Security
284+ - Password hashing with bcryptjs
285+ - JWT token validation on API routes
286+ - Zod schema validation for form inputs
287+ - SQL injection prevention via parameterized queries
288+ - Environment variables for API keys and secrets
289+
290+ ### Error Handling
291+ - Form validation with user-friendly error messages
292+ - API error responses with appropriate HTTP status codes
293+ - Loading states and skeleton screens for data fetching
294+ - Fallback UI for failed API calls
0 commit comments