craydent-http

Node module http servers and routing

Usage no npm install needed!

<script type="module">
  import craydentHttp from 'https://cdn.skypack.dev/craydent-http';
</script>

README

Craydent 0.13.4

by Clark Inada

Craydent is all inclusive utility library. There are several ways to use the library in NodeJS. More detailed documentation on constants can be found at Craydent Properties. More detailed documentation on methods can be found at Craydent Methods

// require with prototypes - this require will add prototypes to extend classes and add two constants ($c, $g) to the global space.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent-http');
$c.logit($c.VERSION);
arr.prototypedMethod(args);
// require no conflict - this require is the fully modular version with no global constants, prototypes, or methods.
var $c = require('craydent-http/noConflict');
$c.logit($c.VERSION);
$c.prototypedMethod(arr, args);
// require global - this require constants and methods in the global space and add prototypes to extend classes.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent-http/global');
logit($c.VERSION);
arr.prototypedMethod(args);

Note: All methods and properties defined in the http module must be used as a property of the context (this) within the createServer callback method.

Craydent is all inclusive utility library. There are several ways to use the library in NodeJS. More detailed documentation on constants can be found at Craydent Properties. More detailed documentation on methods can be found at Craydent Methods

// require with prototypes - this require will add prototypes to extend classes and add two constants ($c, $g) to the global space.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent-http');
$c.createServer(function(req, res){ this.$GET(); });
// require no conflict - this require is the fully modular version with no global constants, prototypes, or methods.
var $c = require('craydent-http/noConflict');
$c.createServer(function(req, res){ this.$GET(); });
// require global - this require constants and methods in the global space and add prototypes to extend classes.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent-http/global');
createServer(function(req, res){ this.$GET(); });

Categories

Constants

ACCEPT_ENCODING (String) IE6 (Boolean) PRINCE (Boolean)
ACCEPT_LANGUAGE (String) IE7 (Boolean) PROTOCOL (String)
AMAYA (Boolean) IE8 (Boolean) PUBLIC_IP (String)
ANDROID (Boolean) IE_VERSION (Number) REFERER (String)
BLACKBERRY (Boolean) IPAD (Boolean) REFERER_IP (String)
BROWSER (Object) IPHONE (Boolean) RESPONSES (Object)
CHROME (Boolean) IPOD (Boolean) SAFARI (Boolean)
CHROME_VERSION (Number) KHTML (Boolean) SAFARI_VERSION (Number)
CLIENT (Object) LINUX (Boolean) SERVER (String)
CONSOLE_COLORS (Object) LOCAL_IP (String) SERVER_PATH (String)
CORES_SUPPORT (Boolean) MAC (Boolean) SYMBIAN (Boolean)
DEBUG_MODE (Boolean) MODULES_LOADED (Object) TEMPLATE_TAG_CONFIG (Object)
DEVICE (Object) OPERA (Boolean) VERBOSE_LOGS (String)
ENGINE (Object) OPERA_VERSION (Number) TEMPLATE_VARS (Array)
ERROR_TYPES (Array) ORIGIN (String) TRIDENT (Boolean)
EXPOSE_ROUTE_API (String) OS (Object) VERSION (String)
FIREFOX (Boolean) PAGE_NAME (String) WEBKIT (Boolean)
FIREFOX_VERSION (Number) PAGE_NAME_RAW (String) WINDOWS (Boolean)
GEKKO (Boolean) PALM (Boolean) WINDOWS_MOBILE (Boolean)
HTTP_STATUS_TEMPLATE (Object) PRAGMA (String)
IE (Boolean) PRESTO (Boolean)

Properties

$l (Object) request (Object) sessionid (String)
location (Object) response (Object)
navigator (Object) session (Object)

Featured

HTTP


$COOKIE


Info: Get/set Cookies

Return: (String|Bool)

Parameters:

  • key: (String) Key for cookie value
  • option?: (CookieOptions) Specify delete

Overloads:

Parameters

  • keyValue: (Object) Specify the key value pair: key=>property, value=>object[key]
  • option?: (CookieOptions) Specify path, domain, and/or expiration of cookie

Parameters

  • key: (String) Key for cookie value
  • value: (any) Value to store
  • option?: (CookieOptions) Specify path and/or expiration of cookie

$DEL


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$DELETE


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$GET


Info: Retrieve all or specific variables in the url

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (GetOptions|VerbOptionsTypes|String) Options to defer, ignore case, etc

$HEADER


Info: Retrieve all or specific variables in the headers

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$PAYLOAD


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$POST


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$PUT


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

Methods

HTTP


ChromeVersion


Info: Get Chrome version

Return: (Float)

Parameters:

None

Overloads:

None


FirefoxVersion


Info: Get Firefox version

Return: (Float)

Parameters:

None

Overloads:

None


IEVersion


Info: Get Internet Explorer version

Return: (Float)

Parameters:

None

Overloads:

None


OperaVersion


Info: Get Opera version

Return: (Float)

Parameters:

None

Overloads:

None


SafariVersion


Info: Get Safari version

Return: (Float)

Parameters:

None

Overloads:

None


createServer


Info: Create http server, ability to run middleware, and define routes.

Return: (HTTP)

Parameters:

  • callback: (HTTPCallback) Function to callback when a request is received
  • createServer?: (HTTPOptions) Options for creating the server (ex: {createServer:require('http').createServer})

Overloads:

Parameters

  • options: (HTTPOptions) Function to callback when a request is received

echo


Info: Echo to buffer and use in response

Return: (void)

Parameters:

  • output: (String) Data to send in response

Overloads:

None


end


Info: Call the next function(s) in queue

Return: (void)

Parameters:

None

Overloads:

Parameters

  • status?: (Integer) HTTP status code.
  • output?: (String) output to send as response.
  • encoding?: (String) encoding for the response.

getSession


Info: Asynchronous retrieval of the session object when used in conjunction with createServer

Return: (Promise)

Parameters:

  • sid: (String) Session id of the session object to retrieve syncronously.
  • callback?: (SessionCallback) callback function to invoke once the session object is retrieved.

Overloads:

None


getSessionID


Info: Retrieve the session id when used in conjunction with createServer

Return: (String)

Parameters:

None

Overloads:

None


getSessionSync


Info: Syncronously retrieve the session object when used in conjunction with createServer

Return: (Session)

Parameters:

  • sid: (String) Session id of the session object to retrieve syncronously.

Overloads:

None


header


Info: Set Http Headers to send

Return: (void)

Parameters:

  • header: (Header) Http header.
  • code?: (Integer) Http response code.

Overloads:

None


isAmaya


Info: Check if browser is Amaya

Return: (Bool)

Parameters:

None

Overloads:

None


isAndroid


Info: Check if device is Android

Return: (Bool)

Parameters:

None

Overloads:

None


isBlackBerry


Info: Check if device is BlackBerry

Return: (Bool)

Parameters:

None

Overloads:

None


isChrome


Info: Check if browser is Chrome

Return: (Bool)

Parameters:

None

Overloads:

None


isFirefox


Info: Check if browser is Firefox

Return: (Bool)

Parameters:

None

Overloads:

None


isGecko


Info: Check if engine is Gecko

Return: (Bool)

Parameters:

None

Overloads:

None


isIE


Info: Check if browser is Internet Explorer

Return: (Bool)

Parameters:

None

Overloads:

None


isIE6


Info: Check if browser is Internet Explorer 6

Return: (Bool)

Parameters:

None

Overloads:

None


isIPad


Info: Check if device is iPad

Return: (Bool)

Parameters:

None

Overloads:

None


isIPhone


Info: Check if device is IPhone

Return: (Bool)

Parameters:

None

Overloads:

None


isIPod


Info: Check if device is IPod

Return: (Bool)

Parameters:

None

Overloads:

None


isKHTML


Info: Check if engine is KHTML

Return: (Bool)

Parameters:

None

Overloads:

None


isLinux


Info: Check if OS is Linux

Return: (Bool)

Parameters:

None

Overloads:

None


isMac


Info: Check if OS is Mac Based

Return: (Bool)

Parameters:

None

Overloads:

None


isMobile


Info: Check if the device is a Mobile device

Return: (Bool)

Parameters:

None

Overloads:

None


isOpera


Info: Check if browser is Opera

Return: (Bool)

Parameters:

None

Overloads:

None


isPalmOS


Info: Check if OS is PalmOS

Return: (Bool)

Parameters:

None

Overloads:

None


isPresto


Info: Check if engine is Presto

Return: (Bool)

Parameters:

None

Overloads:

None


isPrince


Info: Check if engine is Prince

Return: (Bool)

Parameters:

None

Overloads:

None


isSafari


Info: Check if browser is Safari

Return: (Bool)

Parameters:

None

Overloads:

None


isSymbian


Info: Check if OS is Symbian

Return: (Bool)

Parameters:

None

Overloads:

None


isTrident


Info: Check if engine is Trident

Return: (Bool)

Parameters:

None

Overloads:

None


isWebkit


Info: Check if engine is Webkit

Return: (Bool)

Parameters:

None

Overloads:

None


isWindows


Info: Check if OS is Windows

Return: (Bool)

Parameters:

None

Overloads:

None


isWindowsMobile


Info: Check if device is Windows Mobile

Return: (Bool)

Parameters:

None

Overloads:

None


send


Info: Recursively require the entire directory and returns an object containing the required modules.

Return: (void)

Parameters:

  • data: (Object) Object to send in response.

Overloads:

Parameters

  • status: (Integer) Status code for response.
  • data: (Object) Object to send in response.

varDump


Info: Dump of variables to response.

Return: (void)

Parameters:

  • ...infinite: (any) any number of arguments can be passed.

Overloads:

None


writeSession


Info: Writes session to filesystem to be retrieved later.

Return: (void)

Parameters:

None

Overloads:

None

Download