Class: Collection
Represents of a collection of Resource
instances. As the Collection
class inherits from State
, instances of Collection
also represent valid request responses.
Hierarchy
↳ Collection
Index
Constructors
Metadata Properties
Other Properties
Factory Methods
- ACCEPTED
- BAD_REQUEST
- CONFLICT
- CREATED
- FORBIDDEN
- INTERNAL_SERVER_ERROR
- NOT_FOUND
- NO_CONTENT
- OK
- UNAUTHORIZED
Other Methods
Constructors
constructor
+ new Collection(resources
: Array‹Resource›): Collection
Overrides State.constructor
Defined in lib/Collection.ts:12
Parameters:
Name | Type |
---|---|
resources |
Array‹Resource› |
Returns: Collection
Metadata Properties
$dependencies
• $dependencies: Array‹string› = []
Inherited from State.$dependencies
Defined in lib/State.ts:33
An array of paths upon which the response data depends.
$message
• $message: string = ""
Defined in lib/State.ts:23
A string describing the response.
$query
• $query: string = null
Defined in lib/State.ts:28
An HTTP query string representing the requested path and validated arguments.
$status
• $status: number
Defined in lib/State.ts:18
An HTTP status code describing the response.
$type
• $type: string = null
Defined in lib/State.ts:13
The derived class name of the instance.
Other Properties
resources
• resources: Array‹Resource›
Defined in lib/Collection.ts:12
Factory Methods
Static
ACCEPTED
▸ ACCEPTED(message
: any): State‹›
Defined in lib/State.ts:96
Creates a standard HTTP response.
Parameters:
Name | Type | Default |
---|---|---|
message |
any | null |
Returns: State‹›
Static
BAD_REQUEST
▸ BAD_REQUEST(message
: any): State‹›
Inherited from State.BAD_REQUEST
Defined in lib/State.ts:110
Creates a standard HTTP response.
Parameters:
Name | Type | Default |
---|---|---|
message |
any | null |
Returns: State‹›
Static
CONFLICT
▸ CONFLICT(message
: any): State‹›
Defined in lib/State.ts:138
Creates a standard HTTP response.
Parameters:
Name | Type | Default |
---|---|---|
message |
any | null |
Returns: State‹›
Static
CREATED
▸ CREATED(message
: any): State‹›
Defined in lib/State.ts:89
Creates a standard HTTP response.
Parameters:
Name | Type | Default |
---|---|---|
message |
any | null |
Returns: State‹›
Static
FORBIDDEN
▸ FORBIDDEN(message
: any): State‹›
Inherited from State.FORBIDDEN
Defined in lib/State.ts:124
Creates a standard HTTP response.
Parameters:
Name | Type | Default |
---|---|---|
message |
any | null |
Returns: State‹›
Static
INTERNAL_SERVER_ERROR
▸ INTERNAL_SERVER_ERROR(message
: any): State‹›
Inherited from State.INTERNAL_SERVER_ERROR
Defined in lib/State.ts:145
Creates a standard HTTP response.
Parameters:
Name | Type | Default |
---|---|---|
message |
any | null |
Returns: State‹›
Static
NOT_FOUND
▸ NOT_FOUND(message
: any): State‹›
Inherited from State.NOT_FOUND
Defined in lib/State.ts:131
Creates a standard HTTP response.
Parameters:
Name | Type | Default |
---|---|---|
message |
any | null |
Returns: State‹›
Static
NO_CONTENT
▸ NO_CONTENT(): State‹›
Inherited from State.NO_CONTENT
Defined in lib/State.ts:103
Creates a standard HTTP response.
Returns: State‹›
Static
OK
▸ OK(message
: any): State‹›
Defined in lib/State.ts:82
Creates a standard HTTP response.
Parameters:
Name | Type | Default |
---|---|---|
message |
any | null |
Returns: State‹›
Static
UNAUTHORIZED
▸ UNAUTHORIZED(message
: any): State‹›
Inherited from State.UNAUTHORIZED
Defined in lib/State.ts:117
Creates a standard HTTP response.
Parameters:
Name | Type | Default |
---|---|---|
message |
any | null |
Returns: State‹›
Other Methods
isError
▸ isError(): boolean
Defined in lib/State.ts:46
Checks if the instance represents an error.
Returns: boolean
render
▸ render(): object
Defined in lib/Collection.ts:29
Returns: object
serialize
▸ serialize(): string
Inherited from State.serialize
Defined in lib/State.ts:57
Returns a serialized version of the public representation of the instance for network transport.
Returns: string
toJSON
▸ toJSON(): object
Defined in lib/State.ts:68
Returns a public representation of the instance metadata, with the instance's rendered
payload assigned to the property payload
on the resulting object. Called when an the instance is converted to JSON via JSON.stringify
.
Returns: object
-
message: string = this.$message
-
payload: any = this.render()
-
query: string = this.$query
-
status: number = this.$status
-
type: string = this.$type
uses
▸ uses(...states
: Array‹State›): this
Defined in lib/State.ts:62
Adds the given states to the instance's dependencies
, such that when those states are invalidated, so will be the instance.
Parameters:
Name | Type |
---|---|
...states |
Array‹State› |
Returns: this