1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const Server_1 = require("../Server");
|
4 | const Response_1 = require("./Response");
|
5 | class SuccessfulResponse extends Response_1.Response {
|
6 | static create(statusCode, data, meta) {
|
7 | return new this({ statusCode, data, meta });
|
8 | }
|
9 | static ok(data, meta) {
|
10 | return this.create(Server_1.HttpStatusCodes.Ok, data, meta);
|
11 | }
|
12 | static created(data, meta) {
|
13 | return this.create(Server_1.HttpStatusCodes.Created, data, meta);
|
14 | }
|
15 | static accepted(data, meta) {
|
16 | return this.create(Server_1.HttpStatusCodes.Accepted, data, meta);
|
17 | }
|
18 | static nonAuthoritativeInformation(data, meta) {
|
19 | return this.create(Server_1.HttpStatusCodes.NonAuthoritativeInformation, data, meta);
|
20 | }
|
21 | static noContent(data, meta) {
|
22 | return this.create(Server_1.HttpStatusCodes.NoContent, data, meta);
|
23 | }
|
24 | static resetContent(data, meta) {
|
25 | return this.create(Server_1.HttpStatusCodes.ResetContent, data, meta);
|
26 | }
|
27 | static partialContent(data, meta) {
|
28 | return this.create(Server_1.HttpStatusCodes.PartialContent, data, meta);
|
29 | }
|
30 | static multiStatus(data, meta) {
|
31 | return this.create(Server_1.HttpStatusCodes.MultiStatus, data, meta);
|
32 | }
|
33 | static alreadyReported(data, meta) {
|
34 | return this.create(Server_1.HttpStatusCodes.AlreadyReported, data, meta);
|
35 | }
|
36 | static imUsed(data, meta) {
|
37 | return this.create(Server_1.HttpStatusCodes.ImUsed, data, meta);
|
38 | }
|
39 | format() {
|
40 |
|
41 | if (this.statusCode === Server_1.HttpStatusCodes.NoContent) {
|
42 | return;
|
43 | }
|
44 | return this.data;
|
45 | }
|
46 | }
|
47 | exports.SuccessfulResponse = SuccessfulResponse;
|
48 |
|
\ | No newline at end of file |