sdqri / rigelsdk

Typescript SDK for rigel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rigelsdk

Typescript SDK for rigel

Issues GitHub pull requests GitHub Downloads GitHub Total Downloads GitHub release
Report Bug / Request Feature

Getting started

Installation

Install with yarn or npm: yarn or npm:

# yarn
yarn add rigelsdk
# npm
npm i rigelsdk --save

Import the lib with es6 or cjs

// es6
import rigelsdk from 'rigelsdk';
// cjs
const rigelsdk = require('rigelsdk');

Usage examples

#!/usr/bin/env node
const KEY = 'secretkey';
const SALT = 'secretsalt';
const BASE_URL = '<put rigel url here>'; //~http://localhost:8080/rigel

const rigelSDK = new rigelsdk.SDK(BASE_URL, KEY, SALT);

const proxyURL = await rigelSDK.proxyImage(
  'https://www.pakainfo.com/wp-content/uploads/2021/09/image-url-for-testing.jpg',
  new rigelsdk.Options({ Width: 100, Height: 100, Type: ImageType.WEBP }),
  Date.now() + 1000 * 60 * 60 * 24, // 1 day expiry
);

// Creating short url
const shortURL = await rigelSDK.tryShortURL(
  'https://www.pakainfo.com/wp-content/uploads/2021/09/image-url-for-testing.jpg',
  new rigelsdk.Options({ Width: 100, Height: 100, Type: ImageType.WEBP }),
  Date.now() + 1000 * 60 * 60 * 24, // 1 day expiry
);

// BatchedCache
const batchedCachedImageArgs: models.ProxyParams[] = [
  new models.ProxyParams({
    img: 'https://www.pakainfo.com/wp-content/uploads/2021/09/image-url-for-testing.jpg',
    options: new models.Options({
      Height: 100,
      Width: 100,
      Type: ImageType.WEBP,
    }),
  }),
  new models.ProxyParams({
    img: 'hhtps://img.freepik.com/premium-photo/baby-cat-british-shorthair_648604-47.jpg',
    options: new models.Options({
      Height: 100,
      Width: 100,
      Type: ImageType.WEBP,
    }),
  }),
];
const result: models.CacheImageResponse[] = await rigelSDK.batchedCacheImage(batchedCachedImageArgs, -1);

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE.txt for more information.

About

Typescript SDK for rigel

License:Apache License 2.0


Languages

Language:TypeScript 100.0%