Methods
_generateSuccessDetails(req, data) → {Object}
Appends a standard set of request data to a success response
Parameters:
| Name | Type | Description |
|---|---|---|
req |
Object | An express request object |
data |
Object | Data to be included in response |
- Source:
Returns:
The original data with request information added
- Type
- Object
_IMPLEMENT(options) → {Object}
Generates a set of controller functions indexed by a standard set of properties
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for the creation of model specific middleware Properties
|
- Source:
Returns:
A set of controller functions a express router if options.router was provided
- Type
- Object
CLI(options) → {function}
Generates a function that handles CLI inputs for queries
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for CLI handler Properties
|
- Source:
Returns:
Returns a function that handles CLI inputs for queries and writes result to process stdout
- Type
- function
composeMiddleware(options) → {function}
A convenience method for creating view rendering middleware for a given model
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options Properties
|
- Source:
Returns:
Returns an express middleware function that will render a view dependent on options
- Type
- function
CREATE(options) → {function}
Generates middleware that handles creating items in a database
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for create middleware Properties
|
- Source:
Returns:
Returns middleware that handles creating items
- Type
- function
EDIT(options) → {function}
Generates middleware that will render the "edit" view
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for "edit" view rendering Properties
|
- Source:
Returns:
Returns a middleware function that will render "edit" view
- Type
- function
generateErrorDetails(req, data) → {Object}
Appends a standard set of request data to an error response
Parameters:
| Name | Type | Description |
|---|---|---|
req |
Object | An express request object |
data |
Object | Error data that should be included in response |
- Source:
Returns:
The original error data with request information added
- Type
- Object
INDEX(options) → {function}
Generates middleware that will render the "index" view
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for "index" view rendering Properties
|
- Source:
Returns:
Returns a middleware function that will render "index" view
- Type
- function
LOAD(options) → {function}
Generates middleware that handles querying for a single populated item
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for load middleware Properties
|
- Source:
Returns:
Returns a middleware function that will query the database for a single item which is populated by default
- Type
- function
LOAD_WITH_COUNT(options) → {function}
Generates middleware that sets a property on req.headers that specifies that query results should be paginated
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for generating middleware Properties
|
- Source:
Returns:
Returns a middleware that ensures that query results are paginated
- Type
- function
LOAD_WITH_LIMIT(options) → {function}
Generates middleware that sets a default limit and starting page for paginated queries
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | Configurable options for generating middleware |
- Source:
Returns:
Returns a middleware that set default limit and starting page number params on req.query for paginated queries
- Type
- function
NEW(options) → {function}
Generates middleware that will render the "new" view
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for "new" view rendering Properties
|
- Source:
Returns:
Returns a middleware function that will render "new" view
- Type
- function
PAGINATE(options) → {function}
Generates middleware that handles querying a database and returning paginated data
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for generating middleware for making queries that will return paginated data Properties
|
- Source:
Returns:
Returns a middleware function that will query the database and return paginated data
- Type
- function
REMOVE(options) → {function}
Generates middleware that handles deleting items from a database
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for delete middleware Properties
|
- Source:
Returns:
Returns middleware that handles deleting items
- Type
- function
SEARCH(options) → {function}
Generates middleware that handles rendering a view from paginated data
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for querying middleware Properties
|
- Source:
Returns:
Returns middleware that handles rendering a view from paginated data
- Type
- function
setViewModelProperties(model_name) → {Object}
Checks to see if active model label matches model name. If there is a match returns active model inflected name values otherwise generates expanded names from model name and sets value to active model
Parameters:
| Name | Type | Description |
|---|---|---|
model_name |
string | String value that should be inflected |
- Source:
Returns:
Returns an object containing inflected string values
- Type
- Object
SHOW(options) → {function}
Generates middleware that will render the "show" view
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for "show" view rendering Properties
|
- Source:
Returns:
Returns a middleware function that will render "show" view
- Type
- function
UPDATE(options) → {function}
Generates middleware that handles updating an item in a database
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Configurable options for delete middleware Properties
|
- Source:
Returns:
Returns middleware that handles updating items
- Type
- function