Home Reference Source

Function

Static Public Summary
public
since 0.1.0
public

core(plugins: *): Object

public

dev(plugins: *): Array

public

findNew(req: Object, res: Object, next: function)

Attempts to find the existing published resource by the id provided.

since 0.1.0
public

findOld(req: Object, res: Object, next: function)

Attempts to find the existing published resource by the name of the new record.

since 0.1.0
public

findPublished(req: Object, res: Object, next: function)

Attempts to find the existing published resource by the name provided.

since 0.1.0
public

formatter(response: Object)

Used to format mongoose responses prior to sending json response.

since 0.1.0
public

handleBody(req: Object, res: Object, next: function): *

Checks req.body to make sure it contains body, name, and label fields.

since 0.1.0
public

Compiles the new code before proceeding.

since 0.1.0
public

Proceeds to next function if no compiler error occured.

since 0.1.0
public

parse(code: string): Object

since 0.1.0
public

prod(plugins: *): Array

public

query(req: Object, res: Object, next: function): *

Queries code based on query string parameters provided.

since 0.1.0
public

save(req: Object, res: Object, next: function)

Saves code resource to mongodb.

since 0.1.0
public

throwError(message: string, node: Object)

A shorthand function to throw a CompilerError

since 0.1.0
public

update(req: Object, res: Object, next: function)

Attempts to change published to false and update req.unpublisher.record.

since 0.1.0
public

update(req: Object, res: Object, next: function)

Updates the old record published field to false and the new record published field to true.

since 0.1.0
public

A void function that validates a ceallog function syntax tree based on a series of rules, and throwing an error if not.

since 0.1.0
public

validateURIBlacklist(req: Object, res: Object, next: function): *

Checks whether req.body.name is in the URI blacklist and proceeds if not.

since 0.1.0
public

validateURIComponent(req: Object, res: Object, next: function): *

Determines whether req.body.name is a valid URI component.

since 0.1.0

Static Public

public compile(code: string): function since 0.1.0 source

Params:

NameTypeAttributeDescription
code string

Code to compile.

Return:

function

A closure function that takes a Ceallog instance as a param. When this function is executed, it applies a null scope to the compiled function and passes the Ceallog instance as its sole argument.

public core(plugins: *): Object source

Params:

NameTypeAttributeDescription
plugins *

{...Object} Plugin modules to be applied to ceallog function execution

Return:

Object

An object containing Express middlewear callback functions

public dev(plugins: *): Array source

Params:

NameTypeAttributeDescription
plugins *

{...Object} Plugin modules to be applied to ceallog function execution

Return:

Array

An array of Express middlewear callback functions

public findNew(req: Object, res: Object, next: function) since 0.1.0 source

Attempts to find the existing published resource by the id provided. If successful, the result is added to req.publisher.newRecord.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

public findOld(req: Object, res: Object, next: function) since 0.1.0 source

Attempts to find the existing published resource by the name of the new record. If successful, the result is added to req.publisher.oldRecord.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

public findPublished(req: Object, res: Object, next: function) since 0.1.0 source

Attempts to find the existing published resource by the name provided. If successful, the result is added to req.unpublisher.result.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

public formatter(response: Object) since 0.1.0 source

Used to format mongoose responses prior to sending json response.

Params:

NameTypeAttributeDescription
response Object

mongoose response to be formatted.

public handleBody(req: Object, res: Object, next: function): * since 0.1.0 source

Checks req.body to make sure it contains body, name, and label fields. If not, an error is sent via res. If so, the next function is called.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

Return:

*

public handleCompilerResult(req: Object, res: Object, next: function) since 0.1.0 source

Compiles the new code before proceeding.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

public handleCompilerResult(req: Object, res: Object, next: function) since 0.1.0 source

Proceeds to next function if no compiler error occured. If an error did occur, it is normalised as an HttpError, including location information if available, then sent with a 400 status code.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

public parse(code: string): Object since 0.1.0 source

Params:

NameTypeAttributeDescription
code string

String containing code to be parsed.

Return:

Object

AST from esprima module.

public prod(plugins: *): Array source

Params:

NameTypeAttributeDescription
plugins *

{...Object} Plugin modules to be applied to ceallog function execution

Return:

Array

An array of Express middlewear callback functions

public query(req: Object, res: Object, next: function): * since 0.1.0 source

Queries code based on query string parameters provided. If none are provided, the latest results for each ceallog function name is sent.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

Return:

*

public save(req: Object, res: Object, next: function) since 0.1.0 source

Saves code resource to mongodb. Sends 201 response if successful, error response otherwise.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

public throwError(message: string, node: Object) since 0.1.0 source

A shorthand function to throw a CompilerError

Params:

NameTypeAttributeDescription
message string

Message to include in CompileError.

node Object

(Optional) node object from esprima where the failure occurred.

Throw:

CompilerError

Error with line location info if applicable.

public update(req: Object, res: Object, next: function) since 0.1.0 source

Attempts to change published to false and update req.unpublisher.record.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

public update(req: Object, res: Object, next: function) since 0.1.0 source

Updates the old record published field to false and the new record published field to true.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

public validate(ast: Object) since 0.1.0 source

A void function that validates a ceallog function syntax tree based on a series of rules, and throwing an error if not.

Params:

NameTypeAttributeDescription
ast Object

ceallog function abstract syntax tree to be validated.

public validateURIBlacklist(req: Object, res: Object, next: function): * since 0.1.0 source

Checks whether req.body.name is in the URI blacklist and proceeds if not. Sends a 400 response otherwise.

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

Return:

*

public validateURIComponent(req: Object, res: Object, next: function): * since 0.1.0 source

Determines whether req.body.name is a valid URI component. This function is a limitted implementation of the rules for RFC-2396: URI Generic Syntax (https://www.ietf.org/rfc/rfc2396.txt) as applied to relative segment URI components (see section 5).

Params:

NameTypeAttributeDescription
req Object

Express request object

res Object

Express response object

next function

Function to be called by Express next.

Return:

*