@wholebuzz/archive-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

@wholebuzz/archive-client

Archive database client. See archive.

Example

import { ArchiveDatabase } from '@wholebuzz/archive-base'
import { 
  ArchiveBlockDatabaseClient, 
  ArchiveTipDatabaseClient,
} from '@wholebuzz/archive-client/lib/archive'
import {
  fetchContentWithAxiosAndGzip,
  fetchContentWithAxiosAndPako,
  newAxiosCancelToken,
} from '@wholebuzz/archive-client/lib/axios'

const fetchFn = typeof window === 'undefined'
    ? fetchContentWithAxiosAndGzip
    : fetchContentWithAxiosAndPako,
const cancelToken = newAxiosCancelToken()
const disposableFetchFn = (url: string) => fetchFn(url, { cancelToken: cancelToken.token })

const archive = new ArchiveDatabase<Event>(
    'news',
    [
      {
        name: 'publisher',
        getter: getEventPublishers,
        sorter: compareEventReverse,
        blockDatabase: new ArchiveBlockDatabaseClient<Event>(
          'https://archive.storage.googleapis.com',
          parseNewsItem,
          disposableFetchFn
        ),
        tipDatabase: new ArchiveTipDatabaseClient(
          'https://archive-index.storage.googleapis.com',
          sha1,
          disposableFetchFn
        ),
      },
    ],
    {
      dispose: () => cancelToken.cancel(),
      strictOrdering: true,
    }
  )
}

const tipBlock = await archive.findTipBlock('publisher', 'theatlantic.com')

Table of contents

Modules

Readme

Keywords

none

Package Sidebar

Install

npm i @wholebuzz/archive-client

Weekly Downloads

0

Version

0.0.2

License

Apache-2.0

Unpacked Size

41.4 kB

Total Files

17

Last publish

Collaborators

  • wholenewsorg