Added jsdoc for the node part of etherpad. (#5983)

This commit is contained in:
SamTV12345 2023-10-17 12:49:56 +02:00 committed by GitHub
parent 53d1e8a160
commit ff1b929eb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 284 additions and 71 deletions

View file

@ -1,6 +1,14 @@
'use strict';
const eejs = require('../../eejs');
/**
* Add the admin navigation link
* @param hookName {String} the name of the hook
* @param args {Object} the object containing the arguments
* @param {Function} cb the callback function
* @return {*}
*/
exports.expressCreateServer = (hookName, args, cb) => {
args.app.get('/admin', (req, res) => {
if ('/' !== req.path[req.path.length - 1]) return res.redirect('./admin/');

View file

@ -121,6 +121,13 @@ exports.socketio = (hookName, args, cb) => {
return cb();
};
/**
* Sorts a list of plugins by a property
* @param {Object} plugins The plugins to sort
* @param {Object} property The property to sort by
* @param {String} dir The directory of the plugin
* @return {Object[]}
*/
const sortPluginList = (plugins, property, /* ASC?*/dir) => plugins.sort((a, b) => {
if (a[property] < b[property]) {
return dir ? -1 : 1;

View file

@ -696,10 +696,20 @@ exports.expressPreSession = async (hookName, {app}) => {
}
};
// helper to get api root
/**
* Helper to get the current root path for an API version
* @param {String} version The API version
* @param {APIPathStyle} style The style of the API path
* @return {String} The root path for the API version
*/
const getApiRootForVersion = (version, style = APIPathStyle.FLAT) => `/${style}/${version}`;
// helper to generate an OpenAPI server object when serving definitions
/**
* Helper to generate an OpenAPI server object when serving definitions
* @param {String} apiRoot The root path for the API version
* @param {Request} req The express request object
* @return {url: String} The server object for the OpenAPI definition location
*/
const generateServerForApiVersion = (apiRoot, req) => ({
url: `${settings.ssl ? 'https' : 'http'}://${req.headers.host}${apiRoot}`,
});