-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Store status, body and metadata in ResponseDescription
- Loading branch information
Showing
31 changed files
with
209 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { DataFactory } from 'n3'; | ||
import { HTTP } from '../../../util/UriConstants'; | ||
import { RepresentationMetadata } from '../../representation/RepresentationMetadata'; | ||
import type { ResourceIdentifier } from '../../representation/ResourceIdentifier'; | ||
import { ResponseDescription } from './ResponseDescription'; | ||
|
||
/** | ||
* Corresponds to a 201 response, containing the relevant link metadata. | ||
*/ | ||
export class CreatedResponseDescription extends ResponseDescription { | ||
public constructor(location: ResourceIdentifier) { | ||
const metadata = new RepresentationMetadata({ [HTTP.location]: DataFactory.namedNode(location.path) }); | ||
super(201, metadata); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { Readable } from 'stream'; | ||
import type { RepresentationMetadata } from '../../representation/RepresentationMetadata'; | ||
import { ResponseDescription } from './ResponseDescription'; | ||
|
||
/** | ||
* Corresponds to a 200 response, containing relevant metadata and potentially data. | ||
*/ | ||
export class OkResponseDescription extends ResponseDescription { | ||
/** | ||
* @param metadata - Metadata concerning the response. | ||
* @param data - Potential data. @ignored | ||
*/ | ||
public constructor(metadata: RepresentationMetadata, data?: Readable) { | ||
super(200, metadata, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ResponseDescription } from './ResponseDescription'; | ||
|
||
/** | ||
* Corresponds to a 205 response. | ||
*/ | ||
export class ResetResponseDescription extends ResponseDescription { | ||
public constructor() { | ||
super(205); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { Readable } from 'stream'; | ||
import type { RepresentationMetadata } from '../../representation/RepresentationMetadata'; | ||
|
||
/** | ||
* The result of executing an operation. | ||
*/ | ||
export class ResponseDescription { | ||
public readonly statusCode: number; | ||
public readonly metadata?: RepresentationMetadata; | ||
public readonly data?: Readable; | ||
|
||
/** | ||
* @param statusCode - Status code to return. | ||
* @param metadata - Metadata corresponding to the response (and data potentially). | ||
* @param data - Data that needs to be returned. @ignored | ||
*/ | ||
public constructor(statusCode: number, metadata?: RepresentationMetadata, data?: Readable) { | ||
this.statusCode = statusCode; | ||
this.metadata = metadata; | ||
this.data = data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.