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

create-server

v1.0.2

Published

Create a pre-configured HTTP server

Downloads

37,849

Readme

create-server

Version npmBuild StatusDependenciesCoverage StatusIRC channel

I've found my self writing this particular piece of snippet over and over again. If you need to have a common API for creating a HTTP, HTTPS or SPDY server this might be the module that you've been waiting for.

Installation

Add it to your Node.js project by running

npm install --save create-server

Creating a server

In all code examples we assume that you've required the module and saved it as the create variable:

'use strict';

var create = require('create-server');

The create variable is now a function which can be used to create different types of servers. The function accepts 2 different arguments:

  1. A number which should be the port number or object with the configuration for the servers.
  2. Optionally, an object with different callback methods.

The following properties can be configured:

  • port: The port number we should listen on. Also used to determine which type of server we need to create.
  • hostname: What interface we should listen on.
  • spdy: Create SPDY server instead of a HTTPS server.
  • root: The root folder that contains your HTTPS certs.
  • key, cert, ca, pfx, crl Path or array of paths which will be read out the correct files. The path should be relative to the root option.
  • redirect: Start up an optional HTTP server who will redirect users to the port you're listening on. The supplied value should be the port number we need to listen on.
  • listen: Do need to start listening to the server for you?

The following properties can be provided as callback object:

  • close: Server is closed.
  • request: Received a new incoming request.
  • upgrade: Received a HTTP upgrade request.
  • listening: We're now listening. Receives an optional error as first argument.
  • error: Received a new error on the server.
  • https: A new HTTPS server has been created.
  • http: A new HTTP server has been created.
  • spdy: A new SPDY server has been created.

When creating a secure server, we will do our best to provide sane defaults that will protect your server against known secure server attacks such as POODLE, we also update the cipher list to prevent attacks such as heart bleed. This can be overridden by supplying your own cypher, secureProtocol and secureOptions keys as option.

License

MIT