3.0.2 • Published 10 years ago
xserver v3.0.2
XServer
A very simple HTTP server for Node.js. The point is to deliever files and respond to regular expression routing.
Basics of the Server:
- When a request is sent to the server it matches the URI pattern to any routes you have set up to run. It is up to the routed method to return a response.
- If no routes are found it will try to find a file and return it.
- If no files are found it will return a 404 status response code.
Installation
npm install xserver
Example
var XServer = require("./xserver.js");
var xs = new XServer({
directories: ["./public"],
temporaryDirectory: "./tmp",
port: 3003
});
xs.get(/^$/, function ( directive ) {
directive.sendText("XServer");
});
xs.get(/^coffee$/, function ( directive ) {
directive.setData("Hello World!");
directive.next();
});
xs.get(/^chain$/,
function ( directive ) {
directive.setData("Chain 1");
directive.next();
},
function ( directive ) {
directive.setData(directive.data + "\nChain 2");
directive.setContentType("txt");
directive.next();
});
xs.get(/^download-file$/, function ( directive ) {
directive.perpareFile("./package.json", function ( err ) {
if ( err ) return directive.sendStatus(500);
directive.send();
});
});
xs.get(/^say\/(.*)$/, function ( directive, segment ) {
directive.sendText("Server says: " + segment);
});
xs.start();
3.0.2
10 years ago
3.0.1
10 years ago
3.0.0
10 years ago
2.0.1
10 years ago
2.0.0
10 years ago
1.2.1
10 years ago
1.1.1
10 years ago
1.1.0
10 years ago
1.0.3
10 years ago
1.0.2
10 years ago
1.0.1
10 years ago
1.0.0
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago