This is a Node.js API project for creating server side html or text images. We need this service during a private project to send some assets on email attachments.
Project developed with express and implements two important npm libraries to create images. Obviously this service is working thanks to "highcharts-export-server" and "text2png". This is only an example of how you can implement these libraries.
If you need to dockerize project do not forget to set environment variable for highchart license as following: ENV ACCEPT_HIGHCHARTS_LICENSE="YES"
Clone or download project to your local and provide dependencies. Project dependencies as following:
"dependencies": {
"express": "^4.17.1",
"highcharts-export-server": "^2.0.24",
"text2png": "^2.3.0",
"tsc-watch": "^4.1.0"
},
"devDependencies": {
"@types/express": "^4.17.2",
"nodemon": "^2.0.2",
"ts-node": "^8.6.2",
"typescript": "^3.7.5"
}
(For VSCode) Then run project with
npm install
and
npm run dev
After project build and ready you will see "Server is running on 3000" log at console.
Then call APIs as following (I used Postman application to call APIs):
For line chart with double line; you need to send below object in a "POST" request body to "/doublelinechart"
Created image must be as:
For line chart with single line; you need to send below object in a "POST" request body to "/singlelinechart"
Created image must be as:
-For pie chart; you need to send below object in a "POST" request body to "/piechart"
Created image must be as:
-For the textimage; you need to send below object in a "POST" request body to "/textimage"