npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@acheetahk/cloudtools

v2.4.5

Published

work with cloud server

Downloads

134

Readme

codecov build npm

Please use version greater than 2.0.0

Methods Nav

Installation

npm install @acheetahk/cloudtools

cnpm install @acheetahk/cloudtools

yarn add @acheetahk/cloudtools

Dependencies

{
  "@types/ali-oss": "^6.0.5",
  "ali-oss": "^6.11.2",
  "aliyun-sdk": "^1.12.3"
}

Usage

IP

validationIp

/**
 * Is a correct IP address
 *
 * @param ipStr `string` ipv4 or ipv6
 *
 * @returns boolean
 */
validationIp('2001:3CA1:010F:001A:121B:0000:0000:0010') // true

getIpByRequest

/**
 * Get the IP from the request
 *
 * @param requset `Request`
 *
 * @returns string
 */
getIpByRequest(request) // ip string

SLS

import { SLS } from '@acheetahk/cloudtools';

const logger = new SLS.SLSLogger('TOPIC', options);

SLS.SLSLogger args

|param|type|require| |:-:|:-:|:-:| |topic|string|true| |options|SLSOptions|true|

SLS.SLSLogger SLSOptions

see: aliyun doc

accessKeyId: string; // access secret you create
secretAccessKey: string; // access secret you create
endpoint?: string; // sls region domain. It takes priority over region.
apiVersion?: string; // 2015-06-01
project: string;
logStore: string;

SLS.SLSLogger method (logger level)

// log put =====> aliyun sls
logger.info('simple logger', 'info');
logger.error('simple logger');
logger.debug('simple logger');
logger.fatal('simple logger');
logger.trace('simple logger');
logger.fatal('simple logger');
logger.warn('simple logger');

SLS.SLSLogger method args

|param|type|require| |:-:|:-:|:-:| |value|string|true| |source|string|true|

OSS

import { OSS } from '@acheetahk/cloudtools';
import { fileToBuffer } from '@acheetahk/request';

const storage = new OSS.BaseOSS(options);

const buffer = await fileToBuffer('http://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png');

// const buffer = fs.readFileSync(<path>);

OSS.BaseOSS options

accessKeyId: string; // access secret you create
accessKeySecret: string; // access secret you create
stsToken?: string; // used by temporary authorization
bucket?: string; //  the default bucket you want to access If you don't have any bucket, please use putBucket() create one first.
endpoint?: string; // oss region domain. It takes priority over region.
region?: string; // the bucket data region location, please see Data Regions, default is oss-cn-hangzhou.
internal?: boolean; //  access OSS with aliyun internal network or not, default is false. If your servers are running on aliyun too, you can set true to save lot of money.
secure?: boolean; // instruct OSS client to use HTTPS (secure: true) or HTTP (secure: false) protocol.
timeout?: string | number; // instance level timeout for all operations, default is 60s
cname?: boolean; // use custom domain name

OSS.BaseOSS upload

// upload
const result = await storage.upload('/test/test.png', buffer);
const result1 = await storage.upload('/test/test1.png', buffer, 'put');
const result2 = await storage.upload('/test/test2.png', buffer, 'putStream');

OSS.BaseOSS upload args

|param|type|require| |:-:|:-:|:-:| |path|string|true| |fileBuffer|Buffer|true| |type|type: 'put' | 'putStream'|true|

OSS.BaseOSS delete

// delete
await storage.delete('/test/test.png');

OSS.BaseOSS delete args

|param|type|require| |:-:|:-:|:-:| |path|string|true|