1.14.1 • Published 2 years ago

lazy-http v1.14.1

Weekly downloads
1
License
ISC
Repository
github
Last release
2 years ago

LazyHttp Server

This module is aimed to provide a http server that can only serve static contents. This is for developers who want to test their site without needs to install and establish heavy server that is used only for simple web testing.

Friendly Reminder

Well, since that this module's purpose is very simple, "Provide simple and light-weighted http server for developers who only wants to test their website logic via valid http environment", this module has following features...

  • This module dones't have any external dependency but the nodejs's built-in modules
  • This module is NOT designed to be used as a module
  • This module is NOT designed to serving large files

How to use ?

All you need to do is to install the package globally using following command.

npm install -g lazy-http

And use lazy-http command to instantiate a server. Following lines are the verbose output of the lazy-http --help command.

Usage: lazy-http [OPTION]... [PATH]...
OPTION:
    -h, --help Show this instruction
    -H, --host [host] Set bind address
    -p, --port [port] Set listen port
    -u, --unix [path] Listen to unix socket. ( Note that the -u option will suppress listening on ip & port! )
    -d, --document_root [path] Set document root. Default value is current working directory!
    -r, --rule [RULE_URI] Add and apply the rule uri!
        --config [path] Path to the server configuration file

RULE_URI:
    redir:[default:][hostname][/path_prefix]:[redirected-url] Proxy request for hostname to remote http server!
    proxy:[default:][hostname][/path_prefix]::[dst-host]:[dst-port] Proxy request for hostname to remote http server!
    proxy:[default:][hostname][/path_prefix]:http:[dst-host]:[dst-port] Proxy request for hostname to remote http server!
    proxy:[default:][hostname][/path_prefix]:https:[dst-host]:[dst-port] Proxy request for hostname to remote https server!
    proxy:[default:][hostname][/path_prefix]:unix:[dst-host]:[dst-port] Proxy request for hostname to local named pipe server!
    mime:[extension]:[mime-type] Add a relation between specified extension and mime-type!
    cors:[hostname]:[path-to-cors-handler] Attach a cors handler to a specific hostname!
    csp:[hostname]:[path-to-csp-handler] Attach a csp handler to a specific hostname!
PATH:
    This program will use the following rules to process the input paths.
        1. If the path is pointed to a valid file, then the path will be loaded as a config
        2. If the path is pointed to a valid directory, then the path will be used as the document root
        3. If the path doesn't exist, then verbose error message and skipping

Logs

This tool will generate verbose output in stdout and stderr. The stdout lists succeeded queries and stderr lists failed queries. The following line shows an example line of output, which contains time presented in ISO format, responded http status code, remote ip, remote port and requested URI.

[2019-01-12T05:16:52.157Z] 200 127.0.0.1:60977 /

Note that each output will contains leading and tailing terminal color controlling sequences! It is compatible to ANSI/VT100 Spec. So, some of the environment cannot read it normally! If you encounter a problem reading it, you should write a program to purge the sequences to get normal output!

Debugging

Well, since this module executable itself is a javascript module. You can easily using following command to enable nodejs inspection to debug the server...

node --inspect $(which lazy-http)

DEFAULT-MIME-MAP

The lazy-http server by default will act as a normal static http file server, which will respond mime types according to the extensions of the requested files. Please refer to Default MIME Types for the complete list of the supported extension and their corresponding mime types!

Features in the far far future...

Since that this module is designed for testing purpose, following requirement of "testing environments" are planned to be delivered in the future ( when I have time or someone is willing to helpout... )

  • Support http/2, http/3 logic
1.14.1

2 years ago

1.14.0

2 years ago

1.13.4

4 years ago

1.13.3

4 years ago

1.13.2

5 years ago

1.13.1

5 years ago

1.13.0

5 years ago

1.12.7

5 years ago

1.12.6

5 years ago

1.12.5

5 years ago

1.12.4

5 years ago

1.12.3

5 years ago

1.12.2

5 years ago

1.12.1

5 years ago

1.12.0

5 years ago

1.11.2

5 years ago

1.11.1

5 years ago

1.11.0

5 years ago

1.10.2

5 years ago

1.10.1

5 years ago

1.10.0

5 years ago

1.9.18

5 years ago

1.9.16

5 years ago

1.9.15

5 years ago

1.9.13

5 years ago

1.9.12

5 years ago

1.9.11

5 years ago

1.9.10

5 years ago

1.9.9

5 years ago

1.9.8

5 years ago

1.9.7

5 years ago

1.9.6

5 years ago

1.9.5

5 years ago

1.9.4

5 years ago

1.9.3

5 years ago

1.9.2

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.0.1

5 years ago