Monday 29 April 2019

My first NPM Package

I've just made and published my own first NPM package!I'm a beginning web developer, while coding one of my personal projects I ran through an simple issue with Express and decided to make a NPM package out of the solution.I saw it as a great opportunity to learn to make and publish packages and as a way to contribute back to the our community.​The ProblemI was developing an Express website which had a lot of data within JSON files, each file had a list of objects, that would need to be served by Express in a HTML template.​Express provides a relatively easy ways to do templating, you can just set and install a templating engine as Handlebars and Pug to it.Although, I didn't want to install a template library just for the simple operation of injecting values.​What JSON-Pages (Yep, that's the name) does, is it automates the process of injecting JSON objects into a HTML template and serving them into an unique path in your server.All it needs to work is the path to a folder containing: JSON files and a HTML file. And optionally an unique key of each objThe use within my project looked like this:app.use(jsonPages(''))

Submitted April 29, 2019 at 09:15PM by Schapke

No comments:

Post a Comment