Core

js-cgi provides a small set of built-in globals and functions for handling HTTP requests and generating responses. No extensions are required — these are always available.

Globals

GlobalTypeDescription
requestobjectIncoming HTTP request data
responseobjectMethods to control the HTTP response

Functions

FunctionDescription
print(value, ...)Append values to the response body
include(path)Execute another .js file in the same context

Modules

ES modules (import/export) are supported for organising code into reusable files.

Default Behaviour

  • Content-Type defaults to text/html
  • Status code defaults to 200
  • The response body is everything output by print()
  • Scripts execute synchronously from top to bottom
Was this page helpful?