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-tserver

v1.0.2

Published

Create terraria server in javascript

Downloads

34

Readme

Fast setup

Ngrok routing

Auto-save system

Note

• You might need a 100mb free storage for installation and setup of terraria server

• Recommended for 2gb+ ram for less lag

• Your progress will be loss if you dont save it

• Terraria Files is saved at your project root or project cwd

Soon to make

  • Server Plugins
  • User authorization system

Fixes

  • Terraria Folder not loading and saving
  • Commands not working

Documentation

  • Creating your first Server is not that hard
  • You just need to have 100mb free in your storage
  • To create your server, follow this example
const { TerrariaServer } = require('node-tserver') // Import the package into your code

const server = new TerrariaServer({ // Create your very first terraria server
  // as i said the setup is easy
  
  version: "1.4.3.2", // put your terraria version here
  
  world: { // provide info for your world
    name: 'my world', // your worlds name is very important
    difficulty: "journey", // put the difficulty you want (defaults to 'classic')
    size: "medium", // put the world size you want (defaults to 'small')
    evil: "1", // the evil is not tested yet!
    seed: "none", // put none to generate random seed, or if you have an specific seed put it here
  },

  autosave: "5m", // this means that it will save every 5 minutes, more like a autosave system

  server: { // most important setup

    ngrok: { // if you dont want ngrok, just dont put it
      // go here to specify the options of ngrok, "https://npmjs.com/package/ngrok#Options"
      authtoken: 'my ngrok auth token',
      region: 'eu'
    },

    admins: [
      "me6969" // all admins you want for your save "NOTE: PUT NAME ONLY HERE"
    ],

    banlist: [
      "hecker420" // all players you want to ban (put only name here)
    ],

    maxplayers: "8", // put here how many players can join in your server

    serverport "7777", // put what port you want your server to tunnel, (defaults to '7777')

    forwardport: "false", // if you want automatically forward port, put "true" here

    password: "none", // if you dont want any password put none, or if you want one just put it here

    motd: "My Motd" // put your motd here
  }
})
  • A setup without ngrok
const { TerrariaServer } = require('node-tserver') // Import the package into your code

const server = new TerrariaServer({ // Create your very first terraria server
  // as i said the setup is easy
  
  version: "1.4.3.2", // put your terraria version here
  
  world: { // provide info for your world
    name: 'my world', // your worlds name is very important
    difficulty: "journey", // put the difficulty you want (defaults to 'classic')
    size: "medium", // put the world size you want (defaults to 'small')
    evil: "1", // the evil is not tested yet!
    seed: "none", // put none to generate random seed, or if you have an specific seed put it here
  },

  autosave: "5m", // this means that it will save every 5 minutes, more like a autosave system
  
  server: { // most important setup

    admins: [
      "me6969" // all admins you want for your save "NOTE: PUT NAME ONLY HERE"
    ],

    banlist: [
      "hecker420" // all players you want to ban (put only name here)
    ],

    maxplayers: "8", // put here how many players can join in your server

    serverport "7777", // put what port you want your server to tunnel, (defaults to '7777')

    forwardport: "false", // if you want automatically forward port, put "true" here

    password: "none", // if you dont want any password put none, or if you want one just put it here

    motd: "My Motd" // put your motd here
  }
})
  • Start your server with
server.start()
  • TerrariaServer have some events too
// The 'started' event will fire when the server started
server.on('started', async(control, host) => {
  console.log(host) // Host only exists if you use ngrok

  control.save() // saves your progress

  control.send('say Hi Im Sending This') // sends command in the terminal

  control.close() // stop your server with save
})

// The 'connected' event will fire if there is a player joined in your server
server.on('connected', async(user) => {
  console.log('User Joined '+user)
})

// The 'disconnected' event will fire if there is a player leaved in your server
server.on('disconnected', async(user) => {
  console.log('User Leaved '+user)
})

// The 'chat' event will fire when a player sends a message in chats
server.on('chat', async(user, msg, reply) => {
  reply(user+' said '+msg) // the reply function will send message in the chat
})

Want to create commands?

  • Follow this setup if you want a command!
const { TerrariaServer } = require('node-tserver') // Import the package into your code

const server = new TerrariaServer({ // Create your very first terraria server
  // as i said the setup is easy
  
  version: "1.4.3.2", // put your terraria version here
  
  world: { // provide info for your world
    name: 'my world', // your worlds name is very important
    difficulty: "journey", // put the difficulty you want (defaults to 'classic')
    size: "medium", // put the world size you want (defaults to 'small')
    evil: "1", // the evil is not tested yet!
    seed: "none", // put none to generate random seed, or if you have an specific seed put it here
  },

  autosave: "5m", // this means that it will save every 5 minutes, more like a autosave system

  server: { // most important setup

    ngrok: { // if you dont want ngrok, just dont put it
      // go here to specify the options of ngrok, "https://npmjs.com/package/ngrok#Options"
      authtoken: 'my ngrok auth token',
      region: 'eu'
    },

    // here how you enable it
    command: { // enable it by doing this
      prefix: "/" // put the prefix you want here
    },
    // just add this 3 lines on your options

    admins: [
      "me6969" // all admins you want for your save "NOTE: PUT NAME ONLY HERE"
    ],

    banlist: [
      "hecker420" // all players you want to ban (put only name here)
    ],

    maxplayers: "8", // put here how many players can join in your server

    serverport "7777", // put what port you want your server to tunnel, (defaults to '7777')

    forwardport: "false", // if you want automatically forward port, put "true" here

    password: "none", // if you dont want any password put none, or if you want one just put it here

    motd: "My Motd" // put your motd here
  }
})

now everytime a user chats a message that starts with "/", it will be specified as a command

thats gonna fire the "command" event

server.on('command', cmd => {
  // it will return a "cmd" object

  console.log(cmd)

  // cmd returns an object
  // cmd.command - this is the name of the command that was runned
  // cmd.arguments - all arguments that was recieve from the command
  // cmd.control - returns the control methods from the server
  // cmd.message - returns the full message object
})

I created built-in commands

- time (dawn, noon, dusk, midnight) : Change the time status
- admin add <username> : adds a user to the admins
- admin delete <username> : removes a user to the admins
- banlist add <username> : adds a user to the banlist 
- banlist delete <username> : removes a user to the banlist

Note: Only users you put in admins, can access command!

...

I used dedicated server than TShock is because some TShock versions doesnt work in linux (and ofc in Replit)

Yeah the other one is broken

Links Used

  • https://terraria.org
  • https://replit.com

A Bug?

• Currently testing so

• Email me at: [email protected]

Thanks For Downloading 💛