Commit graph

9 commits

Author SHA1 Message Date
Oisin Canty
c160ea11e4 Node.js: renamed "require_shim" to "loader". 2021-05-24 09:01:42 +00:00
Oisin Canty
a0c083af20 Node.js: a shim for overriding "http" and "websocket" modules.
Also added stubs for Server.address()
This was done to prevent crashes in some popular frameworks like express

Supports both CommonJS and the new ES Modules system syntax e.g:

app.js:
const http = require('http')

app.mjs:
import http from "http"

Usage on Node 14.16.x and higher:
{
    "type": "external",
    "processes": {"spare": 0},
    "working_directory": '/project',
    "executable": "/usr/bin/env",
    "arguments": [
        "node",
        "--loader",
        "unit-http/require_shim.mjs"
        "--require",
        "unit-http/require_shim",
        "app.js"
    ]
}

Usage on Node 14.15.x and lower:
{
    "type": "external",
    "processes": {"spare": 0},
    "working_directory": '/project',
    "executable": "/usr/bin/env",
    "arguments": [
        "node",
        "--require",
        "unit-http/require_shim",
        "app.js"
    ]
}
2021-05-12 09:26:55 +00:00
Andrey Zelenkov
9bbf54e23e Tests: Node.js websockets. 2019-08-22 15:33:41 +03:00
Valentin Bartenev
7fd9444728 Node.js: returning "this" from writeHead() to allow chaining.
In Node.js version 11.10.0 and later, the writeHead() function returns "this".
2019-08-06 16:24:11 +03:00
Andrey Zelenkov
0c12afbf6a Tests: using low-case header names in Node.js tests. 2019-04-18 19:27:12 +03:00
Andrey Zelenkov
d625691ff4 Tests: test_node_application_write_before_writeHead reworked.
Added res.end() call in application and response status check.
Also, renamed to test_node_application_write_before_write_head.
2018-12-25 16:35:35 +03:00
Andrey Zelenkov
aafa4bbaf9 Tests: more Node.js tests. 2018-12-11 18:30:58 +03:00
Andrey Zelenkov
2ef5011236 Tests: fixed test_node_application_write_callback.
Fixed the write() callback order test.
Also introduced a separate test to verify the callback call itself.
2018-12-04 19:05:10 +03:00
Sergey Kandaurov
0fdc7c3a55 Tests: Node.js application tests. 2018-10-25 15:43:48 +03:00