A base class for CRUD routes and templates for a model

Parameters

See Controller docs

  • redirectAfterCreate - path suffix to routePrefix after route
  • redirectAfterEdit - path suffix to routePrefix after route
  • redirectAfterDelete - path suffix to routePrefix after route

Implement Routes

The default implementation of the routes handles querying for the model instance, pagination, and the template rendering. See the specific method documentation for each public view function.

new EditController(options: any)

Extends ViewController

Parameters
options (any = {})
Static Members
replaceRouteParams(route, params)
Instance Members
edit(req, res, query)
create(req, res, object)

Register a nav menu item

add(menu: string, label: string, link: string, options: object)
Parameters
menu (string) Group of nav items
label (string) Text for menu item
link (string) URL of menu item
options (object = {}) Extra context for rendering (icon, css)

Retrieve a menu group

get(menu: string): Array
Parameters
menu (string) Group of nav items
Returns
Array: Menu items

A base class for common application module organization

Automatically registers:

  • Templates from ./templates
  • Models from ./models - these files should extend nxus-storage.BaseModel)
  • Controllers from ./controllers - you may want to extend nxus-web.ViewController
REGEX_FILE

A base class for CRUD routes and templates for a model

Parameters

You can pass any of the following into the constructor options argument:

  • modelIdentity - defaults to name of class, underscored, e.g. todo_item
  • prefix - defaults to name of class, dashed, e.g. todo-item
  • templatePrefix - defaults to parent containing directory (module) + prefix, e.g. mymodule-todo-item-
  • routePrefix - defaults to '/'+prefix
  • pageTemplate - the layout to use to render the page
  • populate - relationships to populate on find. Accepts a string, array, or array of [rel, options] arrays.
  • displayName - defaults to class name
  • instanceTitleField - defaults to first attribute
  • paginationOptions - object with sortField, sortDirection, and itemsPerPage keys.
  • ignoreFields - blacklist of fields to ignore in display
  • displayFields - whitelist of fields to display, show in this order if supplied
  • listFields - subset of fields to show on list view
  • idField - field to use for id in routes

Implement Routes

The default implementation of the routes handles querying for the model instance, pagination, and the template rendering. See the specific method documentation for each public view function.

new ViewController(options: any)

Extends HasModels

Parameters
options (any = {})
Instance Members
list(req, res, query)
detail(req, res, query)