README
crookse.Node
Node.js web app library/framework that simplifies HTTP resource creation and the request-response cycle while respecting RESTful design principles.
// Require the package
var CrookseNode = require('crookse-node');
// Create and run the server (listens at localhost:1337 by default)
var server = CrookseNode.createServer('Server-1');
server.run();
// Add an HTTP resource that can be retrieved from the / URI
server.addHttpResources([
{
paths: ['/'],
class: function HomeResource() {
// localhost:1337
this.HTTP_GET_JSON = () => { this.response.end(JSON.stringify({message: "You made a GET request and received a JSON response!"})); };
// localhost:1337
this.HTTP_POST_JSON = () => { this.response.end(JSON.stringify({message: "You made a POST request and received a JSON response!"})); };
// localhost:1337?output=html
this.HTTP_GET_HTML = () => { this.response.end('<p>Message:</p><p>You made a GET request and received an HTML response!</p>'); };
// localhost:1337?output=xml
this.HTTP_GET_XML = () => { this.response.end('<response><body><message>You made a GET request and received an XML response!</message></body></response>'); };
}
}
]);
crookse.Node helps you build web apps that handle requests to grab resources and return representations of those resources in different formats (e.g., HTML, JSON, XML, etc.).
Features
- Semantic routing based on content negotiation
- Extensive documentation with example usage
- Easy-to-follow tutorials for building modern web apps from the ground up
- Use with any other package
- Tagged console and file loggers
- No need to add/call
next()
handlers in the request-response cycle - Sample applications located at crookse/crookse-node-sample-applications
Installation
$ cd /path/to/your/project
$ npm install --save crookse-node
- Note: This package was developed using Node.js v8.12.0 and npm v6.4.1
Documentation Pages
License
Thanks StackEdit and Shields.io.