Skip to content

Commit d50c1fb

Browse files
committed
prettier
1 parent 66fb2a0 commit d50c1fb

File tree

3 files changed

+43
-41
lines changed

3 files changed

+43
-41
lines changed

index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class API {
4242
: {};
4343
this._compression =
4444
props &&
45-
(typeof props.compression === 'boolean' ||
46-
Array.isArray(props.compression))
45+
(typeof props.compression === 'boolean' ||
46+
Array.isArray(props.compression))
4747
? props.compression
4848
: false;
4949

@@ -84,7 +84,7 @@ class API {
8484
this._app = {};
8585

8686
// Executed after the callback
87-
this._finally = () => { };
87+
this._finally = () => {};
8888

8989
// Global error status (used for response parsing errors)
9090
this._errorStatus = 500;
@@ -213,8 +213,8 @@ class API {
213213
stack: _stack['m'][method]
214214
? _stack['m'][method].concat(stack)
215215
: _stack['*'][method]
216-
? _stack['*'][method].concat(stack)
217-
: stack,
216+
? _stack['*'][method].concat(stack)
217+
: stack,
218218
// inherited: _stack[method] ? _stack[method] : [],
219219
route: '/' + parsedPath.join('/'),
220220
path: '/' + this._prefix.concat(parsedPath).join('/'),
@@ -447,8 +447,8 @@ class API {
447447
typeof args[0] === 'string'
448448
? Array.of(args.shift())
449449
: Array.isArray(args[0])
450-
? args.shift()
451-
: ['/*'];
450+
? args.shift()
451+
: ['/*'];
452452

453453
// Init middleware stack
454454
let middleware = [];

lib/errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ module.exports = {
6767
ConfigurationError,
6868
ResponseError,
6969
ApiError,
70-
FileError
70+
FileError,
7171
};

lib/response.js

+35-33
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ class RESPONSE {
8585
return asArr
8686
? this._headers
8787
: Object.keys(this._headers).reduce(
88-
(headers, key) =>
89-
Object.assign(headers, { [key]: this._headers[key].toString() }),
90-
{}
91-
); // return all headers
88+
(headers, key) =>
89+
Object.assign(headers, { [key]: this._headers[key].toString() }),
90+
{}
91+
); // return all headers
9292
return asArr
9393
? this._headers[key.toLowerCase()]
9494
: this._headers[key.toLowerCase()]
95-
? this._headers[key.toLowerCase()].toString()
96-
: undefined;
95+
? this._headers[key.toLowerCase()].toString()
96+
: undefined;
9797
}
9898

9999
// Issue #130
@@ -131,9 +131,9 @@ class RESPONSE {
131131

132132
this.header('Content-Type', 'application/json').send(
133133
(cb ? cb.replace(' ', '_') : 'callback') +
134-
'(' +
135-
this._serializer(body) +
136-
')'
134+
'(' +
135+
this._serializer(body) +
136+
')'
137137
);
138138
}
139139

@@ -193,8 +193,8 @@ class RESPONSE {
193193
typeof expires === 'function'
194194
? expires
195195
: typeof callback === 'function'
196-
? callback
197-
: (e) => {
196+
? callback
197+
: (e) => {
198198
if (e) this.error(e);
199199
};
200200

@@ -236,10 +236,10 @@ class RESPONSE {
236236
cookieString +=
237237
opts.maxAge && !isNaN(opts.maxAge)
238238
? '; MaxAge=' +
239-
((opts.maxAge / 1000) | 0) +
240-
(!opts.expires
241-
? '; Expires=' + new Date(Date.now() + opts.maxAge).toUTCString()
242-
: '')
239+
((opts.maxAge / 1000) | 0) +
240+
(!opts.expires
241+
? '; Expires=' + new Date(Date.now() + opts.maxAge).toUTCString()
242+
: '')
243243
: '';
244244

245245
// path (String): Path for the cookie
@@ -253,9 +253,9 @@ class RESPONSE {
253253
cookieString +=
254254
opts.sameSite !== undefined
255255
? '; SameSite=' +
256-
(opts.sameSite === true
257-
? 'Strict'
258-
: opts.sameSite === false
256+
(opts.sameSite === true
257+
? 'Strict'
258+
: opts.sameSite === false
259259
? 'Lax'
260260
: opts.sameSite)
261261
: '';
@@ -323,7 +323,7 @@ class RESPONSE {
323323
let buffer, modified;
324324

325325
let opts = typeof options === 'object' ? options : {};
326-
let fn = typeof callback === 'function' ? callback : () => { };
326+
let fn = typeof callback === 'function' ? callback : () => {};
327327

328328
// Add optional parameter support
329329
if (typeof options === 'function') {
@@ -440,16 +440,16 @@ class RESPONSE {
440440
opts.methods
441441
? opts.methods
442442
: acam
443-
? acam
444-
: 'GET, PUT, POST, DELETE, OPTIONS'
443+
? acam
444+
: 'GET, PUT, POST, DELETE, OPTIONS'
445445
);
446446
this.header(
447447
'Access-Control-Allow-Headers',
448448
opts.headers
449449
? opts.headers
450450
: acah
451-
? acah
452-
: 'Content-Type, Authorization, Content-Length, X-Requested-With'
451+
? acah
452+
: 'Content-Type, Authorization, Content-Length, X-Requested-With'
453453
);
454454

455455
// Optional CORS headers
@@ -500,8 +500,8 @@ class RESPONSE {
500500
date && typeof date.toUTCString === 'function'
501501
? date
502502
: date && Date.parse(date)
503-
? new Date(date)
504-
: new Date();
503+
? new Date(date)
504+
: new Date();
505505
this.header('Last-Modified', lastModified.toUTCString());
506506
}
507507
return this;
@@ -559,10 +559,10 @@ class RESPONSE {
559559
},
560560
this._request.interface === 'alb'
561561
? {
562-
statusDescription: `${this._statusCode} ${UTILS.statusLookup(
563-
this._statusCode
564-
)}`,
565-
}
562+
statusDescription: `${this._statusCode} ${UTILS.statusLookup(
563+
this._statusCode
564+
)}`,
565+
}
566566
: {}
567567
);
568568

@@ -596,11 +596,13 @@ class RESPONSE {
596596
error(code, e, detail) {
597597
const message = typeof code !== 'number' ? code : e;
598598
const statusCode = typeof code === 'number' ? code : undefined;
599-
const errorDetail = typeof code !== 'number' && e !== undefined ? e : detail;
599+
const errorDetail =
600+
typeof code !== 'number' && e !== undefined ? e : detail;
600601

601-
const errorToSend = typeof message === 'string'
602-
? new ApiError(message, statusCode, errorDetail)
603-
: message;
602+
const errorToSend =
603+
typeof message === 'string'
604+
? new ApiError(message, statusCode, errorDetail)
605+
: message;
604606

605607
this.app.catchErrors(errorToSend, this, statusCode, errorDetail);
606608
} // end error

0 commit comments

Comments
 (0)