update devDependencies
[squeep-api-dingus] / lib / enum.js
1 'use strict';
2
3
4 const ContentType = {
5 TextHTML: 'text/html',
6 TextPlain: 'text/plain',
7 ApplicationForm: 'application/x-www-form-urlencoded',
8 ApplicationJson: 'application/json',
9 };
10
11 // Supported encoding types
12 const EncodingType = {
13 Brotli: 'br',
14 Gzip: 'gzip',
15 XGzip: 'x-gzip',
16 Identity: 'identity',
17 };
18
19 // Filename suffixes for serving pre-encoded files
20 const EncodingTypeSuffix = {
21 [EncodingType.Brotli]: '.br',
22 [EncodingType.Gzip]: '.gz',
23 [EncodingType.XGzip]: '.gz',
24 };
25
26 const ErrorResponse = {
27 BadRequest: {
28 statusCode: 400,
29 errorMessage: 'Bad Request',
30 },
31 Unauthorized: {
32 statusCode: 401,
33 errorMessage: 'Unauthorized',
34 },
35 Forbidden: {
36 statusCode: 403,
37 errorMessage: 'Forbidden',
38 },
39 ReallyForbidden: {
40 statusCode: 403,
41 errorMessage: 'F̦̩̫̼͔̫͓̃ͤ̈̆̀͑o̖̟͙̫̯̗̳̽ͦ̆́ͨr̩͉̰̗͉b̬̂͘į̟̬̓d͂͗҉̟͈̜͙ͅd͎̜̺̝͇͑̒̋̾ë̴̳̺͓̦̘́ͮ̈́ǹ͈̦̫̙',
42 },
43 NotFound: {
44 statusCode: 404,
45 errorMessage: 'Not Found',
46 },
47 MethodNotAllowed: {
48 statusCode: 405,
49 errorMessage: 'Method Not Allowed',
50 },
51 NotAcceptable: {
52 statusCode: 406,
53 errorMessage: 'Not Acceptable',
54 },
55 Gone: {
56 statusCode: 410,
57 errorMessage: 'Gone',
58 },
59 UnsupportedMediaType: {
60 statusCode: 415,
61 errorMessage: 'Unsupported Media Type',
62 },
63 InternalServerError: {
64 statusCode: 500,
65 errorMessage: 'Internal Server Error',
66 },
67 };
68
69 const ErrorResponseDefaultProxy = new Proxy(ErrorResponse, {
70 get: (target, property) => {
71 // eslint-disable-next-line security/detect-object-injection
72 return (property in target) ? target[property] : {
73 errorMessage: `undefined error response '${property}'`,
74 };
75 },
76 });
77
78 const Header = {
79 Accept: 'Accept',
80 AcceptEncoding: 'Accept-Encoding',
81 CacheControl: 'Cache-Control',
82 ContentEncoding: 'Content-Encoding',
83 ContentLength: 'Content-Length',
84 ContentType: 'Content-Type',
85 ETag: 'ETag',
86 IfModifiedSince: 'If-Modified-Since',
87 IfNoneMatch: 'If-None-Match',
88 LastModified: 'Last-Modified',
89 Location: 'Location',
90 RequestId: 'Request-ID',
91 Vary: 'Vary',
92 XCorrelationId: 'X-Correlation-ID',
93 XForwardedFor: 'X-Forwarded-For',
94 XForwardedProto: 'X-Forwarded-Proto',
95 XRealIP: 'X-Real-IP',
96 XRequestId: 'X-Request-ID',
97 };
98
99 module.exports = {
100 ContentType,
101 EncodingType,
102 EncodingTypeSuffix,
103 ErrorResponse: ErrorResponseDefaultProxy,
104 Header,
105 };