Package Exports
- nezaldi
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nezaldi) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Nezaldi
From the Nahuatl 'Path' or 'Trail'. Nezaldi is an http proxy server created to help developers to keep a very thin setup on projects that require multiple backend servers usually behind Nginx or similar technology.
Nezaldi is not intended to be used in production environments, but in development ones.
Usage
Install it with NPM:
npm install nezaldi
Create a file in your project root named .nezaldi.json
and write your route configuration there:
{
"debug": false,
"defaultUrl": "http://localhost:4000",
"rules": [
{
"path": "^/$",
"resetPath": true,
"target": "http://localhost:4000/index.html"
},
{
"path": "^/bundles/",
"target": "http://mywebpackserver/bundles/"
},
{
"path": "^/redirect/",
"redirect": "http://myotherserver/home/"
},
{
"path": "^/(books|pets)/",
"target": "http://$1-server/"
},
{
"path": "^/html/",
"accept": "text/html",
"target": "http://myhtmlserver/"
},
{
"path": "^/users/",
"target": "http://myserverneedsaheader/",
"addHeaders": [
{
"name": "X-MyHeader",
"value": "Hello Header"
}
]
}
]
}
Start the server from a package.json
script:
{
"scripts": {
"start": "npm nezaldi"
}
}
Available Options
--conf
Configuration file to use, by default it will usenezaldi.json
-p <port>
Sets the port for running Nezaldi. Default 3000. It can be specified in the configuration file.
Global Configuration Settings
- debug [Boolean] It will print information on the console on every request, including path, match and headers
- defaultUrl [String] The URL that will be used if there is match for a request
Rule Configuration Settings
path [String] The string should be a valid regex argument. It will be used to match rules with requests. Rules are executed in order. If you have rules that are more specific than others, it is better to place the more specific ones before the general ones
target [String] This is the URL of the server that will be used when the rule matches
redirect [String] URL to be used as a redirect response.
redirect
should not be used in combination withtarget
setting in the same rule.resetPath [Boolean] Will force Nezaldi to not add any fragments to the target URL. By default, Nezaldi will remove the path fragment from the url adding the rest of it to the target url. For example, on the request
http://localhost:4000/a/b/c
lets suppose the match rule has path^/a
and targethttp://server/some/more/stuff/
, the default behavior will be to proxy the call tohttp://server/some/more/stuff/b/c
if you set resetPath to true, then the call will be tohttp://server/some/more/stuff/
accept [String] Sometimes you want that a rule only applies when the
accept
type is a specific one, liketext/html
. Use this property to limit the matches to only those containing the given accept typeaddHeaders [Key Value Map Array] In the case you need to add some headers to your calls that are not present in the original request, you can do so by adding them here.
removeHeaders [Key Value Map Array] In the case you need to remove some headers from the original request, you can do so by adding them here.
Dependencies
Nezaldi is intended to be superlight. It only depends on Node itself and on Jasmine for testing during development mode.