Have you looked for npm modules that may do this ?