Locations management API.
Methods
(static) canCreate()
An administrator can create a location.
(static) canDestroy()
An administrator can destroy a location.
(static) canList()
Anyone can list locations.
(static) canRetrieve()
Anyone can retrieve a location.
(static) canUpdate()
An administrator can update a location.
(static) create()
Creates a new location.
(static) destroy()
Deletes a location.
(static) fetchLocation()
Middleware that fetches the location identified by the ID in the URL.
(static) list()
Lists locations ordered by name.
(static) parse(data, locationopt) → {Location}
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()
Retrieves a single location.
(static) serialize(req, location) → {object}
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()
Updates a location.
(inner) validateListRequest(req) → {Promise.<ValidationErrorBundle>}
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>}
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>