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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@samtayl/start-app

v0.1.0

Published

Serve an application with nice logging and extendable configuration.

Readme

start-app

  • Serves an application from a file
  • Reads a config from a file and passes it to the application
  • Logs clearly and passes the logger to the application

Installation

npm:

npm i @samtayl/start-app

yarn:

yarn i @samtayl/start-app

Usage

Create an app.js file in the package directory. This must export a function which returns a request handler for the server.

export default function() {
  return function(req, res) {
    res.end('Hello, World! :3');
  };
};

Run start-app to start the server and serve the app.

By default, the server listens at http://127.0.0.1:8000.

Configuration

Configuring your app

Create a config.json file in the package directory. This object will be passed to the exported function in the app.js file.

{
  "greeting": "Hello, World! :3"
}
export default function(options) {
  return function(req, res) {
    res.end(options.greeting); // "Hello, World! :3"
  };
};

Configuring start-app

These config.json properties will change the behaviour of start-app:

| config.json property | type | format | default | description | | ---------------------- | -------- | ----------------------------------------------------------------------- | ------------- | ----------------------------------------------- | | appPath | string | A pathname relative to where the start-app command is ran. | "app.js" | The pathname of the file which your app is in. | | logLevel | string | One of 'silly', 'debug', 'verbose', 'http', 'info', 'warn', or 'error'. | "info" | The log level which should be displayed. | | port | number | A valid port. | 8000 | The port which the server should listen on. | | hostname | string | A valid hostname. | "127.0.0.1" | The hostname which the server should listen on. |

CLI options and environment variables

start-app uses convict to validate it's configuration and to enable a hierarchy of configuration methods. As such, the previously listed config.json properties are also available as the following command line arguments and environment variables:

| config.json property | command line argument | environment variable | | ---------------------- | --------------------- | -------------------- | | appPath | --appPath | APP_PATH | | logLevel | --logLevel | LOG_LEVEL | | port | --port | PORT | | hostname | --hostname | HOSTNAME |

Lastly, the path of the config file can also be changed:

| command line argument | environment variable | format | default | description | | --------------------- | -------------------- | ------------------------------------------------------------ | --------------- | ------------------------------------------------- | | --configPath | CONFIG_PATH | A pathname relative to where the start-app command is ran. | "config.json" | The pathname of the file which your config is in. |

Custom config schema

Create a configSchema.js file. This must export a convict instance as demonstrated by their documentation.

import convict from 'convict';

export default convict({
  greeting: {
    doc: 'The greeting to give',
    format: String,
    default: 'Hello. World. :|',
    env: 'GREETING',
    arg: 'greeting',
  },
});

Your configuration in config.json will now be validated against this schema. You may override the config.json properties listed above to change default values or command line argument and environment variable names.

Logging

The logger used to output from start-app will also be passed to your app. It is a winston instance.

export default function(options, logger) {
  return function(req, res) {
    logger.info("Hello, Console! :[]");

    res.end("Hello, World! :3");
  };
};