Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions 03-Capn-Web/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Cap'n Web + Auth0 Demo Configuration
# IMPORTANT: Copy this file to .env and update with your actual values

# Server Configuration
PORT=3000
HOST=localhost
NODE_ENV=development

# Auth0 Configuration
# Get these values from your Auth0 Dashboard > Applications > [Your App]
AUTH0_DOMAIN=your-domain.us.auth0.com
AUTH0_AUDIENCE=https://api.your-app.com

# Auth0 Client Configuration (for the web app)
# Get this from Auth0 Dashboard > Applications > [Your App] > Settings
AUTH0_CLIENT_ID=your-auth0-client-id

# Optional: Add artificial delays for testing (in milliseconds)
DELAY_PROFILE_MS=100

# Optional: Database Configuration (for production)
# DATABASE_URL=postgresql://username:password@localhost:5432/capnweb_demo

# Optional: Redis Configuration (for session storage)
# REDIS_URL=redis://localhost:6379
# REDIS_URL=redis://localhost:6379
96 changes: 96 additions & 0 deletions 03-Capn-Web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Environment variables (NEVER commit these!)
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Logs
logs
*.log

# Coverage directory used by tools like istanbul
coverage/
*.lcov

# nyc test coverage
.nyc_output

# IDE and editor files
.vscode/settings.json
.vscode/launch.json
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Build outputs
dist/
build/
out/

# Temporary files
*.tmp
*.temp

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Storybook build outputs
.out
.storybook-out

# Temporary folders
tmp/
temp/
57 changes: 57 additions & 0 deletions 03-Capn-Web/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Contributing to Cap'n Web + Auth0 Demo

Thank you for your interest in contributing to this project! This demo showcases the integration between Cap'n Web RPC and Auth0 authentication.

## Getting Started

1. Fork the repository
2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/capn-web-auth0-demo.git`
3. Install dependencies: `npm install`
4. Set up environment: `npm run setup`
5. Update `.env` with your Auth0 configuration
6. Start the development server: `npm run dev`

## Development Guidelines

### Code Style
- Use consistent indentation (2 spaces)
- Follow existing naming conventions
- Add comments for complex logic
- Maintain the existing dark theme design patterns

### Security
- Never commit credentials or API keys
- All authentication logic should be server-side validated
- Follow object-capability security patterns
- Test all authentication flows thoroughly

### Documentation
- Update README.md for any new features
- Add inline comments for complex RPC interactions
- Update the environment configuration examples

## Pull Request Process

1. Create a feature branch: `git checkout -b feature/your-feature-name`
2. Make your changes
3. Test thoroughly with different Auth0 configurations
4. Update documentation if needed
5. Submit a pull request with a clear description

## Testing

Before submitting a PR:
- Test the authentication flow end-to-end
- Verify WebSocket RPC calls work correctly
- Check that the pipelining demo functions properly
- Test with both development and production-like environments

## Questions?

Feel free to open an issue for questions about:
- Cap'n Web RPC implementation
- Auth0 integration patterns
- Project structure and architecture
- Development setup issues

Thank you for contributing! 🚀
29 changes: 29 additions & 0 deletions 03-Capn-Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Cap'n Web + Auth0 Demo Dockerfile
FROM node:18-alpine

# Set working directory
WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm ci --only=production

# Copy application code
COPY . .

# Create non-root user for security
RUN addgroup -g 1001 -S nodejs
RUN adduser -S capnweb -u 1001
USER capnweb

# Expose port
EXPOSE 3000

# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"

# Start application
CMD ["npm", "start"]
Loading