0.4.0 • Published 3 years ago
ts-limiter v0.4.0
Limiter TypeScript SDK
Installation
With npm:
npm install ts-limiter
With yarn:
yarn add ts-limiter
Quick Usage
Default Backend
Initialize SDK with the managed storage backend
import { Limiter } from 'ts-limiter';
const opts = {
backend: 'Default',
apiToken: 'api-token',
};
const client = new Limiter('project-id', opts);
S3 Backend (Deprecated)
Initialize SDK with a private S3 bucket storage
import { Limiter } from 'ts-limiter';
const opts = {
backend: 'S3',
s3Bucket: 's3-bucket',
region: 'us-east-1',
accessKeyId: 'access-key-id',
secretAccessKey: 'secret-access-key',
};
const client = new Limiter('project-id', opts);
Available Methods
// Bind user to a plan
await client.bind('plan-name', 'user-id');
// Check if a feature is within limit
if (await client.feature('feature-name', 'user-id')) {
// Pass
}
// Increment usage by 1.
await client.increment('feature-name', 'user-id');
// Decrement usage by 1.
await client.decrement('feature-name', 'user-id');
// Set usage to some value.
await client.set('feature-name', 'user-id', 5);
// Get feature matrix for the project
const featureMatrix = await client.featureMatrix();
// Get user's usage data
const usage = await client.usage('user-id');
0.4.0
3 years ago
0.3.1
3 years ago
0.3.0
3 years ago
0.2.1
3 years ago
0.2.0
3 years ago
0.1.17
3 years ago
0.1.16
3 years ago
0.1.15
3 years ago
0.1.14
3 years ago
0.1.13
3 years ago
0.1.12
3 years ago
0.1.11
3 years ago
0.1.10
3 years ago
0.1.9
3 years ago
0.1.8
3 years ago
0.1.7
3 years ago
0.1.6
3 years ago
0.1.5
3 years ago
0.1.4
3 years ago
0.1.3
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago