1.0.10 • Published 9 years ago

kombucha v1.0.10

Weekly downloads
1
License
ISC
Repository
github
Last release
9 years ago

Kombucha

The Kombucha Official (TKO) http Framework

How to use the Kombucha framework

Installation

npm install kombucha

To then use kombucha, you must require in ('kombucha').

const kombucha = require('kombucha')

Router Methods

var port = process.env.PORT; kombucha.listen(port, ()=>{ port = process.env.PORT || 3000; console.log(port); console.log('server is up on the port ' + port); }); (Use this if you want to use an environment variable. If you don't have one, it will default to port 3000, which you can change if you want.)

kombucha.get(pathname, plain/text)

Sets up a basic route on your server that will return the plain/text you give it as a second argument

  1. Pathname: Any valid url character may be used in the form of a string.
  2. Responseoptional: The response you want the server to send and thus be displayed on a browser if you navigate to this route. If you do not include a response it defaults to a placeholder.
kombucha.get('/soeffervescent', "anybody got a scoby?");

will print "anybody got a scoby?" when you visit /soeffervescent.

kombucha.get('/default');

kombucha.post('/yourownurl');

<h4><a name="post-request"></a>Setting up a route for a POST request:</h4>

<strong>kombucha.post(pathname, [callback])</strong>

1.Pathname: Any valid url character may be used in the form of a string.
2.Callback[optional]: A callback function with the parameters of request and response. If left black will default to an empty response.

and setting up a route for a POST request is easy if you can use the default callback provided above.  Simply use the following code:

kombucha.post('/yourownurl');

Here is an example of an optional callback.


```kombucha.post('/sobubblysosweet', function(request, response){
      var totalData = '';
      request.on('data', function(data){
        totalData += data.toString();
      });
      request.on('end', function() {
        response.writeHead(200, {"Content-Type": "application/json"});
        response.write(totalData);
        response.end();
      });```



<h4><a name="listen"></a>Starting up your server:</h4>

<strong>kombucha.listen([port], [optional callback])</strong>

1.Port(optional): You can set what port you want your server to be on. If you provide no arguments it will default to 3000.

kombucha.listen(3000.()=>{console.log('Server is running on 3000')});

Your server is now listen on port 3000.

readme and other inspiration from Sludgy Trucker Coffee (STC)

Docs & Dev Dependencies included:
gulp, eslint, mocha, chai, gulp-mocha, gulp-eslint, chai http,
1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.0

9 years ago