How do I jsdoc parameters to web request?

落爺英雄遲暮 提交于 2020-01-06 05:45:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!