purdy-server

1.1.3 • Public • Published

Purdy

The quick and easy Express-based production server

Introduction

Purdy uses Express, Helmet, and compression. It makes running thin, production-ready Node.js servers using ridiculously quick and easy.

Purdy is designed to be a dependency of your project. It serves a directory of static assets and proxies API calls to an endpoint of your choosing.

Purdy's goal isn't to be the most feature-rich server out there. It's designed to be fast, secure, and simple.

Usage

Install as a project dependency: npm i -S purdy-server

Add an NPM script to your package.json to start your production server:

{
  "scripts": {
    "start:prd": "purdy --staticDir ./dist"
  }
}

Options

Options are configured as command line arguments.

  • port: sets the port the server runs on.

    Example: --port 8080

    Defaults to 3000.

  • cache: the maxAge (in milliseconds) the server will use when caching static assets.

    Example: --cache 2592000000 will cache assets for 30 days.

    Defaults to 7 days.

  • staticDir: the directory static content will be served from. This content will be served from the root path. / will automatically resolve to index.html at the root of the static directory.

    Example: --staticDir ./dist will serve all contents of the "./dist" directory from the root path.

  • apiPath: the path to use for forwarding requests to another URL. This option must be used in conjunction with the apiProxy option.

    Example: --apiPath /api will listen for all requests to /api/* and proxy those requests to the URL configured via apiProxy.

  • apiProxy: the URL to proxy API requests to. This option must be used in conjunction with the apiPath option.

    Example: --apiProxy https://jsonplaceholder.typicode.com

Compatibility

Purdy requires Node.js v5+.

Readme

Keywords

none

Package Sidebar

Install

npm i purdy-server

Weekly Downloads

6

Version

1.1.3

License

ISC

Last publish

Collaborators

  • justinsisley