0.3.0 • Published 10 months ago

@outsidecube/db-api-sync v0.3.0

Weekly downloads
-
License
BSD 2.0
Repository
github
Last release
10 months ago

Getting started

Installation

Install this library

npm install --save @outsidecube/db-api-sync

Configuration

In order to configure this you will need to provide.

1. Processor object

Before you start using the Synchronizer, you will need to write a class that implements HTTPResponseProcessor, with the following signature: readEntities(callback: EntityFetchCallback, originalRequest: HTTPRequest): Promise<void>

This would be a minimal example:

import {
  EntityDef,
  EntityFetchCallback,
  HTTPRequest,
  HTTPResponseProcessor,
} from '@outsidecube/db-api-sync';

export default class MyCustomProcessor implements HTTPResponseProcessor {
  async readEntities(
    callback: EntityFetchCallback,
    entityDef: EntityDef,
    originalRequest: HTTPRequest,
  ): Promise<void> {
    const r: Response = await originalRequest.fetch();
    const { data } = await r.json();
    for (const element of data) {
      await callback(entityDef, element);
    }
  }
}

2. Configuration Object

The configuration object has a structure defined in SynchronizerConfig.ts. It has the following elements:

{
  baseURI: "[base URI for API]",
  fetchers: [
    {
      name: "default",
      default: true,
      type: "RESTEntityFetcher",
      config: {
        //here comes the custom procesor defined
        "responseProcessor": new MyCustomProcessor(); 
      }
    }
  ]
}

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. The starting point for contributing is understanding the class design:

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2023 Outside The Cube. This project is BSD licensed.

0.3.0

10 months ago

0.2.1

11 months ago

0.2.0

11 months ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.9

12 months ago

0.2.3

11 months ago

0.2.2

11 months ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.0.4

1 year ago