Installation
Dinja provides a Rust HTTP service with Python and TypeScript clients.
Service Installation
Using Docker (Recommended)
Building from Source
git clone https://github.com/hlop3z/dinja.git
cd dinja
cargo build --release -p dinja-core
./target/release/dinja-core
Client Installation
Python
TypeScript/JavaScript
Rust (Direct Integration)
Add to your Cargo.toml:
Or use cargo:
Verification
Python
from dinja import Renderer
renderer = Renderer("http://localhost:8080")
if renderer.health():
print("Dinja service is running!")
result = renderer.html(views={"test.mdx": "# Hello"})
print(result.get_output("test.mdx"))
TypeScript
import { Renderer } from '@dinja/core';
const renderer = new Renderer({ baseUrl: 'http://localhost:8080' });
const isHealthy = await renderer.health();
if (isHealthy) {
console.log('Dinja service is running!');
const result = await renderer.html({ views: { 'test.mdx': '# Hello' } });
console.log(result);
}
Rust
use dinja_core::service::{RenderService, RenderServiceConfig};
fn main() -> anyhow::Result<()> {
let service = RenderService::new(RenderServiceConfig::default())?;
println!("Dinja initialized successfully!");
Ok(())
}
Troubleshooting
Service Not Running
If you get connection errors:
- Ensure the Docker container is running:
- Check if port 8080 is available:
Python Import Errors
If you encounter import errors:
- Verify the installation:
- Check your Python version (3.8+ required):
TypeScript Import Errors
If you encounter import errors:
- Verify the installation:
- Check your Node.js version (18+ recommended):
Next Steps
Once installed, check out the Quick Start Guide to render your first MDX file.