-
Notifications
You must be signed in to change notification settings - Fork 4
Home
A fast middleware Connect alternative for Node.js users who want more speed with their convenience
This framework is released under the GNU General Public License v3:
http://www.gnu.org/copyleft/gpl.html
npm install fastworks
- Add a lot more documentation
- More modules, improve existing modules
- Speed optimisations
The starting point of the Fastworks framework is the router. There are two included routers, you can easily add your own if you like.
Routers process incoming requests, and route them through a stack to a destination.
Web applications can (and should) have multiple stacks containing middleware geared towards a type of route they handle. So static routes should have a simple stack, whilst routes which handle form submissions should contain more form-centric stacks.
var fw = require("fastworks");
var stackStatic = new fw.Stack();
stackStatic.append(new fw.CompressorLess({ staticDir: __dirname + "/static" }))
.append(new fw.CompressorJS({ staticDir: __dirname + "/static" }))
.append(new fw.StaticFile({ staticDir: __dirname + "/static" }));
var router = new fw.SimpleRouter();
router.addRoute("/images", stackStatic, notfoundPage);
router.listen(true, 8080);
function notfoundPage(request, response)
{
response.writeHead(404, { "Content-Type": "text/plain" });
response.end("File not found!");
}
This example creates a stack that compresses Less style sheets into CSS, minifies Javascript files, and serves static content such as images, in the /static directory.
Read more about the included routers:
- SimpleRouter - Simple fast matching system
- RegExRouter - Slightly more complicated matching with regular expression support
Read more about the included modules:
- BodySimple - Handles general url encoded form submissions
- BodyJSON - Handles submissions that use JSON
- BodyComplex - Formidable based module for handling complex form submissions such as file uploads
- Query - Parses the query string into a query object
- CompressorJS - Minifies static javascript content
- CompressorLess - Compiles Less files into CSS
- FavIcon - Serves a favicon.ico file
- StaticFile - Lactate based module for serving static content, includes gzip and memory cache support
- Cookies - Parses submitted cookies into a cookie object
- SignedCookies - Parses and verifies cookies signed by the server
- Session - Maintains a data object across sessions
- SignedSession - Maintains a data object across signed sessions
- Limiter - Limits the size of uploads
- ResponseTime - Adds an X-Response-time header to response pages
- ErrorHandler - Catches any errors and sends a friendly message to the client
- Profiler - Logs detailed information on the url and memory usage per request
- Connect - Allows Connect compatible modules to run inside a Fastworks stack