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

mc_on_ec2

v1.0.1

Published

mc_on_ec2 is a promise-based wrapper for the AWS V3 Javascript SDK that makes it easy to manage Minecraft servers.

Downloads

4

Readme

mc_on_ec2

Overview

mc_on_ec2 is a promise-based wrapper for the AWS V3 Javascript SDK that makes it easy to manage Minecraft servers. This module was written in typescript and includes a bash script to configure the Minecraft server and restart it when the instance boots.

Features

API includes functions that allow you to:

A 1.20.4 Minecraft server will be running at all times when the instance is functional and the game state will be preserved across instance restarts.

Usage

To install through NPM, run the following command:

npm i mc_on_ec2

To use this package you must be authenticated with AWS. Follow this link for the latest best practices.

API

Launch

createServer(playerCount: number): Promise<server>

This function will create an EC2 instance running a version 1.20.4 Minecraft server. Networking security policies will be correctly configured and an elastic IP will be created to persist the IP address across instance restarts.

Input

playerCount: a number greater than 1 that indicates the maximum expected player count. This will determine the EC2 instance type to launch as follows:

1 < playerCount < 10 = c6i.large
10 <= playerCount < 20 = c6i.xlarge
20 <= playerCount = c6i.2xlarge

Output

Promise<server>: This promise will conform to the server interface. It will resolve once the server is fully functional. It will be rejected if there are any errors with the AWS call.

Example

import { createServer } from "mc_on_ec2";

createServer(5)
.then((result)=>console.log(result)) // {id: "i-example", ip: "1.1.1.1"}
.catch((error)=> console.log(error)); // May be rejected if the user has not completed AWS authentication procedures.

Stop

stopServer(instanceID: string): Promise<void>

This function will stop the specified server. This will preserve the play-state of the game for all players while minimizing the hosting cost when the server is not in use.

Input

instanceID: A valid EC2 instance ID. Intended to be used in tandem with the output of the createServer function.

Output

Promise<void>: This promise will resolve once AWS has received the stop command. This promise will be rejected if there are any errors with the AWS call.

Example

import { stopServer } from "mc_on_ec2";

stopServer("i-example")
.catch((error)=> console.log(error)); // May be rejected if the user has not followed AWS authentication procedures.

Start

startServer(instanceID: string): Promise<void>

This function will start the specified server. This is intended to be used after the stopServer function in order to resume server functionality.

Input

instanceID: A valid EC2 instance ID. Intended to be used in tandem with the output of the createServer function.

Output

Promise<void>: This promise will resolve once the server is fully functional. This promise will be rejected if there are any errors with the AWS call.

Example

import { startServer } from "mc_on_ec2";

startServer("i-example")
.catch((error)=> console.log(error)); // May be rejected if the user has not followed AWS authentication procedures.

Reboot

rebootServer(instanceID: string): Promise<void>

This function will restart the specified EC2 instance in case of issues with the operating system or Minecraft server.

Input

instanceID: A valid EC2 instance ID. Intended to be used in tandem with the output of the createServer function.

Output

Promise<void>: This promise will resolve once the server is fully functional. This promise will be rejected if there are any errors with the AWS call.

Example

import { rebootServer } from "mc_on_ec2";

rebootServer("i-example")
.catch((error)=> console.log(error)); // May be rejected if the user has not followed AWS authentication procedures.

Terminate

terminateServer(instanceID: string): Promise<void>

This function will terminate the specified EC2 instance and associated elastic IP. Warning: This is not reversible and the game state will be lost. Warning: This will terminate both the instance and the elastic IP. Use carefully when deleting servers not generated using this module.

Input

instanceID: A valid EC2 instance ID. Intended to be used in tandem with the output of the createServer function.

Output

Promise<void>: This promise will resolve once AWS has received the termination command. This promise will be rejected if there are any errors with the AWS call.

Example

import { terminateServer } from "mc_on_ec2";

terminateServer("i-example")
.catch((error)=> console.log(error)); // May be rejected if the user has not followed AWS authentication procedures.

Types

server

interface server {
    'id': string,
    'ip': string;
}

The id declaration represents the AWS EC2 instance ID. The ip declaration represents the elastic IP associated with the instance.

License

MIT