Skip to content

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

@cezar77

Description

@cezar77

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions