{
    "type": "trigger",
    "source": "http.js",
    "method": "server",
    "input-schema": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
            "port": {
                "type": "integer",
                "default": 3002,
                "description": "Defaults to 3002",
                "required": true
            },
            "routes": {
                "type": "array",
                "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "title": "route",
                    "properties": {
                        "pattern": {
                            "type": "string",
                            "required": true,
                            "description": "A pattern to match the route. e.g. /, /home/, /user/*, etc."
                        },
                        "name": {
                            "type": "string",
                            "title": "label",
                            "description": "A label for the route. If the pattern is matched, a property with the name as the given label and value as true will bet set in the output.routes object.",
                            "required": true
                        },
                        "methods": {
                            "type": "array",
                            "title": "methods",
                            "description": "Request methods to match the route for. If a method other than 'ALL' is specified, will listen only for the specified method on this route. Defaults to all",
                            "items": {
                                "type": "string",
                                "title": "method",
                                "format": "choice",
                                "choice": [
                                    {
                                        "label": "ALL",
                                        "value": "\"ALL\""
                                    },
                                    {
                                        "label": "GET",
                                        "value": "\"GET\""
                                    },
                                    {
                                        "label": "HEAD",
                                        "value": "\"HEAD\""
                                    },
                                    {
                                        "label": "POST",
                                        "value": "\"POST\""
                                    },
                                    {
                                        "label": "PUT",
                                        "value": "\"PUT\""
                                    },
                                    {
                                        "label": "DELETE",
                                        "value": "\"DELETE\""
                                    },
                                    {
                                        "label": "PATCH",
                                        "value": "\"PATCH\""
                                    },
                                    {
                                        "label": "OPTIONS",
                                        "value": "\"OPTIONS\""
                                    },
                                    {
                                        "label": "CONNECT",
                                        "value": "\"CONNECT\""
                                    },
                                    {
                                        "label": "TRACE",
                                        "value": "\"TRACE\""
                                    }
                                ]
                            }
                        },
                        "middlewares": {
                            "type": "array",
                            "description": "List of route specific middlewares.",
                            "items": {
                                "additionalProperties": false,
                                "type": "flow",
                                "title": "middleware",
                                "inputtitle": "options",
                                "inheritsId": "core/http/middleware/interface"
                            }
                        }
                    }
                }
            },
            "websocket": {
                "additionalProperties": false,
                "title": "websocket",
                "description": "Select Websocket handler",
                "type": "flow",
                "inheritsId": "core/http/websocket/interface",
                "inputkey": "config",
                "inputtitle": "config"
            },
            "session": {
                "additionalProperties": false,
                "title": "sessionStore",
                "description": "Select a session store to enable sessions.",
                "type": "flow",
                "inheritsId": "core/http/session/interface",
                "inputkey": "config",
                "inputtitle": "config"
            },
            "middlewares": {
                "type": "array",
                "description": "List of global middlewares that can process the request before reaching the routes.",
                "items": {
                    "additionalProperties": false,
                    "type": "flow",
                    "title": "middleware",
                    "inputtitle": "options",
                    "inheritsId": "core/http/middleware/interface"
                }
            },
            "advanced": {
                "additionalProperties": false,
                "displayOptions": {
                    "showCollapsed": true
                },
                "type": "object",
                "properties": {
                    "staticFiles": {
                        "type": "array",
                        "description": "Specify the path and prefix to serve static contents",
                        "items": {
                            "type": "object",
                            "title": "staticConfig",
                            "additionalProperties": false,
                            "properties": {
                                "location": {
                                    "type": "string",
                                    "format": "filechooser",
                                    "formatOptions": {
                                        "type": "folder"
                                    }
                                },
                                "prefix": {
                                    "type": "string",
                                    "default": "\"/\"",
                                    "description": "Prefix for static files."
                                },
                                "maxAge": {
                                    "type": "any",
                                    "description": "Set the max-age property of the Cache-Control header in milliseconds or in string format ex: 2h, 1d, 1y, 2 days"
                                }
                            }
                        }
                    },
                    "favicon": {
                        "type": "string",
                        "format": "filechooser",
                        "formatOptions": {
                            "ext": "ico"
                        },
                        "description": "Location of favicon file"
                    },
                    "gzipResponse": {
                        "type": "boolean",
                        "description": "Compress HTTP response with gZip",
                        "default": true,
                        "format": "plain"
                    },
                    "clustering": {
                        "type": "boolean",
                        "description": "Use clustering",
                        "format": "plain"
                    },
                    "numWorkers": {
                        "type": "number",
                        "description": "Number of workers to fork if clustering is enabled."
                    },
                    "ssl": {
                        "additionalProperties": false,
                        "type": "object",
                        "displayOptions": {
                            "showCollapsed": "true"
                        },
                        "properties": {
                            "port": {
                                "type": "integer",
                                "description": "Defaults to 443"
                            },
                            "certificate": {
                                "type": "string",
                                "format": "filechooser",
                                "formatOptions": {
                                    "ext": "pem"
                                }
                            },
                            "key": {
                                "type": "string",
                                "format": "filechooser",
                                "formatOptions": {
                                    "ext": "pem"
                                }
                            },
                            "passphrase": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    },
    "output-schema": {
        "type": "object",
        "properties": {
            "routes": {
                "type": "object"
            },
            "method": {
                "type": "string"
            },
            "headers": {
                "type": "object",
                "properties": {
                    "host": {
                        "type": "string"
                    },
                    "connection": {
                        "type": "string"
                    },
                    "user-agent": {
                        "type": "string"
                    },
                    "accept": {
                        "type": "string"
                    },
                    "accept-charset": {
                        "type": "string"
                    },
                    "accept-encoding": {
                        "type": "string"
                    },
                    "accept-language": {
                        "type": "string"
                    },
                    "access-control-request-method": {
                        "type": "string"
                    },
                    "access-control-request-headers": {
                        "type": "string"
                    },
                    "origin": {
                        "type": "string"
                    },
                    "cache-control": {
                        "type": "string"
                    },
                    "content-length": {
                        "type": "string"
                    },
                    "content-type": {
                        "type": "string"
                    },
                    "forwarded": {
                        "type": "string"
                    },
                    "cookie": {
                        "type": "string"
                    },
                    "referer": {
                        "type": "string"
                    },
                    "authorization": {
                        "type": "string"
                    },
                    "if-modified-since": {
                        "type": "string"
                    },
                    "if-none-match": {
                        "type": "string"
                    },
                    "if-range": {
                        "type": "string"
                    },
                    "if-unmodified-since": {
                        "type": "string"
                    },
                    "x-forwarded-for": {
                        "type": "string"
                    },
                    "x-forwarded-host": {
                        "type": "string"
                    },
                    "x-forwarded-proto": {
                        "type": "string"
                    },
                    "x-requested-with": {
                        "type": "string"
                    }
                },
                "additionalProperties": {
                    "type": "string"
                }
            },
            "params": {
                "type": "object",
                "additionalProperties": {
                    "type": "string"
                }
            },
            "query": {
                "type": "object",
                "additionalProperties": {
                    "type": "string"
                }
            },
            "body": {
                "type": "object",
                "description": "Response body.",
                "additionalProperties": {
                    "type": "any"
                }
            },
            "files": {
                "type": "object",
                "additionalProperties": {
                    "type": "object",
                    "properties": {
                        "fieldName": {
                            "type": "string"
                        },
                        "originalFilename": {
                            "type": "string"
                        },
                        "path": {
                            "type": "string"
                        },
                        "name": {
                            "type": "string"
                        },
                        "size": {
                            "type": "integer"
                        },
                        "type": {
                            "type": "string"
                        },
                        "headers": {
                            "type": "object",
                            "properties": {
                                "content-disposition": {
                                    "type": "string"
                                },
                                "content-type": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            },
            "connection": {
                "type": "object",
                "properties": {
                    "request": {
                        "type": "any",
                        "description": "request object (http.IncomingMessage), which is also a readable stream."
                    },
                    "response": {
                        "type": "any",
                        "description": "response object (http.ServerResponse), which is also a writable stream."
                    },
                    "socket": {
                        "type": "any",
                        "description": "Socket object, will be available only during a websocket communication"
                    }
                }
            },
            "socket": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "event": {
                        "type": "string"
                    },
                    "namesapce": {
                        "type": "string"
                    },
                    "data": {
                        "type": "any"
                    }
                }
            }
        }
    },
    "meta": {
        "name": "serverListener",
        "description": "Starter that accepts HTTP requests.",
        "icon": {
            "type": "fa",
            "name": "server"
        }
    }
}