UNPKG

1.81 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const Server_1 = require("../Server");
4const Response_1 = require("./Response");
5class 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 // Like it says, no content.
41 if (this.statusCode === Server_1.HttpStatusCodes.NoContent) {
42 return;
43 }
44 return this.data;
45 }
46}
47exports.SuccessfulResponse = SuccessfulResponse;
48//# sourceMappingURL=SuccessfulResponse.js.map
\No newline at end of file