This commit is contained in:
Andris Reinman 2020-05-08 10:55:07 +03:00
parent dfe1e0944b
commit e0ad98e3ef
13 changed files with 106 additions and 82 deletions

View file

@ -8,7 +8,7 @@ secure=false
# If set requires all API calls to have accessToken query argument with that value
# http://localhost:8080/users?accessToken=somesecretvalue
accessToken="somesecretvalue"
#accessToken="somesecretvalue"
[accessControl]
# If true then require a valid access token to perform API calls

View file

@ -8394,6 +8394,13 @@ define({ "api": [
"field": "results.date",
"description": "<p>Datestring</p>"
},
{
"group": "Success 200",
"type": "Number",
"optional": false,
"field": "results.size",
"description": "<p>Message size in bytes</p>"
},
{
"group": "Success 200",
"type": "String",
@ -8476,7 +8483,7 @@ define({ "api": [
"examples": [
{
"title": "Success-Response:",
"content": "HTTP/1.1 200 OK\n{\n \"success\": true,\n \"total\": 1,\n \"page\": 1,\n \"previousCursor\": false,\n \"nextCursor\": false,\n \"specialUse\": null,\n \"results\": [\n {\n \"id\": 1,\n \"mailbox\": \"59fc66a03e54454869460e46\",\n \"thread\": \"59fc66a13e54454869460e50\",\n \"from\": {\n \"address\": \"rfinnie@domain.dom\",\n \"name\": \"Ryan Finnie\"\n },\n \"subject\": \"Ryan Finnie's MIME Torture Test v1.0\",\n \"date\": \"2003-10-24T06:28:34.000Z\",\n \"intro\": \"Welcome to Ryan Finnie's MIME torture test. This message was designed to introduce a couple of the newer features of MIME-aware…\",\n \"attachments\": true,\n \"seen\": true,\n \"deleted\": false,\n \"flagged\": true,\n \"draft\": false,\n \"answered\": false,\n \"forwarded\": false,\n \"url\": \"/users/59fc66a03e54454869460e45/mailboxes/59fc66a03e54454869460e46/messages/1\",\n \"contentType\": {\n \"value\": \"multipart/mixed\",\n \"params\": {\n \"boundary\": \"=-qYxqvD9rbH0PNeExagh1\"\n }\n }\n }\n ]\n}",
"content": "HTTP/1.1 200 OK\n{\n \"success\": true,\n \"total\": 1,\n \"page\": 1,\n \"previousCursor\": false,\n \"nextCursor\": false,\n \"specialUse\": null,\n \"results\": [\n {\n \"id\": 1,\n \"mailbox\": \"59fc66a03e54454869460e46\",\n \"thread\": \"59fc66a13e54454869460e50\",\n \"from\": {\n \"address\": \"rfinnie@domain.dom\",\n \"name\": \"Ryan Finnie\"\n },\n \"subject\": \"Ryan Finnie's MIME Torture Test v1.0\",\n \"date\": \"2003-10-24T06:28:34.000Z\",\n \"intro\": \"Welcome to Ryan Finnie's MIME torture test. This message was designed to introduce a couple of the newer features of MIME-aware…\",\n \"attachments\": true,\n \"size\": 1234,\n \"seen\": true,\n \"deleted\": false,\n \"flagged\": true,\n \"draft\": false,\n \"answered\": false,\n \"forwarded\": false,\n \"url\": \"/users/59fc66a03e54454869460e45/mailboxes/59fc66a03e54454869460e46/messages/1\",\n \"contentType\": {\n \"value\": \"multipart/mixed\",\n \"params\": {\n \"boundary\": \"=-qYxqvD9rbH0PNeExagh1\"\n }\n }\n }\n ]\n}",
"type": "json"
}
]

View file

@ -8394,6 +8394,13 @@
"field": "results.date",
"description": "<p>Datestring</p>"
},
{
"group": "Success 200",
"type": "Number",
"optional": false,
"field": "results.size",
"description": "<p>Message size in bytes</p>"
},
{
"group": "Success 200",
"type": "String",
@ -8476,7 +8483,7 @@
"examples": [
{
"title": "Success-Response:",
"content": "HTTP/1.1 200 OK\n{\n \"success\": true,\n \"total\": 1,\n \"page\": 1,\n \"previousCursor\": false,\n \"nextCursor\": false,\n \"specialUse\": null,\n \"results\": [\n {\n \"id\": 1,\n \"mailbox\": \"59fc66a03e54454869460e46\",\n \"thread\": \"59fc66a13e54454869460e50\",\n \"from\": {\n \"address\": \"rfinnie@domain.dom\",\n \"name\": \"Ryan Finnie\"\n },\n \"subject\": \"Ryan Finnie's MIME Torture Test v1.0\",\n \"date\": \"2003-10-24T06:28:34.000Z\",\n \"intro\": \"Welcome to Ryan Finnie's MIME torture test. This message was designed to introduce a couple of the newer features of MIME-aware…\",\n \"attachments\": true,\n \"seen\": true,\n \"deleted\": false,\n \"flagged\": true,\n \"draft\": false,\n \"answered\": false,\n \"forwarded\": false,\n \"url\": \"/users/59fc66a03e54454869460e45/mailboxes/59fc66a03e54454869460e46/messages/1\",\n \"contentType\": {\n \"value\": \"multipart/mixed\",\n \"params\": {\n \"boundary\": \"=-qYxqvD9rbH0PNeExagh1\"\n }\n }\n }\n ]\n}",
"content": "HTTP/1.1 200 OK\n{\n \"success\": true,\n \"total\": 1,\n \"page\": 1,\n \"previousCursor\": false,\n \"nextCursor\": false,\n \"specialUse\": null,\n \"results\": [\n {\n \"id\": 1,\n \"mailbox\": \"59fc66a03e54454869460e46\",\n \"thread\": \"59fc66a13e54454869460e50\",\n \"from\": {\n \"address\": \"rfinnie@domain.dom\",\n \"name\": \"Ryan Finnie\"\n },\n \"subject\": \"Ryan Finnie's MIME Torture Test v1.0\",\n \"date\": \"2003-10-24T06:28:34.000Z\",\n \"intro\": \"Welcome to Ryan Finnie's MIME torture test. This message was designed to introduce a couple of the newer features of MIME-aware…\",\n \"attachments\": true,\n \"size\": 1234,\n \"seen\": true,\n \"deleted\": false,\n \"flagged\": true,\n \"draft\": false,\n \"answered\": false,\n \"forwarded\": false,\n \"url\": \"/users/59fc66a03e54454869460e45/mailboxes/59fc66a03e54454869460e46/messages/1\",\n \"contentType\": {\n \"value\": \"multipart/mixed\",\n \"params\": {\n \"boundary\": \"=-qYxqvD9rbH0PNeExagh1\"\n }\n }\n }\n ]\n}",
"type": "json"
}
]

View file

@ -9,8 +9,8 @@ define({
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2020-04-24T08:30:35.796Z",
"time": "2020-05-08T07:54:54.784Z",
"url": "http://apidocjs.com",
"version": "0.20.1"
"version": "0.22.1"
}
});

View file

@ -9,8 +9,8 @@
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2020-04-24T08:30:35.796Z",
"time": "2020-05-08T07:54:54.784Z",
"url": "http://apidocjs.com",
"version": "0.20.1"
"version": "0.22.1"
}
}

View file

@ -291,7 +291,7 @@
<div class="form-group">
<label class="col-md-3 control-label" for="sample-request-param-field-{{field}}">{{field}}</label>
<div class="input-group">
<input id="sample-request-param-field-{{field}}" type="text" placeholder="{{field}}" class="form-control sample-request-param" data-sample-request-param-name="{{field}}" data-sample-request-param-group="sample-request-param-{{@../index}}" {{#if optional}}data-sample-request-param-optional="true"{{/if}}>
<input id="sample-request-param-field-{{field}}" type="{{setInputType type}}" placeholder="{{field}}" class="form-control sample-request-param" data-sample-request-param-name="{{field}}" data-sample-request-param-group="sample-request-param-{{@../index}}" {{#if optional}}data-sample-request-param-optional="true"{{/if}}>
<div class="input-group-addon">{{{type}}}</div>
</div>
</div>

View file

@ -12,7 +12,9 @@ require.config({
semver: './vendor/semver.min',
utilsSampleRequest: './utils/send_sample_request',
webfontloader: './vendor/webfontloader',
list: './vendor/list.min'
list: './vendor/list.min',
apiData: './api_data',
apiProject: './api_project',
},
shim: {
bootstrap: {
@ -41,8 +43,8 @@ require([
'lodash',
'locales',
'handlebarsExtended',
'./api_project.js',
'./api_data.js',
'apiProject',
'apiData',
'prettify',
'utilsSampleRequest',
'semver',
@ -52,9 +54,19 @@ require([
'list'
], function($, _, locale, Handlebars, apiProject, apiData, prettyPrint, sampleRequest, semver, WebFont) {
// load google web fonts
loadGoogleFontCss();
// Load google web fonts.
WebFont.load({
active: function() {
// Only init after fonts are loaded.
init($, _, locale, Handlebars, apiProject, apiData, prettyPrint, sampleRequest, semver);
},
google: {
families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7']
}
});
});
function init($, _, locale, Handlebars, apiProject, apiData, prettyPrint, sampleRequest, semver) {
var api = apiData.api;
//
@ -385,7 +397,7 @@ require([
$('#sections').append( content );
// Bootstrap Scrollspy
$(this).scrollspy({ target: '#scrollingNav', offset: 18 });
$(this).scrollspy({ target: '#scrollingNav' });
// Content-Scroll on Navigation click.
$('.sidenav').find('a').on('click', function(e) {
@ -396,13 +408,6 @@ require([
window.location.hash = $(this).attr('href');
});
// Quickjump on Pageload to hash position.
if(window.location.hash) {
var id = window.location.hash;
if ($(id).length > 0)
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 0);
}
/**
* Check if Parameter (sub) List has a type Field.
* Example: @apiSuccess varname1 No type.
@ -535,11 +540,13 @@ require([
// HTML-Template specific jQuery-Functions
//
// Change Main Version
$('#versions li.version a').on('click', function(e) {
e.preventDefault();
var selectedVersion = $(this).html();
$('#version strong').html(selectedVersion);
function setMainVersion(selectedVersion) {
if (typeof(selectedVersion) === 'undefined') {
selectedVersion = $('#version strong').html();
}
else {
$('#version strong').html(selectedVersion);
}
// hide all
$('article').addClass('hide');
@ -575,6 +582,13 @@ require([
initDynamic();
return;
}
setMainVersion();
$('#versions li.version a').on('click', function(e) {
e.preventDefault();
setMainVersion($(this).html());
});
// compare all article with their predecessor
@ -592,11 +606,17 @@ require([
if ($.urlParam('compare')) {
// URL Paramter ?compare=1 is set
$('#compareAllWithPredecessor').trigger('click');
}
if (window.location.hash) {
var id = window.location.hash;
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) - 18 }, 0);
}
// Quick jump on page load to hash position.
// Should happen after setting the main version
// and after triggering the click on the compare button,
// as these actions modify the content
// and would make it jump to the wrong position or not jump at all.
if (window.location.hash) {
var id = window.location.hash;
if ($(id).length > 0)
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 0);
}
/**
@ -854,21 +874,6 @@ require([
return;
}
/**
* Load google fonts.
*/
function loadGoogleFontCss() {
WebFont.load({
active: function() {
// Update scrollspy
$(window).scrollspy('refresh')
},
google: {
families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7']
}
});
}
/**
* Return ordered entries by custom order and append not defined entries to the end.
* @param {String[]} elements
@ -899,5 +904,4 @@ require([
});
return results;
}
});
}

View file

@ -21,6 +21,16 @@ define([
return text;
});
/**
* set paramater type.
*/
Handlebars.registerHelper("setInputType", function(text) {
if (text === "File") {
return "file";
}
return "text";
});
/**
* start/stop timer for simple performance check.
*/

16
docs/api/utils/send_sample_request.js Normal file → Executable file
View file

@ -53,8 +53,7 @@ define([
// create JSON dictionary of parameters
var param = {};
var paramType = {};
var bodyFormData = {};
var bodyFormDataType = {};
var bodyFormData = new FormData();
var bodyJson = '';
$root.find(".sample-request-param:checked").each(function(i, element) {
var group = $(element).data("sample-request-param-group-id");
@ -79,8 +78,10 @@ define([
}
if (contentType == "body-form-data"){
header['Content-Type'] = 'multipart/form-data'
bodyFormData[key] = value;
bodyFormDataType[key] = $(element).next().text();
if (element.type == "file") {
value = element.files[0];
}
bodyFormData.append(key,value);
}else {
param[key] = value;
paramType[key] = $(element).next().text();
@ -93,7 +94,7 @@ define([
var url = $root.find(".sample-request-url").val();
//Convert {param} form to :param
url = url.replace(/{/,':').replace(/}/,'');
url = utils.convertPathParams(url);
// Insert url parameter
var pattern = pathToRegexp(url, null);
@ -134,6 +135,11 @@ define([
error : displayError
};
if(header['Content-Type'] == 'multipart/form-data'){
delete ajaxRequest.headers['Content-Type'];
ajaxRequest.contentType=false;
ajaxRequest.processData=false;
}
$.ajax(ajaxRequest);

7
docs/api/utils/send_sample_request_utils.js Normal file → Executable file
View file

@ -47,5 +47,10 @@ define([], function () {
return result;
}
return {handleNestedAndParsingFields};
// Converts path params in the {param} format to the accepted :param format, used before inserting the URL params.
function convertPathParams(url) {
return url.replace(/{(.+?)}/g, ':$1');
}
return {handleNestedAndParsingFields,convertPathParams};
});

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "wildduck",
"version": "1.25.0",
"version": "1.25.1",
"description": "IMAP/POP3 server built with Node.js and MongoDB",
"main": "server.js",
"scripts": {

View file

@ -32,7 +32,7 @@ const URL = 'http://127.0.0.1:8080';
const user2PubKey = fs.readFileSync(__dirname + '/fixtures/user2-public.key', 'utf-8');
const user3PubKey = fs.readFileSync(__dirname + '/fixtures/user3-public.key', 'utf-8');
describe('Send multiple messages', function() {
describe('Send multiple messages', function () {
this.timeout(100 * 1000); // eslint-disable-line
let userIds = [];
@ -268,14 +268,8 @@ describe('Send multiple messages', function() {
expect(message.attachments.length).to.equal(3);
expect(message.parsed.attachments.length).to.equal(3);
for (let i = 0; i < message.attachments.length; i++) {
let hashA = crypto
.createHash('md5')
.update(message.attachments[i].raw)
.digest('hex');
let hashB = crypto
.createHash('md5')
.update(message.parsed.attachments[i].content)
.digest('hex');
let hashA = crypto.createHash('md5').update(message.attachments[i].raw).digest('hex');
let hashB = crypto.createHash('md5').update(message.parsed.attachments[i].content).digest('hex');
expect(hashA).equal(hashB);
}
expect(message.parsed.to.value).deep.equal([
@ -341,18 +335,9 @@ describe('Send multiple messages', function() {
let swanJpg = fs.readFileSync(__dirname + '/../examples/swan.jpg');
let checksums = [
crypto
.createHash('md5')
.update(imagePng)
.digest('hex'),
crypto
.createHash('md5')
.update(Buffer.from(textTxt))
.digest('hex'),
crypto
.createHash('md5')
.update(swanJpg)
.digest('hex')
crypto.createHash('md5').update(imagePng).digest('hex'),
crypto.createHash('md5').update(Buffer.from(textTxt)).digest('hex'),
crypto.createHash('md5').update(swanJpg).digest('hex')
];
const client = new BrowserBox('localhost', 9993, {