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(); });
ACCEPT_ENCODING (String) | IE (Boolean) | PRINCE (Boolean) |
ACCEPT_LANGUAGE (String) | IE6 (Boolean) | PROTOCOL (String) |
AMAYA (Boolean) | IE7 (Boolean) | PUBLIC_IP (String) |
ANDROID (Boolean) | IE8 (Boolean) | REFERER (String) |
BALANCE_SERVER_LIST (Array) | IE_VERSION (Number) | REFERER_IP (String) |
BLACKBERRY (Boolean) | IPAD (Boolean) | RESPONSES (Object) |
BROWSER (Object) | IPHONE (Boolean) | REST_API_TEMPLATE (String) |
CHROME (Boolean) | IPOD (Boolean) | ROUTE_API_PATH (String) |
CHROME_VERSION (Number) | KHTML (Boolean) | ROUTE_LOGO_URL (String) |
CLIENT (Object) | LINUX (Boolean) | SAFARI (Boolean) |
CONSOLE_COLORS (Object) | LOCAL_IP (String) | SAFARI_VERSION (Number) |
CORES_SUPPORT (Boolean) | MAC (Boolean) | SERVER (String) |
DEBUG_MODE (Boolean) | MODULES_LOADED (Object) | SERVER_PATH (String) |
DEFER_END (Boolean) | OPERA (Boolean) | SYMBIAN (Boolean) |
DEVICE (Object) | OPERA_VERSION (Number) | TEMPLATE_TAG_CONFIG (Object) |
ENGINE (Object) | ORIGIN (String) | TEMPLATE_VARS (Array) |
ERROR_TYPES (Array) | OS (Object) | TRIDENT (Boolean) |
EXPOSE_ROUTE_API (String) | PAGE_NAME (String) | VERBOSE_LOGS (String) |
FIREFOX (Boolean) | PAGE_NAME_RAW (String) | VERSION (String) |
FIREFOX_VERSION (Number) | PALM (Boolean) | WEBKIT (Boolean) |
GEKKO (Boolean) | PRAGMA (String) | WINDOWS (Boolean) |
HTTP_STATUS_TEMPLATE (Object) | PRESTO (Boolean) | WINDOWS_MOBILE (Boolean) |
$l (Object) | raw (String) | server (Object) |
GarbageCollector (Array) | request (Object) | session (Object) |
location (Object) | response (Object) | sessionid (String) |
name (String) | response_sent (Boolean) | |
navigator (Object) | rest (Boolean) |
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
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
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
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
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
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
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
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
Info: Get Chrome version
Return: (Float)
Parameters:
None
Overloads:
None
Info: Get Firefox version
Return: (Float)
Parameters:
None
Overloads:
None
Info: Get Internet Explorer version
Return: (Float)
Parameters:
None
Overloads:
None
Info: Get Opera version
Return: (Float)
Parameters:
None
Overloads:
None
Info: Get Safari version
Return: (Float)
Parameters:
None
Overloads:
None
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
Info: Echo to buffer and use in response
Return: (void)
Parameters:
- output: (String) Data to send in response
Overloads:
None
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.
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
Info: Retrieve the session id when used in conjunction with createServer
Return: (String)
Parameters:
None
Overloads:
None
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
Info: Set Http Headers to send
Return: (void)
Parameters:
- header: (Header) Http header.
- code?: (Integer) Http response code.
Overloads:
None
Info: Check if browser is Amaya
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if device is Android
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if device is BlackBerry
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if browser is Chrome
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if browser is Firefox
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if engine is Gecko
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if browser is Internet Explorer
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if browser is Internet Explorer 6
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if device is iPad
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if device is IPhone
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if device is IPod
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if engine is KHTML
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if OS is Linux
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if OS is Mac Based
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if the device is a Mobile device
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if browser is Opera
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if OS is PalmOS
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if engine is Presto
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if engine is Prince
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if browser is Safari
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if OS is Symbian
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if engine is Trident
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if engine is Webkit
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if OS is Windows
Return: (Bool)
Parameters:
None
Overloads:
None
Info: Check if device is Windows Mobile
Return: (Bool)
Parameters:
None
Overloads:
None
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.
Info: Dump of variables to response.
Return: (void)
Parameters:
- ...infinite: (any) any number of arguments can be passed.
Overloads:
None
Info: Writes session to filesystem to be retrieved later.
Return: (void)
Parameters:
None
Overloads:
None
- GitHub
- BitBucket
-
GitLab
Craydent is released under the Dual licensed under the MIT or GPL Version 2 licenses.