feat: add minimal connector

This commit is contained in:
Jovan Krunić
2018-12-03 17:10:03 +01:00
commit d332f6e6b5
14 changed files with 4834 additions and 0 deletions

43
README.md Normal file
View File

@@ -0,0 +1,43 @@
# minimal-connector
## Prerequisites:
* `node` (version 8+) 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`.