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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-mailu

v1.0.0

Published

node-mailu is a Node.js library designed to facilitate interaction with the Mailu API, an open source, self-hosted email platform. This library provides methods and functions that allow developers to programmatically manage various operations related to t

Downloads

14

Readme

node-mailu

This client library provides a convenient way to interact with a Mailu API instance. It encapsulates the necessary details for authentication and interaction with various Mailu services.

Reference: Mailu's official RestAPI documentation.: https://mailu.io/master/api.html

Installation

You can install node-mailu via npm:

npm install node-mailu

Usage

const axios = require('axios');
const MailuClient = require('node-mailu');

// Replace with your Mailu instance's endpoint and API key
const endpoint = 'https://mailu.yourdomain.com/api/v1';
const apiKey = 'YOUR_API_KEY'; 

const mailuClient = new MailuClient(endpoint, apiKey);

// Example: Creating a new user
(async () => {
    try{
        const user = await mailuClient.userService.createUser({
            email: '[email protected]',
            raw_password: 'yourpassword',
            comment: 'New user account'
        });
        console.log('User created:', user.data);
    }catch(error){
        console.error('Error creating user:', error);
    }
})();
Important Note

Your API key is stored within the mailu directory on your system, contained within the .env environment file. Reference the Mailu documentation for specifics.

Sections

  • MailuClient
    • Constructor
    • useAxios
  • Services
    • AliasService
    • AlternativeService
    • DomainService
    • RelayService
    • UserService

MailuClient

The core client for interacting with the Mailu API.

Constructor

constructor(endpoint, apiKey)
  • endpoint (string): The base URL of your Mailu API instance.
  • apiKey (string): An authorization key to access the Mailu API.

useAxios

A utility method to handle API requests using Axios.

useAxios(method, path, data)
  • method (string): The HTTP method to use ('get', 'post', etc.).
  • path (string): The endpoint path relative to the base URL.
  • data (object, optional): Data to send in the request body.

Returns: A Promise resolving with the API response data, or rejecting with an error.

Services

Each service represents a domain of functionality within the Mailu API.

AliasService

Methods for managing email aliases in Mailu.

  • getAliases() - Retrieves all aliases.
  • createAlias(body) - Creates a new alias.
  • getAliasesFromDomain(domain) - Retrieves aliases for a specific domain.
  • updateAlias(alias, body) - Updates an existing alias.
  • getAlias(alias) - Retrieves a single alias.
  • deleteAlias(alias) - Deletes an alias.

AlternativeService

Methods for managing alternative addresses (additional emails for receiving to a user's inbox).

  • getAlternatives() - Retrieves all alternative addresses.
  • createAlternative(body) - Creates a new alternative address.
  • getAlternative(alt) - Retrieves details of an alternative address.
  • deleteAlternative(alt) - Deletes an alternative address.

DomainService

Methods for managing domains in Mailu.

  • getDomains() - Lists all domains.
  • createDomain(body) - Creates a new domain.
  • updateDomain(domain, body) - Updates a domain.
  • getDomain(domain) - Retrieves details of a domain.
  • deleteDomain(domain) - Deletes a domain.
  • generateDomainKeys(domain) - Generates DKIM keys for a domain.
  • getDomainManagers(domain) - Lists managers for a domain.
  • createDomainManager(domain, body) - Adds a new domain manager.
  • deleteDomainManager(domain, email) - Removes a domain manager.
  • getDomainManager(domain, email) - Retrieves details of a domain manager.
  • getUsersFromDomain(domain) - Lists users of a domain.

RelayService

Methods for managing email relays.

  • getRelays() - Lists all relays.
  • createRelay(body) - Creates a new relay.
  • updateRelay(name, body) - Updates a relay.
  • getRelay(name) - Gets details of a relay.
  • deleteRelay(name) - Deletes a relay.

UserService

Methods for managing Mailu users.

  • getUsers() - Lists all users.
  • createUser(body) - Creates a new user.
  • updateUser(email, body) - Updates a user.
  • getUser(email) - Retrieves details of a user.
  • deleteUser(email) - Deletes a user.