Skip to content
NodeJS/Express application which generates PDF certificates from handlebars template using flyingsaucer. Uses SASS, Gulp, Handlerbars and Docker.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
dist
flyingsaucer
gulp
src
.babelrc
.dockerignore
.gitignore
Dockerfile
Procfile
README.md
composer.json
docker-compose.yml
flyingsaucer.sh
gulpfile.babel.js
package-lock.json
package.json

README.md

MOT Test Certificates

NodeJS/Express application which generates a PDF certificate from handlebars template using flyingsaucer.

Heroku

This application is hosted on heroku (cedar-14 stack) using the address below.

**It is password protected, please contact repo owner to retreive details from the Heroku account under settings **

https://mot-certificates.herokuapp.com/

Local Setup

  1. You will need latest versio node/npm and JDK
  2. Clone this repository and cd into it using terminal
  3. Install all npm dependencies
npm install

NPM

NPM is used to import certain packages required for this project. You can find the depenceny list inside of the package.json file.

Scripts

Start Development

This script is used to to start gulp watch task and run express server with nodemon. The NODE_ENV is automatically set to development, which is used inside of certain gulp tasks.

npm run start-dev

This will start a local server located at the address below:

http://localhost:3000/

Build Production

This task is used to process all ES6 express server code and build all assets ready for publishing. The javascript is processed using babel and the babel env preset to make the output compatible with nodejs. It has been tested with nodejs version 8.9.0. This is mainly required because nodejs does not allow ES6 imports/exports and many other features like the spread operator.

To build assets it runs the gulp build task which is documented further down on this page.

npm run build-production

Flyingsaucer

This is java application which generates a PDF from HTML using iText.

This application uses two jar files from the compiled version of flyingsuacer and itext. These are located in the flyingsaucer folder.

Flyingsaucer Guide

Handlebars

This is the templating language used. The data is taken from JSON files found inside of the data directory.

Handlebars Official Website

GulpJS

GulpJS is used to process the assets files (images and scss).

It is also used to move files into the dist folder once building for production use.

You can find the source code of all gulpjs tasks inside of the gulp folder.

Gulp Tasks

Build

This will run all of the tasks in series to build all assets. This is used to build production assets for dist folder before publishing. You are required to also set the NODE_ENV to production.

gulp build

Fonts

This task is used to move all font files into the dist folder.

gulp fonts

Images

This task is used to move all image assets into the distribution folder. If NODE_ENV is set to production then it will also compress images with imagemin.

gulp images

Scss

This task is used to pre-process the scss files into normal css files.

You can import npm packages into the scss files by using the package name, instead of the full node_modules path.

The task will use autoprefixer to automatically add any prefixes required for CSS 2.1 which is used by flyingsaucer.

When NODE_ENV is set to production it will also minify all css using cssnano.

When NODE_ENV is set to development it will also include sourcemaps inside of the css file.

gulp scss

Views

This task is used to move all view templates into the distribution folder. This is only used as part of the build task before publishing.

gulp views

Compile Handlebars

This task will compile all of the handlebars templates into html with inline stylesheets. This is used as part of the build production to allow for easier development.

gulp compile-handlebars

Watch

This task is used to run scss, images and fonts tasks and watch for any changes to the scss or image assets. When a change is made it will automatically re-run that particular task.

gulp watch

Docker setup for development

You will need the latest version of docker installed

Running development mode

For faster development you can use docker by running the following command:

docker-compose up

After which the server is located at the local address below:

http://localhost:3000

Building production

Run the following command

docker-compose run --rm app npm run build-production
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.