ππ a small web application for previewing PDFs
The repository covers multiple integration scenarios. It can be used as a standalone server, but it also exports an express/connect compatible middleware.
The standalone server is a simple express.js app. You can start it by running the server.js
script (for example via yarn start
).
The server listens on port 8000 by default, but this can be changed by setting the PORT
environment variable.
In this case you do not need the devDependencies
which yarn install
helpfully ignores when exporting NODE_ENV=production
.
$ export NODE_ENV=production PORT=8099
$ yarn install
$ yarn start
You can also require( 'pdf-preview-webapp' )
to mount the application inside another express application. (Express supports nested apps.)
const express = require( 'express' );
const previewApp = require( 'pdf-preview-webapp' );
const app = express();
app.use( '/preview', previewApp );
To start a webpack-dev-server
instance running the application (including server side rendering) use yarn dev
. This requires devDependencies
to be installed:
$ export NODE_ENV=
$ yarn install
$ yarn dev
The dist
directory contains the files that make up the actual application.
server.js
the express middleware that pre-renders the application on the server and handles the HTTP requestsbrowser.js
the actual web application that runs in your browser, including dependenciesstyle.css
CSS for the web application*.worker.js
the source file for the web worker that renders PDF filesstats.json
a manifest of files created when building the web application; used by the server
TBD