crookse-nodedeprecated

Node.js web app library/framework that simplifies HTTP resource creation and the request-response cycle while respecting RESTful design principles.

Usage no npm install needed!

<script type="module">
  import crookseNode from 'https://cdn.skypack.dev/crookse-node';
</script>

README

crookse.Node

Node.js web app library/framework that simplifies HTTP resource creation and the request-response cycle while respecting RESTful design principles.

crookse.Node Latest Release crookse.Node Build Status crookse.Node Coverage Status

// 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

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

MIT


Thanks StackEdit and Shields.io.