func icon indicating copy to clipboard operation
func copied to clipboard

Confusing JSDoc and function signature in http/index.js in the node template

Open cezar77 opened this issue 3 months ago • 0 comments

The file http/index.js in the node template has confusing JSDoc and function signature.

This is the relevant part of the JSDoc:

/**
 * @param {Context} context a context object.
 * @param {object} context.body the request body if any
 * @param {object} context.query the query string deserialized as an object, if any
 * @param {object} context.log logging object with methods for 'info', 'warn', 'error', etc.
 * @param {object} context.headers the HTTP request headers
 * @param {string} context.method the HTTP request method
 * @param {string} context.httpVersion the HTTP protocol version
 * See: https://github.com/knative/func/blob/main/docs/function-developers/nodejs.md#the-context-object
 */

The function signature is this:

const handle = async (context, body) => {

Based on the JSDoc one would assume that the function has only one parameter (of type Context). But the function signature specifies two parameters. If body is property of the object context why would you specify it as a separate parameter?

Also the JSDoc is missing @returns tag:

  * @returns {object} HTTP response object with body, query, or error status

cezar77 avatar Sep 09 '25 09:09 cezar77