UNPKG

2.04 kBMarkdownView Raw
1# @hmcts/draft-store-client
2
3[![Greenkeeper badge](https://badges.greenkeeper.io/hmcts/draft-store-client.svg)](https://greenkeeper.io/)
4
5[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
6
7This is a client library for interacting with the [draft store api](https://github.com/hmcts/draft-store)
8
9To configure the draft store client you need to:
10
11* Implement the ServiceAuthTokenFactory interface.
12```
13export interface ServiceAuthTokenFactory {
14 get (): Promise<ServiceAuthToken>
15 }
16```
17
18* Sample implementation:
19```
20let token: ServiceAuthToken
21
22export class ServiceAuthTokenFactoryImpl implements ServiceAuthTokenFactory{
23 async get (): Promise<ServiceAuthToken> {
24 if (token === undefined || token.hasExpired()) {
25 token = await IdamClient.retrieveServiceToken()
26 }
27 return token
28 }
29}
30```
31# API available with clients
32* DraftService provides wrapper around creating DraftStoreClientFactory to save and delete draft documents
33* DraftStoreClientFactory is responsible for creating DraftStoreClients
34* DraftStoreClient is responsible for search, save and delete of draft store data
35* DraftMiddleware manages number of draft store client can be configured and is available if user is logged in
36
37# To add library
38
39```
40yarn add @hmcts/draft-store-client
41```
42
43## Getting Started
44
45### Prerequisites
46
47* [Node.js](https://nodejs.org/) >= v8.7.0
48* [yarn](https://yarnpkg.com/)
49
50### Running the application
51
52Install dependencies by executing the following command:
53
54 ```bash
55$ yarn install
56 ```
57
58## Developing
59
60### Code style
61
62We use [TSLint](https://palantir.github.io/tslint/) with [StandardJS](http://standardjs.com/index.html) rules
63
64Running the linting:
65`yarn lint`
66
67### Running the tests
68
69Mocha is used for writing tests.
70
71Run them with:
72
73```bash
74$ yarn test
75```
76
77For test coverage:
78
79```bash
80$ yarn test:coverage
81```
82
83## License
84
85This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details
86