# @conclurer/edelog-sync-service

> A package used to create a small server for syncing data between Edelog and third-party services

Latest version **1.0.0-beta.11** (published 2021-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @conclurer/edelog-sync-service
pnpm add @conclurer/edelog-sync-service
yarn add @conclurer/edelog-sync-service
bun add @conclurer/edelog-sync-service
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta.11 |
| Published | 2021-08-14 |
| First published | 2020-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 37.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Conclurer GmbH |
| Maintainers | marvinscharle, jacquelinelechner |

## Links

- npm: https://www.npmjs.com/package/@conclurer/edelog-sync-service
- npm.io page: https://npm.io/package/@conclurer/edelog-sync-service

## Dependencies (7)

- [ip](https://npm.io/package/ip.md) ^1.1.5
- [express](https://npm.io/package/express.md) ^4.17.1
- [is-blank](https://npm.io/package/is-blank.md) ^2.1.0
- [temp-dir](https://npm.io/package/temp-dir.md) ^2.0.0
- [form-data](https://npm.io/package/form-data.md) ^3.0.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [express-fileupload](https://npm.io/package/express-fileupload.md) ^1.2.0

## Recent versions

- 1.0.0-beta.11 (latest) — 2021-08-14
- 1.0.0-beta.10 — 2021-08-14
- 1.0.0-beta.9 — 2020-10-23
- 1.0.0-beta.8 — 2020-09-09
- 1.0.0-beta.7 — 2020-09-09
- 1.0.0-beta.6 — 2020-09-09
- 1.0.0-beta.5 — 2020-08-27
- 1.0.0-beta.4 — 2020-08-27
- 1.0.0-beta.3 — 2020-08-27
- 1.0.0-beta.2 — 2020-08-27
- 1.0.0-beta.1 — 2020-08-27
- 1.0.0-beta.0 — 2020-08-27

## README

# Edelog Sync Service

This package provides an abstract implementation for syncing customer data between their APIs and our Edelog Software.

## Setting up

```shell script
npm install
# starting dev server with logging enabled
LOGGING=TRUE npm run dev 

# start production server
npm start
```

## Environment Variables

<table>
    <thead>
        <td>Variable</td>
        <td>Values</td>
    </thead>
    <tr>
        <td><code>LOGGING</code></td>
        <td><code>true</code> or <code>false</code></td>
    </tr>
    <tr>
        <td><code>SYNC_SERVICE_API_DOMAIN</code></td>
        <td><code>https://app.edelog.com</code></td>
    </tr>
    <tr>
        <td><code>ACCESS_KEY</code></td>
        <td>String; The key needed to authorize to this api</td>
    </tr>
    <tr>
        <td><code>SYNC_SERVICE_ID</code></td>
        <td>String; The Edelog sync service ID</td>
    </tr>
    <tr>
        <td><code>SYNC_SERVICE_SECRET_KEY</code></td>
        <td>String; The Edelog secret key</td>
    </tr>
    <tr>
        <td><code>ALLOWED_IP_ADDRESSES</code></td>
        <td><code>::1, 127.0.0.1, 10.0.0.1</code> (separated with <code>, `</code>) </td>
    </tr>
</table>

## Minimal Configuration

Warning: This assumes that you have configured the Enviroment Variables described above. 

```ts
import provideSyncService from './src/server';
import {NotMatchedRecordsAction, TargetDataFormat} from './src/interfaces/schema.interface'; import {NotFoundAction} from './schema.interface';

provideSyncService({
    mapping: (inputFilePaths) => mappingFunction(inputFilePaths),
});

async function mappingFunction(inputFilePaths: string[]): Promise<TargetDataFormat> {
    console.log(inputFilePaths)
    return {
        version: 1,
        updateCollections: [
            {
                databaseName: '',
                performOnNotMatchedRecords: NotMatchedRecordsAction.Skip,
                tasks: [
                    {
                        type: 'update-data',
                        where: {},
                        update: {
                            test: 'd'
                        },
                        ifNotFound: NotFoundAction.CreateNewRecord
                    }
                ]
            }
        ],
    }
}

```


## Full Configuration

```ts
import provideSyncService from './src/server';
import {NotMatchedRecordsAction, TargetDataFormat} from './src/interfaces/schema.interface';
import {Configuration} from './src/interfaces/configuration.interface'; import {NotFoundAction} from './schema.interface';

provideSyncService({
    accessKey: 'efrgtidhsnfuwe',
    allowedIpAddresses:
        process.env.ALLOWED_IP_ADDRESSES == null || process.env.ALLOWED_IP_ADDRESSES === ''
            ? [] : (process.env.ALLOWED_IP_ADDRESSES).split(', '),
    mapping: (inputFilePaths) => mappingFunction(inputFilePaths),
    errorHandler: (errorMessage, config) => handleError(errorMessage, config),
    target: {
        syncServiceId: '',
        syncServiceSecretKey: ''
    },
    webserviceConfig: {
        logging: process.env.LOGGING === 'true',
    },
});

async function mappingFunction(inputFilePaths: string[]): Promise<TargetDataFormat> {
    return {
        version: 1,
        updateCollections: [
            {
                databaseName: '',
                performOnNotMatchedRecords: NotMatchedRecordsAction.Skip,
                tasks: [
                    {
                        type: 'update-data',
                        where: {},
                        update: {
                            test: 'd'
                        },
                        ifNotFound: NotFoundAction.CreateNewRecord
                    }
                ]
            }
        ],
    }
}

async function handleError(errorMessage: string, config: Configuration) {
    // handle errors here
}

```

## Todo

* Send request to Copy Server if something fails
* Send request to Master Server if something fails

---
_Source: https://npm.io/package/@conclurer/edelog-sync-service · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
