Divorce Document Express Handler

A simple module to handle getting documents
Getting started
Attach document handler to express app
Attach the document get route to the app like so:
const { initDocumentHandler } = require('@hmcts/div-document-express-handler');
const express = require('express');
const idam = require('services/idam');
const app = express();
const middleware = [ idam.protect() ];
const args = {
uri: '/document-download/:documentId',
documentWhiteList: (req, res) => {
return ['fileName1IncludesString', 'fileName2IncludesString'];
},
authorizationTokenCookieName: '__auth-token',
documentServiceUrl: 'service-url',
sessionFileCollectionsPaths: ['case.data.d8', 'files']
};
initDocumentHandler(app, middleware, args);
Generate urls and file types from file system
Here is an example how to generate file urls and types:
const { Page } = require('@hmcts/one-per-page');
const { createUris } = require('@hmcts/div-document-express-handler');
class Step extends Page {
static get path() {
return 'some-path';
}
get downloadableFiles() {
const args = {
uri: 'some-url',
documentWhiteList: ['someOtherFile']
};
return createUris(this.req.session.files, args);
}
}
module.exports = Step;
To render output using look-and-feel:
template.html:
{% from "look-and-feel/components/document-list.njk" import documentList %}
<h3 class="heading-small" id="subsection-title">Download your documents</h3>
{{ documentList(downloadableFiles, content.files) }}
main.scss:
@import 'look-and-feel/all';
or to import specific styles for document-list
@import 'look-and-feel/document-list';
content.json:
{
"en": {
"files": {
"d8petition": "Original Petition",
"aosinvitation": "Respondent Response",
"co-respondentaosinvitation": "Co-Respondent Response"
}
}
}
This will print the file list out.
Versioning
We use SemVer for versioning.
For the versions available, see the tags on this repository.
Standard API
We follow RESTful API standards.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.