Skip to content

Commit 490b4e5

Browse files
authored
fix(api-users-updates): added users/updates api endpoint to api docs generation ZMS-155 (#687)
* Added submission api endpoint to api docs generation * added users updates api endpoin to api docs generation
1 parent e9abf85 commit 490b4e5

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

lib/api/updates.js

+27-6
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,39 @@ const tools = require('../tools');
77
const roles = require('../roles');
88
const base32 = require('base32.js');
99
const { sessSchema, sessIPSchema } = require('../schemas');
10+
const { userId } = require('../schemas/request/general-schemas');
1011

1112
module.exports = (db, server, notifier) => {
1213
server.get(
13-
'/users/:user/updates',
14+
{
15+
path: '/users/:user/updates',
16+
tags: ['Users'],
17+
summary: 'Open change stream',
18+
description:
19+
'This api call returns an EventSource response. Listen on this stream to get notifications about changes in messages and mailboxes. Returned events are JSON encoded strings',
20+
validationObjs: {
21+
requestBody: {},
22+
queryParams: {
23+
'Last-Event-ID': Joi.string().hex().lowercase().length(24).description('Last event ID header as query param'),
24+
sess: sessSchema,
25+
ip: sessIPSchema
26+
},
27+
pathParams: {
28+
user: userId
29+
},
30+
response: { 200: { description: 'Success', model: Joi.string() } }
31+
},
32+
responseType: 'text/event-stream'
33+
},
1434
tools.responseWrapper(async (req, res) => {
1535
res.charSet('utf-8');
1636

17-
const schema = Joi.object().keys({
18-
user: Joi.string().hex().lowercase().length(24).required(),
19-
'Last-Event-ID': Joi.string().hex().lowercase().length(24),
20-
sess: sessSchema,
21-
ip: sessIPSchema
37+
const { pathParams, requestBody, queryParams } = req.route.spec.validationObjs;
38+
39+
const schema = Joi.object({
40+
...pathParams,
41+
...requestBody,
42+
...queryParams
2243
});
2344

2445
if (req.header('Last-Event-ID')) {

0 commit comments

Comments
 (0)