Menu

class: Handlebars

[377:14] (extern: com.lehman.aussomserver.connectors.HandlebarsObj) extends: object

Handlebars support object.

Methods

  • compileString (string Template)

    Compiles the provided template string.

    • @p Template is a string with the HTML template to compile.
    • @r This object.
  • compile (string Template)

    Compiles the provided template with the provided template file name.

    • @p Template is a string with the file name of the template to compile.
    • @r This object.
  • apply (JsonArgs)

    Applies the provided JSON arguments to the template and returns it as a string.

    • @p JsonArgs is a JSON string or an Aussom Object with the values to apply to the template.
    • @r A string with the template and values.

class: api

[509:21] static (extern: com.lehman.aussomserver.connectors.AussomApi) extends: object

Class that handles API operations.

Methods

  • unpack (string Method, string JsonStr)

    The unpack function will attempt to take the provided JSON string and using the API definition will create the object graph it represents.

    • @p Method is the method enum value to unpack for.
    • @p JsonStr is a JSON formatted string with the request data to unpack.
    • @r The object or list of objects unpacked.
  • unpackQueryParams (string Method, map QueryParams)

    The unpack function will attempt to take the provided query params map and create the defined object graph. You can define this with api--req-query-params value.

    • @p Method is the method enum value to unpack for.
    • @p QueryParams is a map with the request query params to unpack.
    • @r The object unpacked.

class: HttpReq

[24:14] (extern: com.lehman.aussomserver.connectors.HttpReqObj) extends: object

HttpReq object is the object provided by the handle(req) function. This object has all of the HTTP request information and also provides the API for sending the HTTP response.

Methods

  • getReqPath ()

    Gets the request path.

    • @r A string with the request path.
  • getReqMethod ()

    Gets the request method.

    • @r A string with the request method.
  • getReqScheme ()

    Gets the HTTP request scheme.

    • @r A string with the request scheme.
  • getReqURI ()

    Gets the request URI.

    • @r A string with the request URI.
  • getReqURL ()

    Gets the request URL.

    • @r A string with the request URL.
  • getReqContentLength ()

    Gets the request content length.

    • @r An integer with the request content length.
  • getReqStartTime ()

    Gets the request start time.

    • @r A Date with the request start time.
  • getReqHeaders ()

    Gets the request HTTP headers.

    • @r A map with the HTTP request headers.
  • getReqCookies ()

    Gets the request cookies.

    • @r A list of objects that store the cookie data. Each object has domain, name, path, comment, value, expires, maxAge, and version keys.
  • getHost ()

    Gets the request host.

    • @r A string with the request host.
  • getAddress ()

    Gets the request IP address.

    • @r A string with the request IP address.
  • getPort ()

    Gets the request port number.

    • @r An integer with the request port number.
  • getSrcHost ()

    Gets the source/client host name.

    • @r A string with the source host name.
  • getSrcAddress ()

    Gets the source/client IP address.

    • @r A string with the source IP address.
  • getSrcPort ()

    Gets the source/client port number.

    • @r An integer with the source port number.
  • getProtocol ()

    Gets the request protocol.

    • @r A string with the request protocol.
  • getQueryString ()

    Gets the request query string.

    • @r A string with the request query string.
  • getQueryParams ()

    Gets the request query parameters.

    • @r A map with the request query parameters.
  • getPathParams ()

    Gets the request path parameters.

    • @r A list with the request path parameters.
  • getReq ()

    Gets the request object. This function gathers all the request fields and returns them as a map. Possible keys in the returned map are path, method, charset, scheme, uri, url, contentLenght, startTime, headers, cookies, host, address, port, srcHost, srcAddress, srcPort, protocol, queryString, queryParams, pathParams, formData, and body. The formData and body keys will only be present if they were provided.

    • @r A map with the request object.
  • getRespBytesSent ()

    Gets the response number of bytes sent.

    • @r An integer with the number of response bytes sent.
  • getRespContentLength ()

    Gets the response content length sent.

    • @r An integer with the content length sent.
  • getRespCharset ()

    Gets the response character set.

    • @r A string with the response character set.
  • getRespHeaders ()

    Gets a map with the response headers.

    • @r A map with the response headers.
  • getRespCookies ()

    Gets a list of response cookie objects.

    • @r A list of maps with the response cookie data.
  • getResp ()

    Gets a response object with all fields.

    • @r A map with the response object fields.
  • putHeader (string Key, value)

    Sets the provided header value for the connection.

    • @p Key is a string with the header name.
    • @p value is a string to set as the header value.
    • @r This object.
  • setStatusCode (int Value)

    Sets the HTTP status code for the response.

    • @p Value is an integer to set for the HTTP status code.
    • @r This object.
  • send (value)

    Sends the provided value as the response.

    • @p value is the value to send as the response.
    • @r This object.
  • sendBytes (object value)

    Sends the provided bytes as the response.

    • @p value is a Buffer object with the bytes to send.
    • @r This object.
  • addPathParam (string Name, string Value)

    Adds a path param.

    • @p Name is a string with name of the path param.
    • @p Value is a string with the value of the path param.
    • @r This object.
  • addQueryParam (string Name, string Value)

    Adds a query param.

    • @p Name is a string with the query param name.
    • @p Value is a string with the query param value.
    • @r This object.
  • getBody ()

    Gets the body of the request as a string.

    • @r A string with the request body.
  • formSubmitted ()

    Gets the form submitted flag.

    • @r A boolean with true if a form was submitted and false if not. (Based on Content-Type)
  • getFormData ()

    Gets the sent form data.

    • @r a map of the url-encoded or multipart form data.
  • setCookie (string name, string value, int expires = -1, bool secure = false, string path = "/")

    Sets a response cookie with the provided arguments.

    • @p name is a string with the cookie name.
    • @p value is a string with the cookie value.
    • @p expires is an integer with the number of milliseconds until the cookie expires.
    • @p secure is the flag that sets if the cookie is secure or not.
    • @p path is a string with the cookie path to set.
    • @r This object.

class: WsConn

[286:14] (extern: com.lehman.aussomserver.connectors.WsConnObj) extends: object

WsConn object is the object provided by a @Websocket-annotated handler function. One WsConn is created per inbound connection and lives until the channel closes. The handler typically registers onMessage / onClose / onError callbacks and may immediately send a greeting frame. Apps that want broadcast or room semantics keep their own peer list (e.g. this.peers @= ws). The WsConn object intentionally has no built-in subscriber list.

Methods

  • send (string Text)

    Sends a text frame to the connected client. Non-blocking.

    • @p Text is a string with the text to send.
    • @r this object
  • sendBytes (object Buf)

    Sends a binary frame to the connected client. Non-blocking.

    • @p Buf is a Buffer with the bytes to send.
    • @r this object
  • onMessage (callback Cb)

    Registers (or replaces) the callback invoked on each incoming text frame. Cb is called with the frame text as its single argument.

    • @p Cb is a callback with signature (text).
    • @r this object
  • onBinary (callback Cb)

    Registers (or replaces) the callback invoked on each incoming binary frame. Cb is called with a Buffer as its single argument.

    • @p Cb is a callback with signature (buffer).
    • @r this object
  • onClose (callback Cb)

    Registers (or replaces) the close callback. Fires once when the channel closes (whether client- or server-initiated). Cb is called with the close code (int) and reason (string).

    • @p Cb is a callback with signature (code, reason).
    • @r this object
  • onError (callback Cb)

    Registers (or replaces) the error callback. Fires for IO errors and other channel-level failures. Cb is called with the error message string.

    • @p Cb is a callback with signature (message).
    • @r this object
  • close (int Code = 1000, string Reason = "")

    Server-initiated close. Defaults to code 1000 (normal) and an empty reason.

    • @p Code is an int with the close code. Defaults to 1000.
    • @p Reason is a string with a human-readable reason. Defaults to "".
    • @r this object
  • getReqPath ()

    Returns the original handshake request URI path.

    • @r A string with the request path.
  • getReqHeaders ()

    Returns the handshake request headers as a map (lower-cased keys). Multi-valued headers come back as lists of strings; single-valued headers come back as plain strings.

    • @r A map of headers from the original handshake.
  • getQueryString ()

    Returns the raw query string from the handshake URI, or "" if none was supplied.

    • @r A string with the query string.
  • getSrcAddress ()

    Returns the source IP of the client connection.

    • @r A string with the source IP.

class: cache

[536:14] (extern: com.lehman.aussomserver.connectors.AussomCache) extends: object

Class that handles caching operations.

Methods

  • cache (int expireAfterMins = 30, int maxNumberOfEntries = 10000)

    Constructor that creates a new cache.

    • @p expireAfterMins is an optional int with the number of minutes that the entry can live for.
    • @p maxNumberOfEntries is an optional int with the maximum number of entries that the cache can hold.
    • @r A new cache instance.
  • _newCache (expireAfterMins, maxNumberOfEntries)

  • put (string key, val)

    Puts the provided key and value into the cache. If the value already exists it is overwritten.

    • @p key is a string with the key.
    • @p val is the value to store.
    • @r This object.
  • get (string key)

    Gets the value with the provided key, or returns null if not found.

    • @p key is a string with the key to get.
    • @r The value, or null if not found.
  • invalidate (string key)

    Invalidates (deletes) the cache entry with the provided key.

    • @p key is a string with the key to invalidate.
    • @r This object.

class: method

[495:6] static extends: object

Defines the HTTP method types.

Members

  • get
  • put
  • post
  • delete
  • options
  • head
  • patch
  • trace

class: AppBase

[408:7] extends: object

Base App object that other Aussom Server apps extend.

Methods

  • http_err_404 (req)

    Handles the default 404 error.

    • @p req is the http request object.
  • http_err_500 (req)

    Handles the default 500 error.

    • @p req is the http request object.

class: props

[440:21] static (extern: com.lehman.aussomserver.connectors.Properties) extends: object

Provides property support.

Methods

  • encrypt (string Str)

    Encrypts the provided string using the app encryption key. The key is either sent on startup with -Daussom-server.key or is provided as the 'key' entry in the config file.

    • @p Str is the plain text string to encrypt.
    • @r The encrypted string.
  • decrypt (string Str)

    Decrypts the provided string using the app encryption key. The key is either sent on startup with -Daussom-server.key or is provided as the 'key' entry in the config file.

    • @p Str is the encrypted string to decrypt.
    • @r The decrypted string.
  • getEnv ()

    Gets the environment identifier. (ie dev, qa, prod) This is set in config.yaml at the root level as 'env' and defaults to local.

  • load (string FileName)

    Loads the YAML properties file with the provided file name. The file must exist in the app directory, but NOT in the public or app_data directories. This will load the properties under the root node that corresponds to the current environment set (env) in the config.yaml. For instance if env is set to 'local', then the root node in the properties file to load must be 'local'. Note that this appends the properties to the existing properties.

    • @p FileName is a string with the YAML file to load.
    • @r A map with all of the properties.
  • get ()

    Gets the map with all the properties. Note that this is a copy of the properties map. You can change the values but they won't change the one's stored.

    • @r A map with all the properties.