Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 16, 2022 01:05 am GMT

Building a simple invoice generator with Node Js

Why

After each online coaching sessions, at the beginning, that was a pain to find a good invoice generator platform as I was not yet ready for a 20 monthly subscription just for handling the invoice part.

None was enough flexible for my own use so.. I decided to build my own mini-invoice generator with Node Js ( that took approx 1h max )

No more talk..Straight to the point

The main parts :

1. Storing clients in Json :

Yep that one is simple..for now x)

(Note: these are fictional characters of course )

Image description

2. Creating the route:
Using express router, just create a POST /invoice route.
const router = express.Router();
router.post('/', handleCreateInvoice);

Then add the Joi Schema. Why ? It allows to define schema and validate the schema before calling the controller/handler of invoice creation.

Source: https://joi.dev/

Image description

3. Handling the invoice creation:

I used the module pdf-kit to generate the pdf to be sent to the client.

pdf-kit

Image description

4. Email sending:
A small function using gmail-send npm module which accepts html as an input Image description

Yep..so what about the result ?

A snapshot of my first trials ^^ ( yep that email should be more personnalized and better structure )

Insomnia POST Call
Image description

Final result
Image description

Next steps:

  • Front-end ( React )
  • Database
  • make it online x)
  • Iterate

And you ?

Tell us in the comments which mini-project you built

Wanna support me ?

I am blogging during my free time ^^ like most people on this platform however I'm not against a small coffee if you want to support me Link below:

https://ko-fi.com/dev_it_out


Original Link: https://dev.to/olaf_ranai/building-a-simple-invoice-generator-with-node-js-lah

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To