0.3.0 • Published 2 years ago

@outsidecube/db-api-sync v0.3.0

Weekly downloads
-
License
BSD 2.0
Repository
github
Last release
2 years 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

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.4

2 years ago