aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/express-utils.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts
index bca59a83c..10a860787 100644
--- a/server/helpers/express-utils.ts
+++ b/server/helpers/express-utils.ts
@@ -129,15 +129,14 @@ function getCountVideos (req: express.Request) {
129// helpers added in server.ts and used in subsequent controllers used 129// helpers added in server.ts and used in subsequent controllers used
130const apiResponseHelpers = (req, res: express.Response, next = null) => { 130const apiResponseHelpers = (req, res: express.Response, next = null) => {
131 res.fail = (options) => { 131 res.fail = (options) => {
132 const { data, status, message, title, type, docs, instance } = { 132 const { data, status = HttpStatusCode.BAD_REQUEST_400, message, title, type, docs = res.docs, instance } = options
133 data: null,
134 ...options,
135 status: options.status || HttpStatusCode.BAD_REQUEST_400
136 }
137 133
138 const extension = new ProblemDocumentExtension({ 134 const extension = new ProblemDocumentExtension({
139 ...data, 135 ...data,
140 docs: docs || res.docs 136 docs,
137 // fields for <= 3.2 compatibility, deprecated
138 error: message,
139 code: type
141 }) 140 })
142 141
143 res.status(status) 142 res.status(status)
@@ -146,12 +145,13 @@ const apiResponseHelpers = (req, res: express.Response, next = null) => {
146 status, 145 status,
147 title, 146 title,
148 instance, 147 instance,
149 type: type && '' + type, 148 // fields intended to replace 'error' and 'code' respectively
150 detail: message 149 detail: message,
150 type: type && 'https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/' + type
151 }, extension)) 151 }, extension))
152 } 152 }
153 153
154 if (next !== null) next() 154 if (next) next()
155} 155}
156 156
157// --------------------------------------------------------------------------- 157// ---------------------------------------------------------------------------