nax

naxtex

Naxtex is a reverse proxy that forwards some network requests to another server and handles some by serving a static file.

Showing:

Popularity

Downloads/wk

2

Maintenance

No Maintenance Data Available

Package

Dependencies

8

Size (min+gzip)

35.1KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Purpose

Naxtex is a reverse proxy intended for use during development of web applications. It creates a server that splits requests between another server and by serving them directly from the filesystem.

The goal is for webservice calls to be allowed to continue to the server, but for static resources to be served by the local filesystem, so that the static resources can be modified during development without a tedious deploy process.

It has basic support for calling build scripts before files are served if they appear to be out of date. This can serve as a replacement for watch servers.

Install

npm install -g naxtex

Usage

Help

The help can be used to see most configurable options including the target server and the port to be listened on.

naxtex --help

Configuration

By default, files are served from the working directory. The config file is looked for in the current working directory as well. It should be named "naxtex.json" Here is an example config file

{
  "files": [
    {
      "match": [
        "**/*.html",
        "**/*.js",
        "!/static/m/index.html"
      ],
      "rewrite": [
        {
          "mode": "regex",
          "from": "/(.*)",
          "to": "$1"
        },
        {
          "from": "vendor/jquery/jquery.min.js",
          "to": "vendor/jquery/jquery-2.2.1.js"
        }
      ]
    },
    {
      "match": [
        "**/app/**/*-*.css"
      ],
      "rewrite": [
        {
          "mode": "regex",
          "from": "/static/(app|m)/css/(.+)-(.+).css",
          "to": "build/optimized/$1/$1/css/$2-$3.css"
        }
      ],
      "watch": [
        "common/css/common.less",
        "app/css/**/*.less"
      ],
      "command": "gulp compile-less:app"
    }
  ]
}

There are currently four configurable parameters: "match", "rewrite","watch", and "command".

"match" should contain an array of glob patterns. Any files that match any glob will be served from the filesystem.

"rewrite" can be used to adjust the path needs to be read. Each option supports two modes, plain string matching and regular expressions. Each rule will be applied in order. Refer to example above.

"watch" and "command" work together. Both are optional. "watch" should be an array of globs. The modified time on the files matched by the glob will be compared to the modified time on the requested file. If requested file is older, "command" will be executed before the file is served.

Note that multiple groups of these parameters are supported. The first one to match will handle any given request. If none match, the file will be forwarded directly to the target server.

Performance

The use of "watch" and "command" can dramatically slow performance. "watch" should be carefully configured to match as few files as possible. "command" needs to execute quickly, as dependent HTTP requests will be stalled until it finishes.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100