mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-12-26 09:50:47 +08:00
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
This commit is contained in:
parent
e9abf8581f
commit
490b4e5118
1 changed files with 27 additions and 6 deletions
|
@ -7,18 +7,39 @@ const tools = require('../tools');
|
|||
const roles = require('../roles');
|
||||
const base32 = require('base32.js');
|
||||
const { sessSchema, sessIPSchema } = require('../schemas');
|
||||
const { userId } = require('../schemas/request/general-schemas');
|
||||
|
||||
module.exports = (db, server, notifier) => {
|
||||
server.get(
|
||||
'/users/:user/updates',
|
||||
{
|
||||
path: '/users/:user/updates',
|
||||
tags: ['Users'],
|
||||
summary: 'Open change stream',
|
||||
description:
|
||||
'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',
|
||||
validationObjs: {
|
||||
requestBody: {},
|
||||
queryParams: {
|
||||
'Last-Event-ID': Joi.string().hex().lowercase().length(24).description('Last event ID header as query param'),
|
||||
sess: sessSchema,
|
||||
ip: sessIPSchema
|
||||
},
|
||||
pathParams: {
|
||||
user: userId
|
||||
},
|
||||
response: { 200: { description: 'Success', model: Joi.string() } }
|
||||
},
|
||||
responseType: 'text/event-stream'
|
||||
},
|
||||
tools.responseWrapper(async (req, res) => {
|
||||
res.charSet('utf-8');
|
||||
|
||||
const schema = Joi.object().keys({
|
||||
user: Joi.string().hex().lowercase().length(24).required(),
|
||||
'Last-Event-ID': Joi.string().hex().lowercase().length(24),
|
||||
sess: sessSchema,
|
||||
ip: sessIPSchema
|
||||
const { pathParams, requestBody, queryParams } = req.route.spec.validationObjs;
|
||||
|
||||
const schema = Joi.object({
|
||||
...pathParams,
|
||||
...requestBody,
|
||||
...queryParams
|
||||
});
|
||||
|
||||
if (req.header('Last-Event-ID')) {
|
||||
|
|
Loading…
Reference in a new issue