{"id":28092363,"url":"https://github.com/sivm99/typst2pdf","last_synced_at":"2025-05-13T13:09:48.488Z","repository":{"id":291347115,"uuid":"977332591","full_name":"sivm99/typst2pdf","owner":"sivm99","description":"Typst-to-PDF generation API powered by Bun and Hono, with built-in support for custom S3 (CS3) uploads.","archived":false,"fork":false,"pushed_at":"2025-05-11T18:34:45.000Z","size":99,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T19:34:29.818Z","etag":null,"topics":["bun","docker","hono","pdf","pdf-generation","typst"],"latest_commit_sha":null,"homepage":"https://api.n3y.in/about","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sivm99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-04T00:31:13.000Z","updated_at":"2025-05-11T18:34:48.000Z","dependencies_parsed_at":"2025-05-04T03:23:42.782Z","dependency_job_id":"e0fddddc-9f23-4334-97ab-c1765f092cf5","html_url":"https://github.com/sivm99/typst2pdf","commit_stats":null,"previous_names":["sivm99/typst2pdf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivm99%2Ftypst2pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivm99%2Ftypst2pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivm99%2Ftypst2pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivm99%2Ftypst2pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sivm99","download_url":"https://codeload.github.com/sivm99/typst2pdf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253948418,"owners_count":21988957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","docker","hono","pdf","pdf-generation","typst"],"created_at":"2025-05-13T13:05:46.910Z","updated_at":"2025-05-13T13:09:48.471Z","avatar_url":"https://github.com/sivm99.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"🖨️ Typst PDF Generator API\n\nA blazing-fast PDF generation API built with Bun, Hono, and Typst. Compile .typ files or raw Typst source to PDF, and either stream, download, or upload to cloud (S3/R2/Spaces/MinIO) — including custom S3-compatible storage!\n\n## ✅ Features\n\n- 🧾 Convert .typ files or raw Typst source to PDF\n- 🚀 Built-in Typst CLI execution via Docker\n- 📤 Upload PDFs directly to:\n  - AWS S3\n  - Cloudflare R2\n  - DigitalOcean Spaces\n  - MinIO\n  - Any custom S3-compatible backend\n- 🌐 CDN support for instant file access\n- 🧪 Multipart file upload or JSON-based string input\n- 🪶 Lightweight \u0026 Bun-native using Bun.S3Client\n- 🧱 Simple endpoints, perfect for backend pipelines or frontend tooling\n\n## ⚙️ Endpoints\n\n### POST /api/v1/pdf\n\nInput: .typ file via multipart/form-data\n\nHeader Requirements:\n\n| Header     | Required | Description                                      |\n| ---------- | -------- | ------------------------------------------------ |\n| x-upload   | No       | Set to true to upload PDF to default S3          |\n| x-filename | No       | Custom filename (default: random UUID)           |\n| x-stream   | No       | Set to true to stream PDF instead of downloading |\n\nResponse Behavior:\n\n- 📤 If x-upload: true, PDF is uploaded to default S3 config\n- 📥 If x-stream: true, PDF is streamed as raw application/pdf\n- 🔽 Else, PDF is downloaded as an attachment\n\n### POST /api/v1/pdf/string\n\nInput: JSON with raw Typst source\n\n```json\n{\n  \"source\": \"Hello, _Typst_!\",\n  \"options\": {\n    \"upload\": true,\n    \"stream\": false,\n    \"filename\": \"hello.pdf\"\n  }\n}\n```\n\nSame headers (x-upload, x-filename, x-stream) apply as optional overrides.\n\n### POST /api/v1/pdf/text\n\nInput: Raw Typst source as text/plain or JSON with \"source\" field\n\nHeader Requirements:\n\n| Header     | Required | Description                                      |\n| ---------- | -------- | ------------------------------------------------ |\n| x-upload   | No       | Set to true to upload PDF to default S3          |\n| x-filename | No       | Custom filename (default: random UUID)           |\n| x-stream   | No       | Set to true to stream PDF instead of downloading |\n\nResponse Behavior:\n\n- 📤 If x-upload: true, PDF is uploaded to default S3 config\n- 📥 If x-stream: true, PDF is streamed as raw application/pdf\n- 🔽 Else, PDF is downloaded as an attachment\n\nNote: Cannot stream and upload simultaneously\n\n### POST /api/v1/pdf/mys3\n\nInput: .typ file via multipart/form-data\n\nHeader Requirements:\n\n| Header          | Required | Description                        |\n| --------------- | -------- | ---------------------------------- |\n| x-s3-access-key | Yes      | Access key for your S3 provider    |\n| x-s3-secret-key | Yes      | Secret key                         |\n| x-s3-endpoint   | Yes      | S3 endpoint (e.g., https://...)    |\n| x-s3-bucket     | Yes      | Bucket name                        |\n| x-s3-cdn-url    | Yes      | Base public CDN URL (for response) |\n| x-s3-filename   | No       | Filename to upload (default: UUID) |\n\n🎯 Returns the full public URL based on cdn-url + filename.\n\n## 🧪 Examples\n\n### Curl - Compile .typ and stream result\n\n```bash\ncurl -X POST http://localhost:3000/api/v1/pdf \\\n  -H \"x-stream: true\" \\\n  -F \"file=@document.typ\" \\\n  --output output.pdf\n```\n\n### Curl - Upload compiled PDF to default S3\n\n```bash\ncurl -X POST http://localhost:3000/api/v1/pdf \\\n  -H \"x-upload: true\" \\\n  -H \"x-filename: invoice.pdf\" \\\n  -F \"file=@invoice.typ\"\n```\n\n### Curl - Custom S3 Upload\n\n```bash\ncurl -X POST http://localhost:3000/api/v1/pdf/mys3 \\\n  -H \"x-s3-access-key: ACCESSKEY\" \\\n  -H \"x-s3-secret-key: SECRETKEY\" \\\n  -H \"x-s3-endpoint: https://nyc3.digitaloceanspaces.com\" \\\n  -H \"x-s3-bucket: my-bucket\" \\\n  -H \"x-s3-cdn-url: https://cdn.mybucket.com\" \\\n  -H \"x-s3-filename: report.pdf\" \\\n  -F \"file=@report.typ\"\n```\n\n## 🚀 Setup \u0026 Run\n\n1. Clone\n\n```bash\ngit clone https://github.com/sivm99/typst2pdf.git\ncd typst2pdf\n```\n\n2. Install deps\n\n```bash\nbun install\n```\n\n3. Add environment variables (optional for default S3)\n\nCreate a .env:\n\n```\nS3_ACCESS_KEY=your-access-key\nS3_SECRET_KEY=your-secret-key\nS3_ENDPOINT=https://s3.amazonaws.com\nS3_BUCKET=my-default-bucket\nS3_CDN_URL=https://cdn.mybucket.com\n```\n\n4. Run\n\n```bash\nbun run build\nbun run src/index.ts\n```\n\n## 🧰 Tech Stack\n\n- Bun\n- Hono (Express-style web framework)\n- Typst (LaTeX alternative)\n- Docker\n- Bun.S3Client for seamless S3 integration\n\n## 📦 Future Ideas\n\n- Typst project zip support\n- Token-based auth\n- Caching with Bun KV or Redis\n- Custom font and asset support\n- Web dashboard to view past jobs\n\n## 🧑‍💻 Author\n\nŚivam Śukla\n🔗 @sivm99\n💻 B.Tech CSE | Full-stack Dev | Backend, Go, MERN, Bun Enthusiast\n\n## 🪪 License\n\nMIT © Śivam Śukla\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsivm99%2Ftypst2pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsivm99%2Ftypst2pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsivm99%2Ftypst2pdf/lists"}