npm.io
1.0.2 • Published 1 year ago

craydent-http

Licence
MIT
Version
1.0.2
Deps
54
Size
84 kB
Vulns
0
Weekly
0

Craydent 1.0.2

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

Properties

$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)

HTTP


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

Keywords