Za is a simple web server that exposes an Express-like API and is capable of handling far more requests per second than Express.
za in your project:
npm install --save za
za to start an HTTP server:
var server = ;server;server;console;
za API is a function which instantiates servers.
var za = ;var server1 = ;var server2 = ;console;
Za exposes its
Router object via
use method on a router sets a middleware function, optionally to be
routed only to a given path. The handler function takes
next arguments. The
response arguments are HTTP request
and response objects, and the
next argument is a function that you should
invoke when you want the next middleware to start executing. For performance
reasons, wildcard paths are not yet supported, but the middleware executes for
any request URLs that start with that path.
This can be used for things like logging:
Or for something like authentication:
get method on a router sets a GET handler function for a given
path. The handler function takes
response arguments. For
performance reasons, wildcard paths are not yet supported.
Works just like router.get, only the method is POST.
Works just like router.get, only the method is PUT.
Works just like router.get, only the method is DELETE.
router.use on the server's router.
router.get on the server's router.
router.post on the server's router.
router.put on the server's router.
router.delete on the server's router.
Za decorates the
with useful methods.
Returns the value of a response header with the given name.
Exposes a getter which parses the cookie header and returns an object with a key and value for each cookie.
Exposes a getter which parses the request body and returns an object with a key and value for each parameter in the POST body.
Exposes a getter which parses the query string and returns an object with a key and value for each URL parameter.
multipart object has its keys and values set as the server is receiving
multipart form data. If the request is not a multipart type request, this
object will be undefined (so it can be used to test for multipart requests).
Sends an object as a JSON string, with
Sends a string, an HTTP status, or an object as a JSON string - depending on
the type of the data (
gzip to compress text (provided the
accept-encoding header mentions
"gzip"), then sets
content-encoding: gzip and sends the response.
preZipped is passed in, the
gzip compression step is skipped, and
the pre-zipped content is used instead. This is a useful performance feature
for when you need to send the same zipped response multiple times.
Sets a cookie with a given name, value and options.
Sends a 302 response, redirecting to the given location.
Za includes its own multipart parser. When a multipart request is received, its handler is called before the multipart parser begins. The handler can listen for request events as file parsing proceeds.
When the multipart parser finds a file, the request emits a
and passes the file field. A listener can set a
stream object on the file
field, and the parser will save to that stream. When the parser is finished, it
will close the stream.
When the multipart parser is finished, the request emits a
event. At that time,
request.multipart (as well as
all of the data that was sent in the multipart request.
The term "za" is short for "pizza", and when it comes to web app responses and pizza, everyone wants fast delivery. (Also, the name was available on NPM).
We would like to thank all of the amazing people who use, support, promote, enhance, document, patch, and submit comments & issues. Za couldn't exist without you.
Copyright (c) 2014 Sam Eubank
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
We welcome contributions from the community and are happy to have them. Please follow this guide when logging issues or making code changes.
All issues should be created using the new issue form. Please describe the issue including steps to reproduce. Also, make sure to indicate the version that has the issue.
Code changes are welcome and encouraged! Please follow our process:
npm testto run tests quickly, without testing coverage.
npm run coverto test coverage and generate a report.
npm run reportto open the coverage report you generated.
As contributors and maintainers of Za, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
If any participant in this project has issues or takes exception with a contribution, they are obligated to provide constructive feedback and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, edits, issues, and other contributions that are not aligned with this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, ability or disability, ethnicity, religion, age, location, native language, or level of experience.