@limitly/limitly-nextjs
Version:
Official Next.js SDK for Limitly - API Key management, plans, users and request validation optimized for server-side
96 lines • 2.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UsersModule = void 0;
/**
* Module for managing Users
* Optimized for Next.js server-side rendering
*/
class UsersModule {
client;
constructor(client) {
this.client = client;
}
/**
* Lists all users
* @param options - Request options including Next.js cache options
* @returns Promise with paginated users
*/
async list(options) {
return this.client.get('/users', options);
}
/**
* Creates a new user
* @param data - User creation data
* @param options - Request options
* @returns Promise with created user
*/
async create(data, options) {
return this.client.post('/users', data, options);
}
/**
* Gets a specific user by ID
* @param userId - The user ID
* @param options - Request options including Next.js cache options
* @returns Promise with user details
*/
async get(userId, options) {
return this.client.get(`/users/${userId}`, options);
}
/**
* Updates an existing user
* @param userId - The user ID
* @param data - Update data
* @param options - Request options
* @returns Promise with updated user
*/
async update(userId, data, options) {
return this.client.put(`/users/${userId}`, data, options);
}
/**
* Deletes a user
* @param userId - The user ID
* @param options - Request options
* @returns Promise with deletion confirmation
*/
async delete(userId, options) {
return this.client.delete(`/users/${userId}`, options);
}
/**
* Gets user usage statistics
* @param userId - The user ID
* @param options - Request options including Next.js cache options
* @returns Promise with user usage
*/
async getUsage(userId, options) {
return this.client.get(`/users/${userId}/usage`, options);
}
/**
* Gets all API Keys for a user
* @param userId - The user ID
* @param options - Request options including Next.js cache options
* @returns Promise with user API keys
*/
async getKeys(userId, options) {
return this.client.get(`/users/${userId}/keys`, options);
}
/**
* Creates a new API Key for a user
* @param userId - The user ID
* @param data - API key creation data
* @param options - Request options
* @returns Promise with created API key
*/
async createKey(userId, data, options) {
return this.client.post(`/users/${userId}/keys`, data, options);
}
/**
* Gets users with usage statistics (optimized for Next.js)
* @param options - Request options
* @returns Promise with users and their usage
*/
async listWithUsage(options) {
return this.client.get('/users/with-usage', options);
}
}
exports.UsersModule = UsersModule;
//# sourceMappingURL=users.js.map