https://github.com/vasisouv/painter
A Typescript Node.js REST API service for rendering emails and pdfs.
https://github.com/vasisouv/painter
email eta express mjml pdf puppeteer renderer
Last synced: 4 days ago
JSON representation
A Typescript Node.js REST API service for rendering emails and pdfs.
- Host: GitHub
- URL: https://github.com/vasisouv/painter
- Owner: vasisouv
- License: mit
- Created: 2022-09-10T13:11:20.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-20T21:09:15.000Z (about 3 years ago)
- Last Synced: 2025-04-02T17:51:39.973Z (7 months ago)
- Topics: email, eta, express, mjml, pdf, puppeteer, renderer
- Language: TypeScript
- Homepage:
- Size: 323 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Painter 🎨
A Typescript Node.js REST API service for rendering emails and pdfs.
Features:
* **[Express](https://expressjs.com/)** - app web framework
* **[Eta](https://eta.js.org/)** - template composition
* **[mjml](https://mjml.io/)** - responsive email framework
* **[playwright](https://playwright.dev/)** - html to pdf rendering## How It Works
Painter is a REST API with dynamic endpoints, representing filesystem template files, with
each path pointing to specific template file. There are two base api paths:### Emails
Base path:`/api/paint/email/:templatePath`
Emails use the mjml framework and markup language to ensure mail client compatibility.
Example:
```
curl --request POST \
--url http://localhost:3003/api/paint/email/example \
--header 'Content-Type: application/json' \
--data '{
"items": [
{
"description": "Alcohol free beer",
"price": "15.00",
"quantity": 2
},
{
"description": "Coffee",
"price": "10.00",
"quantity": 4
},
{
"description": "Potato chips",
"price": "4.00",
"quantity": 5
}
]
}
'
```The service responds with the email's HTML, ready to be sent.
```
#outlook a { padding:0; }
body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; }
table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; }
img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; }
p { display:block;margin:13px 0; }
....
```
### Pdfs
Base path:`/api/paint/pdf/:templatePath`
Pdfs are rendered from HTML using Playwright.
Example:
```
curl --request POST \
--url http://localhost:3003/api/paint/pdf/example \
--header 'Content-Type: application/json' \
--data '{
"items": [
{
"description": "Alcohol free beer",
"price": "15.00",
"quantity": 2
},
{
"description": "Coffee",
"price": "10.00",
"quantity": 4
},
{
"description": "Potato chips",
"price": "4.00",
"quantity": 5
}
]
}
'
```The service responds with the pdf Buffer Blob.
![]()