add options to ingestBody
[squeep-api-dingus] / lib / dingus.js
1 /* eslint-disable security/detect-object-injection */
2 'use strict';
3
4 /**
5 * A very minimal API server framework.
6 * Just a self-contained router and some request glue.
7 */
8
9 require('./patches');
10 const { promises: fsPromises } = require('fs');
11 const path = require('path');
12 const querystring = require('querystring');
13 const common = require('./common');
14 const ContentNegotiation = require('./content-negotiation');
15 const Enum = require('./enum');
16 const { DingusError, ResponseError } = require('./errors');
17 const { extensionToMime } = require('./mime-helper');
18 const Router = require('./router');
19 const Template = require('./template');
20
21 // For logging.
22 const _fileScope = common.fileScope(__filename);
23
24 const defaultOptions = {
25 ignoreTrailingSlash: false,
26 proxyPrefix: '',
27 strictAccept: true,
28 selfBaseUrl: '',
29 staticMetadata: true,
30 staticPath: undefined, // no reasonable default
31 trustProxy: true,
32 querystring,
33 };
34
35 class Dingus {
36 /**
37 * @param {Object} logger object which implements logging methods
38 * @param {Object} options
39 * @param {Boolean} options.ignoreTrailingSlash
40 * @param {string} options.proxyPrefix leading part of url path to strip
41 * @param {Boolean} options.strictAccept whether to error on unsupported Accept type
42 * @param {string} options.selfBaseUrl for constructing links
43 * @param {Boolean} options.staticMetadata serve static headers with static files
44 * @param {Boolean} options.trustProxy trust some header data to be provided by proxy
45 * @param {Object} options.querystring alternate qs parser to use
46 */
47 constructor(logger = common.nullLogger, options = {}) {
48 common.setOptions(this, defaultOptions, options);
49
50 this.router = new Router(options);
51
52 if (!this.proxyPrefix) {
53 this._stripPrefix = (p) => p;
54 }
55
56 this.responseTypes = [
57 Enum.ContentType.TextHTML,
58 Enum.ContentType.TextPlain,
59 Enum.ContentType.ApplicationJson,
60 ];
61
62 this.logger = logger;
63 common.ensureLoggerLevels(this.logger);
64 }
65
66
67 /**
68 * Resolve relative and empty paths in url
69 * @param {string} p path
70 */
71 _normalizePath(p) {
72 const pathNorm = path.normalize(p); // This isn't perfectly correct, but it's easy...
73 return this._stripPrefix(pathNorm);
74 }
75
76
77 /**
78 * Remove a leading portion of url path
79 * N.B. This method gets obliterated if there is no prefix defined at construction
80 * @param {string} p path
81 */
82 _stripPrefix(p) {
83 if (p.startsWith(this.proxyPrefix)) {
84 return p.slice(this.proxyPrefix.length);
85 }
86 return p;
87 }
88
89
90 /**
91 * Returns the path part, and querystring object, from a request url.
92 * @param {string} url
93 */
94 _splitUrl(url) {
95 const [ p, qs ] = common.splitFirst(url, '?');
96 return {
97 pathPart: this._normalizePath(p),
98 queryParams: this.querystring.parse(qs),
99 };
100 }
101
102
103 /**
104 * Insert a new path handler
105 * @param {string} method
106 * @param {string} urlPath
107 * @param {fn} handler
108 */
109 on(method, urlPath, handler, ...handlerArgs) {
110 this.router.on(method, urlPath, handler, handlerArgs);
111 }
112
113
114 /**
115 * Common header tagging for all requests.
116 * Add our own identifier, and persist any external transit identifiers.
117 * @param {http.ClientRequest} req
118 * @param {http.ServerResponse} res
119 * @param {object} ctx
120 */
121 static tagContext(req, res, ctx) {
122 const requestId = common.requestId();
123 ctx.requestId = requestId;
124 res.setHeader(Enum.Header.RequestId, requestId);
125 [Enum.Header.XRequestId, Enum.Header.XCorrelationId].forEach((h) => {
126 const v = req.getHeader(h);
127 if (v) {
128 ctx[h.replace(/-/g, '')] = v;
129 res.setHeader(h, v);
130 }
131 });
132 return requestId;
133 }
134
135
136 /**
137 *
138 * @param {http.ClientRequest} req
139 */
140 _getAddress(req) {
141 // TODO: RFC7239 Forwarded support
142 const address = (this.trustProxy && req && req.getHeader(Enum.Header.XForwardedFor)) ||
143 (this.trustProxy && req && req.getHeader(Enum.Header.XRealIP)) ||
144 (req && req.connection && req.connection.remoteAddress) ||
145 '';
146 return address.split(/\s*,\s*/u)[0];
147 }
148
149
150 /**
151 *
152 * @param {http.ClientRequest} req
153 */
154 _getProtocol(req) {
155 // TODO: RFC7239 Forwarded support
156 const protocol = (this.trustProxy && req && req.getHeader(Enum.Header.XForwardedProto)) ||
157 ((req && req.connection && req.connection.encrypted) ? 'https' : 'http');
158 return protocol.split(/\s*,\s*/u)[0];
159 }
160
161
162 /**
163 *
164 * @param {http.ClientRequest} req
165 * @param {http.ServerResponse} res
166 * @param {object} ctx
167 */
168 clientAddressContext(req, res, ctx) {
169 ctx.clientAddress = this._getAddress(req);
170 ctx.clientProtocol = this._getProtocol(req);
171 }
172
173
174 /**
175 * Called before every request handler.
176 * @param {http.ClientRequest} req
177 * @param {http.ServerResponse} res
178 * @param {object} ctx
179 */
180 async preHandler(req, res, ctx) {
181 Dingus.tagContext(req, res, ctx);
182 this.clientAddressContext(req, res, ctx);
183 }
184
185
186 /**
187 * Helper for collecting chunks as array of buffers.
188 * @param {Buffer[]} chunks
189 * @param {string|Buffer} chunk
190 * @param {string} encoding
191 */
192 static pushBufChunk(chunks, chunk, encoding = 'utf8') {
193 if (chunk) {
194 if (typeof chunk === 'string') {
195 chunk = Buffer.from(chunk, encoding);
196 }
197 chunks.push(chunk);
198 }
199 }
200
201
202 /**
203 * Sets ctx.responseBody and calls handler upon res.end().
204 * @param {http.ClientRequest} req
205 * @param {http.ServerResponse} res
206 * @param {object} ctx
207 * @param {*} handler fn(req, res, ctx)
208 */
209 static setEndBodyHandler(req, res, ctx, handler) {
210 const origWrite = res.write.bind(res);
211 const origEnd = res.end.bind(res);
212 const chunks = [];
213 res.write = function (chunk, encoding, ...rest) {
214 Dingus.pushBufChunk(chunks, chunk, encoding);
215 return origWrite(chunk, encoding, ...rest);
216 };
217 res.end = function (data, encoding, ...rest) {
218 Dingus.pushBufChunk(chunks, data, encoding);
219 ctx.responseBody = Buffer.concat(chunks);
220 handler(req, res, ctx);
221 return origEnd(data, encoding, ...rest);
222 };
223 }
224
225
226 /**
227 * Intercept writes for head requests, do not send to client,
228 * but send length, and make body available in context.
229 * N.B. If persisted, ctx.responseBody will be a raw buffer, be aware when logging.
230 * @param {http.ClientRequest} req
231 * @param {http.ServerResponse} res
232 * @param {object} ctx
233 * @param {Boolean} persistResponseBody
234 */
235 static setHeadHandler(req, res, ctx, persistResponseBody = false) {
236 if (req.method === 'HEAD') {
237 const origEnd = res.end.bind(res);
238 const chunks = [];
239 res.write = function (chunk, encoding) {
240 Dingus.pushBufChunk(chunks, chunk, encoding);
241 // No call to original res.write.
242 };
243 res.end = function (data, encoding, ...rest) {
244 Dingus.pushBufChunk(chunks, data, encoding);
245 const responseBody = Buffer.concat(chunks);
246 res.setHeader(Enum.Header.ContentLength, Buffer.byteLength(responseBody));
247 if (persistResponseBody) {
248 ctx.responseBody = responseBody;
249 }
250 return origEnd(undefined, encoding, ...rest);
251 };
252 }
253 }
254
255
256 /**
257 * Dispatch the handler for a request
258 * @param {http.ClientRequest} req
259 * @param {http.ServerResponse} res
260 * @param {object} ctx
261 */
262 async dispatch(req, res, ctx = {}) {
263 const _scope = _fileScope('dispatch');
264
265 const { pathPart, queryParams } = this._splitUrl(req.url);
266 ctx.queryParams = queryParams;
267
268 let handler, handlerArgs = [];
269 try {
270 ({ handler, handlerArgs } = this.router.lookup(req.method, pathPart, ctx));
271 } catch (e) {
272 if (e instanceof DingusError) {
273 switch (e.message) {
274 case 'NoPath':
275 handler = this.handlerNotFound.bind(this);
276 break;
277 case 'NoMethod':
278 handler = this.handlerMethodNotAllowed.bind(this);
279 break;
280 default:
281 this.logger.error(_scope, 'unknown dingus error', { error: e });
282 handler = this.handlerInternalServerError.bind(this);
283 }
284 } else if (e instanceof URIError) {
285 handler = this.handlerBadRequest.bind(this);
286 } else {
287 this.logger.error(_scope, 'lookup failure', { error: e });
288 handler = this.handlerInternalServerError.bind(this);
289 }
290 }
291
292 try {
293 await this.preHandler(req, res, ctx);
294 return await handler(req, res, ctx, ...handlerArgs);
295 } catch (e) {
296 ctx.error = e;
297 this.sendErrorResponse(e, req, res, ctx);
298 }
299 }
300
301
302 /**
303 * Return normalized type, without any parameters.
304 * @param {http.ClientRequest} req
305 * @returns {string}
306 */
307 static getRequestContentType(req) {
308 const contentType = req.getHeader(Enum.Header.ContentType);
309 return (contentType || '').split(';')[0].trim().toLowerCase();
310 }
311
312
313 /**
314 * Parse rawBody as contentType into ctx.parsedBody.
315 * @param {string} contentType
316 * @param {object} ctx
317 * @param {string|buffer}
318 */
319 parseBody(contentType, ctx, rawBody) {
320 const _scope = _fileScope('parseBody');
321
322 if (!rawBody) {
323 // 1.2.4 and earlier expected rawBody on context
324 rawBody = ctx.rawBody;
325 }
326
327 switch (contentType) {
328 case Enum.ContentType.ApplicationForm:
329 ctx.parsedBody = this.querystring.parse(rawBody);
330 break;
331
332 case Enum.ContentType.ApplicationJson:
333 try {
334 ctx.parsedBody = JSON.parse(rawBody);
335 } catch (e) {
336 this.logger.debug(_scope, 'JSON parse failed', { requestId: ctx.requestId, error: e });
337 throw new ResponseError(Enum.ErrorResponse.BadRequest, e.message);
338 }
339 break;
340
341 default:
342 this.logger.debug(_scope, 'unhandled content-type', { requestId: ctx.requestId, contentType });
343 throw new ResponseError(Enum.ErrorResponse.UnsupportedMediaType);
344 }
345 }
346
347
348 /**
349 * Return all body data from a request.
350 * @param {http.ClientRequest} req
351 * @param {Number=} maximumBodySize
352 */
353 async bodyData(req, maximumBodySize) {
354 const _scope = _fileScope('bodyData');
355 return new Promise((resolve, reject) => {
356 const body = [];
357 let length = 0;
358 req.on('data', (chunk) => {
359 body.push(chunk);
360 length += Buffer.byteLength(chunk);
361 if (maximumBodySize && length > maximumBodySize) {
362 this.logger.debug(_scope, 'body data exceeded limit', { length, maximumBodySize });
363 reject(new ResponseError(Enum.ErrorResponse.RequestEntityTooLarge));
364 }
365 });
366 req.on('end', () => resolve(Buffer.concat(body).toString()));
367 req.on('error', (e) => {
368 this.logger.error(_scope, 'failed', { error: e });
369 reject(e);
370 });
371 });
372 }
373
374
375 /**
376 * Read and parse request body data.
377 * @param {http.ClientRequest} req
378 * @param {http.ServerResponse} res
379 * @param {object} ctx
380 * @param {object}
381 * @param {Boolean} .parseEmptyBody
382 * @param {Boolean} .persistRawBody
383 */
384 async ingestBody(req, res, ctx, { parseEmptyBody = true, persistRawBody = false, maximumBodySize } = {}) {
385 const rawBody = await this.bodyData(req, maximumBodySize);
386 if (persistRawBody) {
387 ctx.rawBody = rawBody;
388 }
389 if (rawBody || parseEmptyBody) {
390 const contentType = Dingus.getRequestContentType(req);
391 this.parseBody(contentType, ctx, rawBody);
392 }
393 }
394
395
396 /**
397 * Return the best matching response type.
398 * @param {string[]} responseTypes
399 * @param {http.ClientRequest} req
400 */
401 static getResponseContentType(responseTypes, req) {
402 const acceptHeader = req.getHeader(Enum.Header.Accept);
403 return ContentNegotiation.accept(responseTypes, acceptHeader);
404 }
405
406
407 /**
408 * Returns a list of the most-preferred content encodings for the response.
409 * @param {string[]} responseEncodings
410 * @param {http.ClientRequest} req
411 */
412 static getResponseEncoding(responseEncodings, req) {
413 const acceptEncodingHeader = req.getHeader(Enum.Header.AcceptEncoding);
414 return ContentNegotiation.preferred(responseEncodings, acceptEncodingHeader);
415 }
416
417
418 /**
419 * Set the best content type for the response.
420 * @param {string[]} responseTypes default first
421 * @param {http.ClientRequest} req
422 * @param {http.ServerResponse} res
423 * @param {object} ctx
424 */
425 setResponseType(responseTypes, req, res, ctx) {
426 const _scope = _fileScope('setResponseType');
427 ctx.responseType = Dingus.getResponseContentType(responseTypes, req);
428 if (!ctx.responseType) {
429 if (this.strictAccept) {
430 this.logger.debug(_scope, 'unhandled strict accept', { requestId: req.requestId });
431 throw new ResponseError(Enum.ErrorResponse.NotAcceptable);
432 } else {
433 ctx.responseType = responseTypes[0];
434 }
435 }
436 res.setHeader(Enum.Header.ContentType, ctx.responseType);
437 }
438
439
440 /**
441 * Inserts an encoding
442 * @param {http.ServerResponse} res
443 * @param {string} encoding
444 */
445 static addEncodingHeader(res, encoding) {
446 const existingEncodings = res.getHeader(Enum.Header.ContentEncoding);
447 if (existingEncodings) {
448 encoding = `${encoding}, ${existingEncodings}`;
449 }
450 res.setHeader(Enum.Header.ContentEncoding, encoding);
451 }
452
453
454 /**
455 * Attempt to fetch both data and metadata for a file.
456 * @param {string} filePath
457 */
458 async _readFileInfo(filePath) {
459 const _scope = _fileScope('_readFileInfo');
460 let result;
461 try {
462 // eslint-disable-next-line security/detect-non-literal-fs-filename
463 const stat = fsPromises.stat(filePath);
464 // eslint-disable-next-line security/detect-non-literal-fs-filename
465 const data = fsPromises.readFile(filePath);
466 result = await Promise.all([stat, data]);
467 } catch (e) {
468 if (['ENOENT', 'EACCES', 'EISDIR', 'ENAMETOOLONG', 'EINVAL'].includes(e.code)) {
469 return [null, null];
470 }
471 this.logger.error(_scope, 'fs error', { error: e, filePath });
472 throw e;
473 }
474 return result;
475 }
476
477
478 /**
479 * Potentially add additional headers from static file meta-file.
480 * @param {http.ServerResponse} res
481 * @param {string} directory
482 * @param {string} fileName - already normalized and filtered
483 */
484 async _serveFileMetaHeaders(res, directory, fileName) {
485 const _scope = _fileScope('_serveFileMetaHeaders');
486 this.logger.debug(_scope, 'called', { directory, fileName });
487
488 const metaPrefix = '.';
489 const metaSuffix = '.meta';
490 const metaFileName = `${metaPrefix}${fileName}${metaSuffix}`;
491 const metaFilePath = path.join(directory, metaFileName);
492
493 const [stat, data] = await this._readFileInfo(metaFilePath);
494 if (!stat) {
495 return;
496 }
497
498 const lineBreakRE = /\r\n|\n|\r/;
499 const lines = data.toString().split(lineBreakRE);
500 common.unfoldHeaderLines(lines);
501
502 const headerParseRE = /^(?<name>[^:]+): +(?<value>.*)$/;
503 lines.forEach((line) => {
504 if (line) {
505 const result = headerParseRE.exec(line);
506 const { groups: header } = result;
507 res.setHeader(header.name, header.value);
508 }
509 });
510 }
511
512
513 /**
514 * Serve a file from a directory, with rudimentary cache awareness.
515 * This will also serve pre-encoded variations if available and requested.
516 * @param {http.ClientRequest} req
517 * @param {http.ServerResponse} res
518 * @param {object} ctx
519 * @param {string} directory
520 * @param {string} fileName
521 */
522 async serveFile(req, res, ctx, directory, fileName) {
523 const _scope = _fileScope('serveFile');
524 this.logger.debug(_scope, 'called', { req: common.requestLogData(req), ctx });
525
526 // Require a directory field.
527 if (!directory) {
528 this.logger.debug(_scope, 'rejected unset directory', { fileName });
529 return this.handlerNotFound(req, res, ctx);
530 }
531
532 // Normalize the supplied path, as encoded path-navigation may have been (maliciously) present.
533 fileName = path.normalize(fileName);
534
535 // We will not deal with any subdirs, nor any dot-files.
536 // (Note that we could not deal with subdirs even if we wanted, due to simple router matching scheme.)
537 if (fileName.indexOf(path.sep) >= 0
538 || fileName.charAt(0) === '.') {
539 this.logger.debug(_scope, 'rejected filename', { fileName });
540 return this.handlerNotFound(req, res, ctx);
541 }
542
543 const filePath = path.join(directory, fileName);
544
545 // File must exist, before any alternate static encodings will be considered.
546 let [stat, data] = await this._readFileInfo(filePath);
547 if (!stat) {
548 return this.handlerNotFound(req, res, ctx);
549 }
550
551 // If encodings were requested, check for static versions to serve.
552 // Update stat and data if matching version is found.
553 ctx.availableEncodings = Dingus.getResponseEncoding(Object.values(Enum.EncodingType), req);
554 if (ctx.availableEncodings.length === 0) {
555 // Identity encoding was specifically denied, and nothing else available.
556 this.logger.debug(_scope, 'no suitable encodings', { ctx });
557 return this.handlerMethodNotAllowed(req, res, ctx);
558 }
559 for (const encoding of ctx.availableEncodings) {
560 if (encoding === Enum.EncodingType.Identity) {
561 break;
562 }
563 const suffix = Enum.EncodingTypeSuffix[encoding];
564 if (suffix) {
565 const encodedFilePath = `${filePath}${suffix}`;
566 const [ encodedStat, encodedData ] = await this._readFileInfo(encodedFilePath);
567 if (encodedStat) {
568 ([ stat, data ] = [ encodedStat, encodedData ]);
569 ctx.selectedEncoding = encoding;
570 Dingus.addEncodingHeader(res, encoding);
571 res.setHeader(Enum.Header.Vary, Enum.Header.AcceptEncoding);
572 this.logger.debug(_scope, 'serving encoded version', { ctx, encodedFilePath });
573 }
574 break;
575 }
576 }
577
578 const lastModifiedDate = new Date(stat.mtimeMs);
579 res.setHeader(Enum.Header.LastModified, lastModifiedDate.toGMTString());
580
581 const eTag = common.generateETag(filePath, stat, data);
582 res.setHeader(Enum.Header.ETag, eTag);
583
584 if (common.isClientCached(req, stat.mtimeMs, eTag)) {
585 this.logger.debug(_scope, 'client cached file', { filePath });
586 res.statusCode = 304; // Not Modified
587 res.end();
588 return;
589 }
590
591 // Set the type based on extension of un-encoded filename.
592 const ext = path.extname(filePath).slice(1); // Drop the dot
593 const contentType = extensionToMime(ext);
594 res.setHeader(Enum.Header.ContentType, contentType);
595
596 // We presume static files are relatively cacheable.
597 res.setHeader(Enum.Header.CacheControl, 'public');
598
599 if (this.staticMetadata) {
600 await this._serveFileMetaHeaders(res, directory, fileName);
601 }
602
603 this.logger.debug(_scope, 'serving file', { filePath, contentType });
604 res.end(data);
605 }
606
607
608 /**
609 * Return a content-type appropriate rendering of an errorResponse object.
610 * @param {string} type content-type of response
611 * @param {object} err either an Error object, or an error response
612 * @param {number} err.statusCode
613 * @param {string} err.errorMessage
614 * @param {string|string[]} err.details
615 */
616 // eslint-disable-next-line class-methods-use-this
617 renderError(contentType, err) {
618 switch (contentType) {
619 case Enum.ContentType.ApplicationJson:
620 return JSON.stringify(err);
621
622 case Enum.ContentType.TextHTML:
623 return Template.errorHTML(err);
624
625 case Enum.ContentType.TextPlain:
626 default:
627 return [err.errorMessage, err.details].join('\r\n');
628 }
629 }
630
631
632 /**
633 * Send an error response. Terminal.
634 * Logs any non-error-response errors as such.
635 * @param {object} err either an Error object, or an error response
636 * @param {http.ClientRequest} req
637 * @param {http.ServerResponse} res
638 * @param {object} ctx
639 */
640 sendErrorResponse(err, req, res, ctx) {
641 const _scope = _fileScope('sendErrorResponse');
642 let body;
643
644 // Default to a content type if one is not yet present
645 if (!res.hasHeader(Enum.Header.ContentType)) {
646 res.setHeader(Enum.Header.ContentType, Enum.ContentType.TextPlain);
647 }
648
649 if (err && err.statusCode) {
650 res.statusCode = err.statusCode;
651 body = this.renderError(res.getHeader(Enum.Header.ContentType), err);
652 this.logger.debug(_scope, 'handler error', { err, ...common.handlerLogData(req, res, ctx) });
653 } else {
654 res.statusCode = 500;
655 body = this.renderError(res.getHeader(Enum.Header.ContentType), Enum.ErrorResponse.InternalServerError);
656 this.logger.error(_scope, 'handler exception', { err, ...common.handlerLogData(req, res, ctx) });
657 }
658 res.end(body);
659 }
660
661
662 /**
663 * @param {http.ClientRequest} req
664 * @param {http.ServerResponse} res
665 * @param {object} ctx
666 * @param {String} file - override ctx.params.file
667 */
668 async handlerGetStaticFile(req, res, ctx, file) {
669 Dingus.setHeadHandler(req, res, ctx);
670
671 // Set a default response type to handle any errors; will be re-set to serve actual static content type.
672 this.setResponseType(this.responseTypes, req, res, ctx);
673
674 await this.serveFile(req, res, ctx, this.staticPath, file || ctx.params.file);
675 }
676
677
678 /**
679 * @param {http.ClientRequest} req
680 * @param {http.ServerResponse} res
681 * @param {Object} ctx
682 * @param {String} newPath
683 * @param {Number} statusCode
684 */
685 async handlerRedirect(req, res, ctx, newPath, statusCode = 307) {
686 this.setResponseType(this.responseTypes, req, res, ctx);
687 res.setHeader(Enum.Header.Location, newPath);
688 res.statusCode = statusCode;
689 res.end();
690 }
691
692
693 /**
694 * @param {http.ClientRequest} req
695 * @param {http.ServerResponse} res
696 * @param {object} ctx
697 */
698 async handlerMethodNotAllowed(req, res, ctx) {
699 this.setResponseType(this.responseTypes, req, res, ctx);
700 throw new ResponseError(Enum.ErrorResponse.MethodNotAllowed);
701 }
702
703
704 /**
705 * @param {http.ClientRequest} req
706 * @param {http.ServerResponse} res
707 * @param {object} ctx
708 */
709 async handlerNotFound(req, res, ctx) {
710 this.setResponseType(this.responseTypes, req, res, ctx);
711 throw new ResponseError(Enum.ErrorResponse.NotFound);
712 }
713
714
715 /**
716 * @param {http.ClientRequest} req
717 * @param {http.ServerResponse} res
718 * @param {object} ctx
719 */
720 async handlerBadRequest(req, res, ctx) {
721 this.setResponseType(this.responseTypes, req, res, ctx);
722 throw new ResponseError(Enum.ErrorResponse.BadRequest);
723 }
724
725
726 /**
727 * @param {http.ClientRequest} req
728 * @param {http.ServerResponse} res
729 * @param {object} ctx
730 */
731 async handlerInternalServerError(req, res, ctx) {
732 this.setResponseType(this.responseTypes, req, res, ctx);
733 throw new ResponseError(Enum.ErrorResponse.InternalServerError);
734 }
735
736 }
737
738 module.exports = Dingus;