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

@ideadesignmedia/webserver.js

v1.6.19

Published

A highly customizable Express HTTP server with a few useful middleware functions.

Downloads

41

Readme

webserver.js

A highly customizable Express HTTP server with a few useful middleware functions.

Features

Automatically sanitize user inputs. Automatically serve gzipped files available in static folder. Supports HTTPS with automatic forwarding from HTTP.

Installation

yarn install @ideadesignmedia/webserver.js

Includes

index.js - Express HTTP Server Setup
bruteForce.js - Brute Force Protection Middleware
filestore.js - Filestore Routing
request-transformer.js - Request Transformer Routing
saveError.js - Error logging function
visits.js - Visitor logging middleware
upload.js - File upload middleware
server.conf - Sample Nginx Configuration

Basic Usage

const createServer = require('@ideadesignmedia/webserver.js');
const app = require('express').Router();
const configuration = { port: 3000, static: './public' };
/* Add routing using app. */
app.get('/', (req, res) => {
    res.send('Hello World');
});
const server = createServer(configuration, app)

createServer(configuration = {}, routing = ExpressRouter, middleware = [ExpressMiddleware])

Creates an Express HTTP/HTTPS server.

Configuration

The configuration object is passed to the createServer function. It is used to configure the server. The following options are available:

port - number - The port to listen on. Defaults to 3000.

static - string - The path to the static files. Defaults to ./static and will create the static folder if it does not exist.

HOST - string - The hostname of the server. - optional

allowAllOrigins - string - Allow all origins to access the server. when no HOST is specified this is set to true. - optional

allowHeaders - string - The headers to allow. - optional

allowMethods - The methods to allow. - optional

indexPage - The index page to serve. Defaults to index.html.

no404Redirect - boolean - If true, will not redirect to the index page on 404. Defaults to false.

noSanitize - boolean - If true, will not sanitize the request. Defaults to false.

JSON_SIZE - number - The maximum size of the JSON body. Defaults to 100kb.

URL_SIZE - number - The maximum size of the URL. Defaults to 100kb.

URL_PARAMETER_LIMIT - number - The maximum number of URL parameters. Defaults to 100.

cert - string - The path to the SSL certificate. - required for HTTPS

key - string - The path to the SSL key. - required for HTTPS

Routing

The Express routing is passed to the createServer function and will run after middleware.

Middleware

The middleware array is passed to the createServer function and will run before static files but after access control, sanitization, options, request loging

Static Files

The static files are served from the static folder. The static folder is created if it does not exist. The static folder is created in the current working directory. The static folder can be changed by setting the static option in the configuration object.

Static files are served after middleware and routing.