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

serve-og

v1.0.0

Published

A simple Node.js server designed to serve static files and provide basic error handling for development and testing purposes.

Downloads

66

Readme

serve-og

Simple & lightweight.

Overview

serve-og is a lightweight Node.js server designed for serving HTML files locally. Ideal for development and testing, this package allows you to quickly set up a local server that serves static HTML files from a specified directory.

Features

  • Serve an HTML file from a specified directory
  • Configuration
  • Basic security with Helmet
  • Request logging with Morgan

Getting Started

Prerequisites

Ensure you have Node.js and npm installed on your machine.

Installation

  1. Install the package:
   npm install serve-og

This command will automatically install all dependencies, including nodemon for development.

Default Configuration

By default, the server is configured with:

  • Port: 3000
  • Directory: src
  • File: index.html
  • Server Name: Local Server

These can be overridden by specifying environment variables when starting the server.

Usage[with default config]

  1. Run the Server in Development Mode:

    • Use the following command to start the server:
   serve.dev 
  1. Run the Server in Production Mode:

    • Use the following command to start the server:
    serve.prod

Environment Variables[custom deployment]

You can customize the server behavior by setting environment variables. The following variables are available:

  • PORT: Port number for the server (default is 3000).
  • DIRECTORY: Directory containing the HTML file (default is src).
  • FILE: HTML file to serve (default is index.html).
  • SERVER_NAME: Name of the server (default is "Local Server").

To use environment variables, you can set them inline with the command or create a .env file in the project root.

Example with environment variables:

   PORT=4000 
   DIRECTORY=public 
   FILE=sample.html 
   SERVER_NAME="My Server" 
   serve.dev

Manually Restarting the Server

While nodemon is running, you can manually restart the server by typing rs in the terminal.

Example Output

When you run the server with nodemon, you should see output similar to the following:

- `> [email protected] start`
- `> nodemon scripts/server.js test sample.html test`
- `[nodemon] 3.1.4`
- `[nodemon] to restart at any time, enter rs`
- `[nodemon] watching path(s): *.*`
- `[nodemon] watching extensions: js,mjs,cjs,json`
- `[nodemon] starting node scripts/server.js test sample.html test`
- `Local Server running at http://localhost:3000`
- `Serving "index.html" from "src"`

Notes

  • The index.html file should be placed in the src folder (if running default).

License

This project is licensed under the MIT License - see the LICENSE file for details.