Files
openstapps/README.md
2019-01-29 16:04:03 +01:00

44 lines
1.2 KiB
Markdown

# @openstapps/minimal-connector
## Prerequisites:
* `node` (version 10+) and `npm` installed
* a backend, which is running locally (on http://localhost:3000) --- for testing purposes, it is advisable to use `minimal-deployment` project
## How to get started
To install all needed `npm` packages:
```sh
npm install
```
To prepare the script to be executed, run:
```sh
npm run build
```
To execute the code in "CLI" script (basically to execute the connector):
```sh
node lib/cli.js
```
To run some sample tests, use:
```sh
npm test
```
The `npm` scripts are defined in `package.json` file.
## Code structure
File [src/main.ts](src/index.ts) contains:
* `MinimalConnector` as class with sample `getItems()` method, which simulates fetching of items from a resource and validator property which is useful for validating items against **StAppsCore**
* sample indexing methods: `parse`, `bulk`, `index` and `finish`
File [src/cli.ts](src/cli.ts) contains:
* instantiation of a client
* calls to asynchronous indexing methods using `auto` method of `async` library
File [test/MinimalConnector.spec.ts](test/MinimalConnector.spec.ts) contains sample test suite using `mocha` and `chai`.