diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-01 01:36:53 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-02 16:57:07 +0200 |
commit | 76148b27f7501bac061992136852be4303370c8d (patch) | |
tree | fc0559253e833c9252fa14ebaec5321d88bfb4e8 /server/controllers/static.ts | |
parent | 5ed25fb76e920dac364cb9ef46f14ec4bd372949 (diff) | |
download | PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.gz PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.zst PeerTube-76148b27f7501bac061992136852be4303370c8d.zip |
refactor API errors to standard error format
Diffstat (limited to 'server/controllers/static.ts')
-rw-r--r-- | server/controllers/static.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 3870ebfe9..52e104346 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -160,10 +160,9 @@ async function generateNodeinfo (req: express.Request, res: express.Response) { | |||
160 | const { totalVideos } = await VideoModel.getStats() | 160 | const { totalVideos } = await VideoModel.getStats() |
161 | const { totalLocalVideoComments } = await VideoCommentModel.getStats() | 161 | const { totalLocalVideoComments } = await VideoCommentModel.getStats() |
162 | const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats() | 162 | const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats() |
163 | let json = {} | ||
164 | 163 | ||
165 | if (req.params.version && (req.params.version === '2.0')) { | 164 | if (req.params.version && (req.params.version === '2.0')) { |
166 | json = { | 165 | const json = { |
167 | version: '2.0', | 166 | version: '2.0', |
168 | software: { | 167 | software: { |
169 | name: 'peertube', | 168 | name: 'peertube', |
@@ -291,12 +290,14 @@ async function generateNodeinfo (req: express.Request, res: express.Response) { | |||
291 | } | 290 | } |
292 | } as HttpNodeinfoDiasporaSoftwareNsSchema20 | 291 | } as HttpNodeinfoDiasporaSoftwareNsSchema20 |
293 | res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"') | 292 | res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"') |
294 | } else { | 293 | .send(json) |
295 | json = { error: 'Nodeinfo schema version not handled' } | 294 | .end() |
296 | res.status(HttpStatusCode.NOT_FOUND_404) | ||
297 | } | 295 | } |
298 | 296 | ||
299 | return res.send(json).end() | 297 | return res.fail({ |
298 | status: HttpStatusCode.NOT_FOUND_404, | ||
299 | message: 'Nodeinfo schema version not handled' | ||
300 | }) | ||
300 | } | 301 | } |
301 | 302 | ||
302 | function getCup (req: express.Request, res: express.Response, next: express.NextFunction) { | 303 | function getCup (req: express.Request, res: express.Response, next: express.NextFunction) { |