- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control. - Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities. - Created .gitmodules to include OpenZeppelin contracts as a submodule. - Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment. - Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks. - Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring. - Created scripts for resource import and usage validation across non-US regions. - Added tests for CCIP error handling and integration to ensure robust functionality. - Included various new files and directories for the orchestration portal and deployment scripts.
3.5 KiB
3.5 KiB
Python to TypeScript Migration Guide
✅ Migration Complete
All Python code has been successfully migrated to TypeScript/Node.js.
📋 What Changed
Backend
- Flask → Express.js: Web framework
- Python → TypeScript: Language migration
- sqlite3 → better-sqlite3: Database library
- PyYAML → yaml: YAML parsing
- Jinja2 → EJS: Template engine
Templates
- Converted from Jinja2 to EJS syntax
- All templates updated and tested
🚀 Quick Start
Install Dependencies
# Install pnpm (if not already installed)
npm install -g pnpm
# Or using corepack
corepack enable && corepack prepare pnpm@latest --activate
cd orchestration/portal
pnpm install
Development
pnpm dev
Production
pnpm build
pnpm start
📝 Template Syntax Changes
Variables
# Jinja2 (Python)
{{ variable }}
// EJS (TypeScript)
<%= variable %>
Conditionals
# Jinja2
{% if condition %}
content
{% endif %}
// EJS
<% if (condition) { %>
content
<% } %>
Loops
# Jinja2
{% for item in items %}
{{ item }}
{% endfor %}
// EJS
<% items.forEach(item => { %>
<%= item %>
<% }); %>
Filters
# Jinja2
{{ value|upper }}
{{ value|title }}
{{ value|round(2) }}
// EJS
<%= value.toUpperCase() %>
<%= value.charAt(0).toUpperCase() + value.slice(1) %>
<%= value.toFixed(2) %>
🔄 API Compatibility
All API endpoints remain the same:
- Same routes
- Same request/response formats
- Same functionality
📦 File Structure
orchestration/portal/
├── src/ # TypeScript source
│ ├── server.ts # Main server
│ ├── config.ts # Configuration
│ ├── database.ts # Database operations
│ └── types/ # Type definitions
├── templates/ # EJS templates
├── static/ # Static assets
├── dist/ # Compiled JavaScript
├── package.json # Dependencies
└── tsconfig.json # TypeScript config
🎯 Benefits
- Type Safety: Compile-time error checking
- Better IDE Support: Autocomplete, refactoring
- Modern JavaScript: ES2022 features
- Performance: Node.js performance
- Ecosystem: Access to npm packages
🔧 Configuration
Environment Variables
PORT=5000 # Server port
HOST=0.0.0.0 # Server host
DB_PATH=... # Database path (optional)
TypeScript Config
See tsconfig.json for compiler options.
📚 Documentation
- TypeScript README - Complete TypeScript documentation
- Original README - Original Python documentation
🐛 Troubleshooting
Build Errors
rm -rf dist node_modules
pnpm install
pnpm build
Template Errors
- Check EJS syntax
- Ensure variables are passed correctly
- Use
<%- JSON.stringify(data) %>for objects
Database Issues
- Ensure
logs/directory exists - Check file permissions
- Database auto-creates on first run
✅ Migration Checklist
- Convert Flask to Express
- Convert Python functions to TypeScript
- Update database operations
- Convert templates to EJS
- Create TypeScript types
- Update configuration
- Create build scripts
- Update documentation
🎉 Status
Migration Complete! All Python code has been successfully migrated to TypeScript.