reddit-style-username-generator
Version:
A utility for generating and storing unique username combinations in Redis. This package reads usernames from a file, generates combinations with specified colors and nouns, and stores them in a Redis set.
25 lines (20 loc) • 597 B
text/typescript
import { HydrateUsernamesInRedis } from '../../dist/index.js';
// Redis client configuration
const redisOptions = {
host: 'localhost',
port: 6379,
};
// Example usage function
async function main() {
const generator = new HydrateUsernamesInRedis(redisOptions);
const filePath = './combinations.txt';
const redisKey = 'available:usernames';
try {
await generator.storeUsernamesFromFile(filePath, redisKey);
await generator.getRandomUsernameFromRedis(redisKey);
} catch (error) {
console.error('Error storing usernames:', error);
}
}
// Run the main function
main();