1.1.2 • Published 11 months ago

@dvcol/synology-http-client v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Simple fetch based http client for Synology API with full typescript support (request and response).

Prerequisites

  • pnpm >=9.0.0
  • node >=20.0.0

Install

pnpm install

Usage

pnpm add @dvcol/synology-http-client

Modular endpoint bundling

synology-http-client is designed to be modular and flexible. Although it uses static classes, endpoints are instantiated at runtime and can be easily omitted, extended or overridden. If your bundler does not support tree-shaking, you can omit unused endpoints by only importing the ones you need.

By default we provide a full api object with all supported endpoints, as well as a minimal api object with only the essential authentication endpoints. You can also import any endpoint by common scope.

import { SynologyClient } from '@dvcol/synology-http-client';

import { download } from '@dvcol/synology-http-client/api/download';
import { file } from '@dvcol/synology-http-client/api/file';
import { minimalSynologyApi } from '@dvcol/synology-http-client/api/minimal';
import { Config } from '@dvcol/synology-http-client/config';

import type { SynologyClientSettings } from '@dvcol/synology-http-client/models';

export const api = {
  ...minimalSynologyApi,
  download,
  file
};

export const settings: SynologyClientSettings = {
  name:'<Your client name>',
  endpoint: Config.endpoint,
  
  corsProxy: '<Optional cors Proxy>',
  corsPrefix: '<Optional cors Proxy prefix>',
};

const authenticaiton = {}

const client = new SynologyClient(settings, authenticaiton, api);

Features

Documentation

See Synology API documentation for more information.

Author

📝 License

This project is MIT licensed.