nodejs

package
v0.0.0-...-f7ae98d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package nodejs implements nodejs runtime

nodejs code need to export a handler function:

exports.handler = function(context, event) {
	// ...
	context.callback(reply); // MUST return reply via callback
}

context is current call context, it contains the following:

    callback:
		Callback function, *must* be used to return response.
		Response can be one of:
			- string
			- Buffer
			- array of [status, body]
			- context.Response object

		Response:
			A response. Has the following fields
				- body
				- headers
				- content_type
				- status_code

		Logging functions:
			- logger.error: function(message)
			- logger.warn: function(message)
			- logger.info: function(message)
			- logger.debug: function(message)
			- logger.errorWith: function(message, with_data)
			- logger.warnWith: function(message, with_data)
			- logger.infoWith: function(message, with_data)
			- logger.debugWith: function(message, with_data)

event is the current event, it contains the following:

  • body: Buffer (*not* string, use event.body.toString())
  • content_type: string
  • trigger:
  • class: string
  • kind: string
  • fields: object of field->value
  • headers: object of header->value
  • id: string
  • method: string
  • path: string
  • size: int
  • timestamp: Date
  • url: string

If you use your own base image, make sure to set NODE_PATH. In nuclio/handler-nodejs-alpine image NODE_PATH is set to /usr/local/lib/node_modules

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRuntime

func NewRuntime(parentLogger logger.Logger, configuration *runtime.Configuration) (runtime.Runtime, error)

NewRuntime returns a new NodeJS runtime

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址