server/api/locations

Locations management API.

Source:

Methods

(static) canCreate()

Source:

An administrator can create a location.

(static) canDestroy()

Source:

An administrator can destroy a location.

(static) canList()

Source:

Anyone can list locations.

(static) canRetrieve()

Source:

Anyone can retrieve a location.

(static) canUpdate()

Source:

An administrator can update a location.

(static) create()

Source:

Creates a new location.

(static) destroy()

Source:

Deletes a location.

(static) fetchLocation()

Source:

Middleware that fetches the location identified by the ID in the URL.

(static) list()

Source:

Lists locations ordered by name.

(static) parse(data, locationopt) → {Location}

Source:

Updates a location with the specified data.

Parameters:
Name Type Attributes Description
data object

The data (with camel-case property names), typically an API request body.

location Location <optional>

The location to update.

Returns:

The updated location.

Type
Location

(static) retrieve()

Source:

Retrieves a single location.

(static) serialize(req, location) → {object}

Source:

Serializes a location for API responses.

Parameters:
Name Type Description
req Request

The Express request object.

location Location

A location record.

Returns:

A serialized location.

Type
object

(static) update()

Source:

Updates a location.

(inner) validateListRequest(req) → {Promise.<ValidationErrorBundle>}

Source:

Validates the query parameters of a request to list locations.

Parameters:
Name Type Description
req Request

An Express request object.

Returns:
  • A promise that will be resolved if the request is valid, or rejected with a bundle of errors if it is invalid.
Type
Promise.<ValidationErrorBundle>

(inner) validateLocation(req, patchModeopt) → {Promise.<ValidationErrorBundle>}

Source:

Validates the location in the request body.

Parameters:
Name Type Attributes Default Description
req Request

An Express request object.

patchMode boolean <optional>
false

If true, only properties that are set will be validated (i.e. a partial update with a PATCH request).

Returns:
  • A promise that will be resolved if the location is valid, or rejected with a bundle of errors if it is invalid.
Type
Promise.<ValidationErrorBundle>