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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wazdl/pelicanjs

v0.9.855

Published

A Node.js module to easily integrate a Pelican panel into a Discord bot or any Node.js application. It provides simple and efficient API access to manage users, servers, and features directly from the panel.

Readme

@wazdl/pelicanjs

A modern JavaScript/TypeScript module for interacting with the Pelican Panel API. Designed to be simple, efficient, and fully typed.

🚀 Installation

npm install @wazdl/pelicanjs

✨ Features

  • ✅ Full TypeScript support with generated types
  • ✅ Client API (user actions) and Application API (admin actions)
  • ✅ Automatic error handling with descriptive messages
  • ✅ Server and user management support
  • ✅ Power management methods (start, stop, restart, kill)
  • ✅ Server reinstallation support
  • ✅ Server deletion support (with force option)
  • ✅ Network allocations and resources management
  • ✅ Compatible with Discord.js and other frameworks
  • ✅ Automatic URL normalization
  • ✅ Configurable timeout (30s default)
  • ✅ Pelican role system support

📖 Usage

Client API (User Actions)

const { PelicanClient } = require('@wazdl/pelicanjs');

const client = new PelicanClient({
  url: 'https://panel.example.com',
  clientKey: 'your_client_api_key'
});

// Fetch a server
const server = await client.servers.fetch('server-uuid');
console.log(`Server: ${server.name}`);

// Start a server
await server.start();

// Reinstall a server
await server.reinstall();

// Delete a server (DANGEROUS!)
await server.delete(); // Normal deletion
await server.delete(true); // Force deletion (even if running)

// Get connection information
const connectionInfo = await server.getConnectionInfo();
console.log(`Connect to: ${connectionInfo.ip}:${connectionInfo.port}`);

// Resource management
const resources = await server.fetchResources();
console.log(`Status: ${resources.current_state}`);
console.log(`RAM: ${resources.resources.memory_bytes / 1024 / 1024} MB`);

Application API (Admin Actions)

const { PelicanApp, PelicanRoles } = require('@wazdl/pelicanjs');

const app = new PelicanApp({
  url: 'https://panel.example.com',
  adminKey: 'your_admin_api_key'
});

// Create a user with role system
const newUser = await app.users.create({
  username: 'testuser',
  email: '[email protected]',
  password: 'password123',
  role: PelicanRoles.USER // 'user', 'admin', 'moderator'
});

console.log(`User created: ${newUser.username} (Role: ${newUser.role})`);

// Fetch all users
const users = await app.users.fetchAll();
console.log(`${users.length} users found`);

🎭 Role System

Pelican uses a string-based role system instead of simple boolean admin flags:

const { PelicanRoles } = require('@wazdl/pelicanjs');

// Available roles
console.log(PelicanRoles.ADMIN);     // 'admin'
console.log(PelicanRoles.USER);      // 'user'
console.log(PelicanRoles.MODERATOR); // 'moderator'

// Create users with different roles
const adminUser = await app.users.create({
  username: 'admin',
  email: '[email protected]',
  password: 'password123',
  role: PelicanRoles.ADMIN
});

const regularUser = await app.users.create({
  username: 'user',
  email: '[email protected]',
  password: 'password123',
  role: PelicanRoles.USER // Default role
});

// Check user roles
console.log(adminUser.isAdmin);      // true
console.log(adminUser.hasRole('admin')); // true
console.log(regularUser.isModerator); // false

🤖 Discord Bot Integration

Updated createuser command

const { PelicanApp, PelicanRoles } = require('@wazdl/pelicanjs');

// In your createuser command
const app = new PelicanApp({
  url: client.configyaml.panel.url,
  adminKey: client.configyaml.panel.adminkey
});

try {
  const newUser = await app.users.create({
    username: args.getString("username"),
    email: args.getString("email"),
    password: args.getString("password"),
    role: args.getString("role") || PelicanRoles.USER // Use role instead of admin boolean
  });

  const embed = new Discord.EmbedBuilder()
    .setTitle("✅ User Created with PelicanJS")
    .setColor('#00FF00')
    .setDescription(`User **${newUser.username}** created successfully!`)
    .addFields(
      { name: '🆔 ID', value: `\`${newUser.id}\``, inline: true },
      { name: '👤 Username', value: `\`${newUser.username}\``, inline: true },
      { name: '📧 Email', value: `\`${newUser.email}\``, inline: true },
      { name: '🎭 Role', value: `\`${newUser.role}\``, inline: true },
      { name: '🔑 Is Admin', value: newUser.isAdmin ? '✅ Yes' : '❌ No', inline: true }
    );

  await message.reply({ embeds: [embed] });
} catch (error) {
  console.error('PelicanJS Error:', error.message);
  // Error handling...
}

Modified startserver command

const { PelicanClient } = require('@wazdl/pelicanjs');

// In your startserver command
const client = new PelicanClient({
  url: client.configyaml.panel.url,
  clientKey: client.configyaml.panel.clientkey
});

try {
  const server = await client.servers.fetch(serverID);
  await server.start();
  
  // Get connection information
  const connectionInfo = await server.getConnectionInfo();
  
  const embed = new Discord.EmbedBuilder()
    .setTitle("✅ Server Started")
    .setColor('#00FF00')
    .setDescription(`Server **${server.name}** started successfully!`)
    .addFields(
      { name: '🆔 ID', value: `\`${server.identifier}\``, inline: true },
      { name: '🌐 Connection', value: `\`${connectionInfo.ip}:${connectionInfo.port}\``, inline: true }
    );

  await message.reply({ embeds: [embed] });
} catch (error) {
  console.error('PelicanJS Error:', error.message);
  // Error handling...
}

📚 API Reference

PelicanClient (Client API)

Servers

  • servers.fetch(uuid) - Fetch a server by UUID
  • servers.fetchAll() - Fetch all servers
  • servers.fetchResources(uuid) - Fetch server resources
  • servers.fetchAllocations(uuid) - Fetch network allocations

Server Methods

  • server.start() - Start the server
  • server.stop() - Stop the server
  • server.restart() - Restart the server
  • server.kill() - Force kill the server
  • server.reinstall() - Reinstall the server
  • server.delete(force?) - Delete the server permanently
  • server.rename(name) - Rename the server
  • server.setDockerImage(image) - Change Docker image
  • server.getConnectionInfo() - Get IP:Port connection info

PelicanApp (Application API)

Users

  • users.create(options) - Create a user with role
  • users.fetch(id) - Fetch a user by ID
  • users.fetchAll() - Fetch all users
  • users.delete(id) - Delete a user
  • users.update(id, options) - Update a user

User Methods

  • user.hasRole(role) - Check if user has specific role
  • user.isAdmin - Check if user is admin
  • user.isModerator - Check if user is moderator

⚙️ Configuration

interface PelicanConfig {
  url: string;           // Pelican panel URL
  clientKey?: string;    // Client API key (for user actions)
  adminKey?: string;     // Admin API key (for admin actions)
}

interface CreateUserOptions {
  username: string;
  email: string;
  password: string;
  role?: string;         // 'admin', 'user', 'moderator'
  first_name?: string;
  last_name?: string;
}

🛠️ Error Handling

The module throws descriptive errors that you can catch:

try {
  const server = await client.servers.fetch('invalid-uuid');
} catch (error) {
  console.error('Error:', error.message);
  // "Pelican API Error: Server not found"
}

📝 TypeScript Support

This module is written in TypeScript and includes all type definitions:

import { PelicanClient, PelicanApp, Server, User, PelicanRoles } from '@wazdl/pelicanjs';

const client = new PelicanClient({
  url: 'https://panel.example.com',
  clientKey: 'your_key'
});

// Types are automatically inferred
const server: Server = await client.servers.fetch('uuid');
const resources: ServerResourcesData = await server.fetchResources();

🔧 Advanced Examples

Role Management

const users = await app.users.fetchAll();

// Filter by role
const admins = users.filter(user => user.hasRole(PelicanRoles.ADMIN));
const moderators = users.filter(user => user.isModerator);
const regularUsers = users.filter(user => user.hasRole(PelicanRoles.USER));

console.log(`${admins.length} administrators found`);
console.log(`${moderators.length} moderators found`);
console.log(`${regularUsers.length} regular users found`);

Server Deletion (DANGEROUS!)

const app = new PelicanApp({
  url: 'https://panel.example.com',
  adminKey: 'your_admin_key'
});

// Get server by ID
const server = await app.servers.fetchById(123);

// Delete server (normal)
await server.delete();

// Force delete server (even if running)
await server.delete(true);

// Or use the manager directly
await app.servers.delete(123); // Normal deletion
await app.servers.delete(123, true); // Force deletion

Server Monitoring

const server = await client.servers.fetch('uuid');
const resources = await server.fetchResources();

console.log(`Status: ${resources.current_state}`);
console.log(`RAM: ${(resources.resources.memory_bytes / 1024 / 1024).toFixed(2)} MB`);
console.log(`CPU: ${resources.resources.cpu_absolute.toFixed(2)}%`);
console.log(`Uptime: ${Math.floor(resources.resources.uptime / 3600)}h`);

Batch User Management

const users = await app.users.fetchAll();
const adminUsers = users.filter(user => user.isAdmin);

console.log(`${adminUsers.length} administrators found`);
for (const admin of adminUsers) {
  console.log(`- ${admin.username} (${admin.email}) - Role: ${admin.role}`);
}

📋 Requirements

  • Node.js 14.16 or higher
  • A working Pelican Panel instance
  • Valid API keys (client and/or admin)

🔍 Troubleshooting

Common Issues

  1. "Pelican API Error: Unauthorized"

    • Check your API key is correct
    • Ensure the key has the right permissions
  2. "Server not found"

    • Verify the server UUID is correct
    • Check if the server exists in the panel
  3. Connection timeout

    • Check your panel URL is accessible
    • Verify firewall settings

🤝 Contributing

Contributions are welcome! Please feel free to:

  1. Fork the project
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

📄 License

MIT License - see the LICENSE file for details.

🔗 Links

🙏 Acknowledgments

  • Thanks to the Pelican Panel team for their excellent API
  • Inspired by the need for better Discord bot integration
  • Built with modern JavaScript/TypeScript best practices

Developed with ❤️ by WazdL for the community