A simple Node.js PDF service built with RabbitMQ and jsPDF.
- Run the following command to create the necessary docker containers to run this project:
$ docker-compose up
-
Create a file named
.env
in the root of the project with the variables defined in.env.example
. -
Create a database called
pdf
and run the following command to run the migrations:
$ yarn migrate
- Install dependencies:
$ yarn install
- Start the service:
$ yarn start
You can also start the service in dev
mode with hard reload:
$ yarn dev
Main data JSON structure needed to generate a PDF:
{
"id": "", // uuid
"logo": "", // base64
"header": "", // string
"description": "", // string
"items": []
}
Items property is and array of items which are defined below.
- Table
{
"type": "table",
"header": "", // string
"description": "", // string
"fields": [], // string[]
"items": [] // related to fields (example below)
}
Example table item:
{
"type": "table",
"header": "Lorem ipsum",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"fields": ["foo", "bar"],
"items": [
{
"foo": "lorem",
"bar": "ipsum"
},
{
"foo": "dolor",
"bar": "sit"
}
]
}