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

pgmjah-tserver

v1.0.32

Published

Simple HTTP server for lightweight web development.

Downloads

80

Readme

tserver README

Simple Node.js http server...just used for lightweight development purposes.

Install/Run

  • Global - npm install -g pgmjah-tserver will install as a global node program. To run: tserver config.json (will default to current working dir as webRoot).
  • Local - npm install pgmjah-tserver. To run node test.server.js config.json

Note: If you run tserver without a config file, the server will use the current working directory (cwd) as the app root, and listen on port 8000.

Config

You can use a '.env' file (optional) to set the default environment values (process.env) for all the server's configuration properties:

TSERVER_PORT=8000
TSERVER_LOG=false
TSERVER_SILENT=false
TSERVER_PLUGINS=["./somePlugin.js"]
TSERVER_PATH_TOKENS={TOKEN:"some/dir/to/replace"}
TSERVER_PLUGINS=["./pluginTest.js"]
TSERVER_WEBROOT_ALIAS=some_alias
TSERVER_WEBROOT_DIR=C:/dev/tserver
TSERVER_WEBAPP_MAPS=[{"alias":"some_alias", "dir":"actual/dir"}]

You can also specify a config file to override any settings in the environment:

{
	"server":
	{
		"port":8000,
		"log":false,
		"silent":false,
		"plugins":[
			'path/to/plugin/plugin.js'
		],
		"pathTokens":{
			"TOKEN":"C:/path/for/token"
		}
	},
	"webApp":
	{
		"webRoot":{"alias":"some_root_name", "dir":"some/dir"},
		"maps":
		[
			{"alias":"map_dir", "dir":"C:/some_dir/some_dir/dir_to_map"}
			{"alias":"token_dir", "dir":"{TOKEN}/some_dir/dir_to_map"}
		]
	}
	
}
  • server - global settings for the server.
    • log - write all server requests to 'test.server.log.txt'.
    • silent - don't log information to the console.
    • plugins - an array of paths to the plugin files you want loaded.
      • plugin - an exported object with functions:
        • resolveUrl(filePath, srvPath, headers) - can inspect the requested path, and return a different path (redirect).
        • preprocessData(data, headers, filePath, srvPath) - can return an object with {data, headers}, which will be returned in the response.
      • pathTokens - an object with keys you can use in a mapped path, or a plugin path (surrounded by {}), that will be replaced when processed.
  • webApp - information about how to configure the server for the app.
  • port - the port for the server to listen on for the app (default 8000).
  • webRoot - object with the web app's root directory (above which you can't navigate).
    • alias - the name of the root you want to use in the url (default "/").
    • dir - the physical directory mapped to the alias (default current working directory).
  • maps - Optional array of objects to map url aliases to physical directories.
    • alias - the name of directory you want to use in the url.
    • dir - the physical directory mapped to the alias.

Commands

  • cls - Clear the screen.
  • clog - Clear the current log file.
  • log - pipe the current log file to the screen.

Changelog

  • 1.0.32 - Added Header Access-Control-Allow-Origin * to all responses.

  • 1.0.31 - Updated readme.md.

  • 1.0.30 - Fixed ping issue.

  • 1.0.29 - Added url '/tserver/ping' to test if server is running.

  • 1.0.28 - Updated packaging.

  • 1.0.27 - Updated packaging.

  • 1.0.26 - Added support for .env file so default config variables can be set outside of the config file.

  • 1.0.25 - Changed plugin 'preprocessData' to take an object with various paths. Also, plugin path's can also use the pathTokens.

  • 1.0.24 - More work on plugins.

  • 1.0.23 - More work on plugins.

  • 1.0.22 - Added plugins.

  • 1.0.21 - Added svg mime type.

  • 1.0.20 - Show ip address and port on startup so we know where, and what we're listening on.

  • 1.0.19 - Fixed deprecated octal in logReset.

  • 1.0.18 - Added config option for settings.silent to stop logging to console. Also exported TestServer so it can be run from other modules.

  • 1.0.17 - Better startup information about config file, mappings, etc.

  • 1.0.16 - Fixed mapped directory resolution when mapped value was actually part of the endpoint of the url.

  • 1.0.15 - Added better default config handling...if you don't supply various values, I'll overlay defaults on top.