Project Structure
Complete Server Implementation
This is the completeserver.ts file from the playground-api app:
Package Dependencies
Here’s thepackage.json configuration:
Environment Configuration
Create a.env file in your project root:
Running the Server
Development Mode
http://localhost:3000.
Production Build
Testing the Server
Health Check
Verify NAVAI Routes
TheregisterNavaiExpressRoutes() function adds the following endpoints:
POST /voice/connect- Establish voice connection- Additional WebRTC signaling routes
Key Features
1. Smart CORS Configuration
The server includes flexible CORS handling that:- Allows all localhost origins automatically
- Supports wildcard (
*) for development - Accepts comma-separated allowed origins
- Blocks unauthorized origins with clear error messages
2. One-Line NAVAI Integration
3. Comprehensive Error Handling
Global error middleware catches all errors and returns consistent JSON responses.4. TypeScript Support
Full type safety with Express 5 types and TypeScript 5.7.Next Steps
- Learn about custom functions to extend voice capabilities
- Set up a React frontend to connect to this backend
- Configure route navigation for your app