问题
I have functions like this (in Node.js/Firebase) and wonder how to add documentation i JSDoc format:
exports.getUserRes = functions.https.onRequest(async (request, response) => {...}
How do I document the GET/POST/etc parameters to the request
?
回答1:
I just found an old question with an answer that seems to suggest a good way. It is not the accepted answer there I mean, but the answer by @Steven Spunkin:
javascript - How to annotate Express middlewares with JSDoc? - Stack Overflow How to annotate Express middlewares with JSDoc?
I am copying his answer here for simplicity. Comments are welcome!
/**
*
* @module myMiddleware
* @function
* @param req {Object} The request.
* @param res {Object} The response.
* @param req.params.foo {String} The foo param.
* @param req.query.bar {String} The bar query.
* @param req.body {Object} The JSON payload.
* @param {Function} next
* @return {undefined}
*/
function foo(req, res, next){ ... }
来源:https://stackoverflow.com/questions/57771798/how-do-i-jsdoc-parameters-to-web-request