UNPKG

@limitly/limitly-nextjs

Version:

Official Next.js SDK for Limitly - API Key management, plans, users and request validation optimized for server-side

95 lines 3.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApiKeysModule = void 0; /** * Module for managing API Keys * Optimized for Next.js server-side rendering */ class ApiKeysModule { client; constructor(client) { this.client = client; } /** * Lists all API Keys for the authenticated owner * @param options - Request options including Next.js cache options * @returns Promise with paginated API keys */ async list(options) { return this.client.get('/keys', options); } /** * Creates a new API Key * @param data - API key creation data * @param options - Request options * @returns Promise with created API key */ async create(data, options) { return this.client.post('/keys', data, options); } /** * Gets a specific API Key by ID * @param keyId - The API key ID * @param options - Request options including Next.js cache options * @returns Promise with API key details */ async get(keyId, options) { return this.client.get(`/keys/${keyId}`, options); } /** * Updates an existing API Key * @param keyId - The API key ID * @param data - Update data * @param options - Request options * @returns Promise with updated API key */ async update(keyId, data, options) { return this.client.put(`/keys/${keyId}`, data, options); } /** * Deletes an API Key (soft delete) * @param keyId - The API key ID * @param options - Request options * @returns Promise with deletion confirmation */ async delete(keyId, options) { return this.client.delete(`/keys/${keyId}`, options); } /** * Regenerates an existing API Key * @param keyId - The API key ID * @param options - Request options * @returns Promise with regenerated API key */ async regenerate(keyId, options) { return this.client.post(`/keys/${keyId}/regenerate`, undefined, options); } /** * Gets usage statistics for an API Key * @param keyId - The API key ID * @param options - Request options including Next.js cache options * @returns Promise with usage statistics */ async getUsage(keyId, options) { return this.client.get(`/keys/${keyId}/usage`, options); } /** * Gets detailed request history for an API Key * @param keyId - The API key ID * @param options - Request options including Next.js cache options * @returns Promise with request history */ async getRequests(keyId, options) { return this.client.get(`/keys/${keyId}/requests`, options); } /** * Gets API keys with usage statistics (optimized for Next.js) * @param options - Request options * @returns Promise with API keys and their usage */ async listWithUsage(options) { return this.client.get('/keys/with-usage', options); } } exports.ApiKeysModule = ApiKeysModule; //# sourceMappingURL=api-keys.js.map