Linux vps-61133.fhnet.fr 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64
Apache/2.4.25 (Debian)
Server IP : 93.113.207.21 & Your IP : 216.73.216.35
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
share /
doc /
nodejs /
api /
Delete
Unzip
Name
Size
Permission
Date
Action
assets
[ DIR ]
drwxr-xr-x
2024-03-12 22:00
addons.html
97.31
KB
-rw-r--r--
2023-02-16 16:32
addons.json.gz
10.85
KB
-rw-r--r--
2023-02-16 16:32
addons.md
39.44
KB
-rw-r--r--
2023-02-16 16:32
all.html
5.07
MB
-rw-r--r--
2023-02-16 16:32
all.json.gz
731.61
KB
-rw-r--r--
2023-02-16 16:32
assert.html
119.06
KB
-rw-r--r--
2023-02-16 16:32
assert.json.gz
11.95
KB
-rw-r--r--
2023-02-16 16:32
assert.md
47.93
KB
-rw-r--r--
2023-02-16 16:32
async_hooks.html
94.76
KB
-rw-r--r--
2023-02-16 16:32
async_hooks.json.gz
13.99
KB
-rw-r--r--
2023-02-16 16:32
async_hooks.md
38.62
KB
-rw-r--r--
2023-02-16 16:32
buffer.html
289.59
KB
-rw-r--r--
2023-02-16 16:32
buffer.json.gz
25.79
KB
-rw-r--r--
2023-02-16 16:32
buffer.md
109.83
KB
-rw-r--r--
2023-02-16 16:32
child_process.html
157.19
KB
-rw-r--r--
2023-02-16 16:32
child_process.json.gz
20.66
KB
-rw-r--r--
2023-02-16 16:32
child_process.md
69.69
KB
-rw-r--r--
2023-02-16 16:32
cli.html
101.2
KB
-rw-r--r--
2023-02-16 16:32
cli.json.gz
18.64
KB
-rw-r--r--
2023-02-16 16:32
cli.md
48.31
KB
-rw-r--r--
2023-02-16 16:32
cluster.html
66.15
KB
-rw-r--r--
2023-02-16 16:32
cluster.json.gz
9.35
KB
-rw-r--r--
2023-02-16 16:32
cluster.md
24.83
KB
-rw-r--r--
2023-02-16 16:32
console.html
50.79
KB
-rw-r--r--
2023-02-16 16:32
console.json.gz
6.09
KB
-rw-r--r--
2023-02-16 16:32
console.md
16.55
KB
-rw-r--r--
2023-02-16 16:32
corepack.html
16.53
KB
-rw-r--r--
2023-02-16 16:32
corepack.json.gz
2.5
KB
-rw-r--r--
2023-02-16 16:32
corepack.md
5.02
KB
-rw-r--r--
2023-02-16 16:32
crypto.html
297.42
KB
-rw-r--r--
2023-02-16 16:32
crypto.json.gz
32.03
KB
-rw-r--r--
2023-02-16 16:32
crypto.md
124.37
KB
-rw-r--r--
2023-02-16 16:32
debugger.html
21.84
KB
-rw-r--r--
2023-02-16 16:32
debugger.json.gz
2.87
KB
-rw-r--r--
2023-02-16 16:32
debugger.md
6.43
KB
-rw-r--r--
2023-02-16 16:32
deprecations.html
142.87
KB
-rw-r--r--
2023-02-16 16:32
deprecations.json.gz
19.41
KB
-rw-r--r--
2023-02-16 16:32
deprecations.md
81.32
KB
-rw-r--r--
2023-02-16 16:32
dgram.html
67.31
KB
-rw-r--r--
2023-02-16 16:32
dgram.json.gz
9.74
KB
-rw-r--r--
2023-02-16 16:32
dgram.md
27.81
KB
-rw-r--r--
2023-02-16 16:32
diagnostics_channel.html
21.94
KB
-rw-r--r--
2023-02-16 16:32
diagnostics_channel.json.gz
2.33
KB
-rw-r--r--
2023-02-16 16:32
diagnostics_channel.md
5.5
KB
-rw-r--r--
2023-02-16 16:32
dns.html
109.94
KB
-rw-r--r--
2023-02-16 16:32
dns.json.gz
15.18
KB
-rw-r--r--
2023-02-16 16:32
dns.md
44.29
KB
-rw-r--r--
2023-02-16 16:32
documentation.html
18.64
KB
-rw-r--r--
2023-02-16 16:32
documentation.json.gz
1.95
KB
-rw-r--r--
2023-02-16 16:32
documentation.md
4.05
KB
-rw-r--r--
2023-02-16 16:32
domain.html
41.6
KB
-rw-r--r--
2023-02-16 16:32
domain.json.gz
6.21
KB
-rw-r--r--
2023-02-16 16:32
domain.md
15.2
KB
-rw-r--r--
2023-02-16 16:32
embedding.html
24.89
KB
-rw-r--r--
2023-02-16 16:32
embedding.json.gz
3.56
KB
-rw-r--r--
2023-02-16 16:32
embedding.md
8.67
KB
-rw-r--r--
2023-02-16 16:32
errors.html
189.76
KB
-rw-r--r--
2023-02-16 16:32
errors.json.gz
36.83
KB
-rw-r--r--
2023-02-16 16:32
errors.md
82.9
KB
-rw-r--r--
2023-02-16 16:32
esm.html
101.35
KB
-rw-r--r--
2023-02-16 16:32
esm.json.gz
16.45
KB
-rw-r--r--
2023-02-16 16:32
esm.md
50.17
KB
-rw-r--r--
2023-02-16 16:32
events.html
129.79
KB
-rw-r--r--
2023-02-16 16:32
events.json.gz
14.04
KB
-rw-r--r--
2023-02-16 16:32
events.md
43.71
KB
-rw-r--r--
2023-02-16 16:32
fs.html
500.94
KB
-rw-r--r--
2023-02-16 16:32
fs.json.gz
58.58
KB
-rw-r--r--
2023-02-16 16:32
fs.md
208.76
KB
-rw-r--r--
2023-02-16 16:32
globals.html
29.77
KB
-rw-r--r--
2023-02-16 16:32
globals.json.gz
3.82
KB
-rw-r--r--
2023-02-16 16:32
globals.md
8.21
KB
-rw-r--r--
2023-02-16 16:32
http.html
213.36
KB
-rw-r--r--
2023-02-16 16:32
http.json.gz
31.02
KB
-rw-r--r--
2023-02-16 16:32
http.md
91.28
KB
-rw-r--r--
2023-02-16 16:32
http2.html
274.92
KB
-rw-r--r--
2023-02-16 16:32
http2.json.gz
37.5
KB
-rw-r--r--
2023-02-16 16:32
http2.md
123.62
KB
-rw-r--r--
2023-02-16 16:32
https.html
44.76
KB
-rw-r--r--
2023-02-16 16:32
https.json.gz
5.04
KB
-rw-r--r--
2023-02-16 16:32
https.md
14.58
KB
-rw-r--r--
2023-02-16 16:32
index.html
12.48
KB
-rw-r--r--
2023-02-16 16:32
index.json
54
B
-rw-r--r--
2023-02-16 16:32
index.md
1.75
KB
-rw-r--r--
2023-02-16 16:32
inspector.html
25.8
KB
-rw-r--r--
2023-02-16 16:32
inspector.json.gz
3.26
KB
-rw-r--r--
2023-02-16 16:32
inspector.md
6.66
KB
-rw-r--r--
2023-02-16 16:32
intl.html
25.32
KB
-rw-r--r--
2023-02-16 16:32
intl.json.gz
3.83
KB
-rw-r--r--
2023-02-16 16:32
intl.md
10.46
KB
-rw-r--r--
2023-02-16 16:32
module.html
24.12
KB
-rw-r--r--
2023-02-16 16:32
module.json.gz
2.7
KB
-rw-r--r--
2023-02-16 16:32
module.md
5.2
KB
-rw-r--r--
2023-02-16 16:32
modules.html
67.42
KB
-rw-r--r--
2023-02-16 16:32
modules.json.gz
11.96
KB
-rw-r--r--
2023-02-16 16:32
modules.md
30.83
KB
-rw-r--r--
2023-02-16 16:32
n-api.html
338.33
KB
-rw-r--r--
2023-02-16 16:32
n-api.json.gz
49.01
KB
-rw-r--r--
2023-02-16 16:32
n-api.md
207.87
KB
-rw-r--r--
2023-02-16 16:32
net.html
111.86
KB
-rw-r--r--
2023-02-16 16:32
net.json.gz
15.48
KB
-rw-r--r--
2023-02-16 16:32
net.md
44.19
KB
-rw-r--r--
2023-02-16 16:32
os.html
60.77
KB
-rw-r--r--
2023-02-16 16:32
os.json.gz
8.44
KB
-rw-r--r--
2023-02-16 16:32
os.md
33.98
KB
-rw-r--r--
2023-02-16 16:32
packages.html
84.18
KB
-rw-r--r--
2023-02-16 16:32
packages.json.gz
13.85
KB
-rw-r--r--
2023-02-16 16:32
packages.md
41.34
KB
-rw-r--r--
2023-02-16 16:32
path.html
43.88
KB
-rw-r--r--
2023-02-16 16:32
path.json.gz
4.78
KB
-rw-r--r--
2023-02-16 16:32
path.md
14.46
KB
-rw-r--r--
2023-02-16 16:32
perf_hooks.html
71.94
KB
-rw-r--r--
2023-02-16 16:32
perf_hooks.json.gz
7.69
KB
-rw-r--r--
2023-02-16 16:32
perf_hooks.md
23.17
KB
-rw-r--r--
2023-02-16 16:32
policy.html
36.2
KB
-rw-r--r--
2023-02-16 16:32
policy.json.gz
5.16
KB
-rw-r--r--
2023-02-16 16:32
policy.md
13.9
KB
-rw-r--r--
2023-02-16 16:32
process.html
192.91
KB
-rw-r--r--
2023-02-16 16:32
process.json.gz
29.14
KB
-rw-r--r--
2023-02-16 16:32
process.md
86.44
KB
-rw-r--r--
2023-02-16 16:32
punycode.html
20.11
KB
-rw-r--r--
2023-02-16 16:32
punycode.json.gz
2
KB
-rw-r--r--
2023-02-16 16:32
punycode.md
4.17
KB
-rw-r--r--
2023-02-16 16:32
querystring.html
22.25
KB
-rw-r--r--
2023-02-16 16:32
querystring.json.gz
2.62
KB
-rw-r--r--
2023-02-16 16:32
querystring.md
5.48
KB
-rw-r--r--
2023-02-16 16:32
readline.html
70.02
KB
-rw-r--r--
2023-02-16 16:32
readline.json.gz
9.82
KB
-rw-r--r--
2023-02-16 16:32
readline.md
28.04
KB
-rw-r--r--
2023-02-16 16:32
repl.html
58.41
KB
-rw-r--r--
2023-02-16 16:32
repl.json.gz
9.98
KB
-rw-r--r--
2023-02-16 16:32
repl.md
23.61
KB
-rw-r--r--
2023-02-16 16:32
report.html
71.62
KB
-rw-r--r--
2023-02-16 16:32
report.json.gz
6.11
KB
-rw-r--r--
2023-02-16 16:32
report.md
17.92
KB
-rw-r--r--
2023-02-16 16:32
stream.html
226.65
KB
-rw-r--r--
2023-02-16 16:32
stream.json.gz
36.05
KB
-rw-r--r--
2023-02-16 16:32
stream.md
100.94
KB
-rw-r--r--
2023-02-16 16:32
string_decoder.html
17.74
KB
-rw-r--r--
2023-02-16 16:32
string_decoder.json.gz
1.54
KB
-rw-r--r--
2023-02-16 16:32
string_decoder.md
2.94
KB
-rw-r--r--
2023-02-16 16:32
synopsis.html
14.16
KB
-rw-r--r--
2023-02-16 16:32
synopsis.json
2.97
KB
-rw-r--r--
2023-02-16 16:32
synopsis.md
2.13
KB
-rw-r--r--
2023-02-16 16:32
timers.html
33.22
KB
-rw-r--r--
2023-02-16 16:32
timers.json.gz
3.79
KB
-rw-r--r--
2023-02-16 16:32
timers.md
10.55
KB
-rw-r--r--
2023-02-16 16:32
tls.html
152.42
KB
-rw-r--r--
2023-02-16 16:32
tls.json.gz
29.84
KB
-rw-r--r--
2023-02-16 16:32
tls.md
81.06
KB
-rw-r--r--
2023-02-16 16:32
tracing.html
22.65
KB
-rw-r--r--
2023-02-16 16:32
tracing.json.gz
2.76
KB
-rw-r--r--
2023-02-16 16:32
tracing.md
6.59
KB
-rw-r--r--
2023-02-16 16:32
tty.html
29.38
KB
-rw-r--r--
2023-02-16 16:32
tty.json.gz
3.67
KB
-rw-r--r--
2023-02-16 16:32
tty.md
8.78
KB
-rw-r--r--
2023-02-16 16:32
url.html
122.59
KB
-rw-r--r--
2023-02-16 16:32
url.json.gz
14.63
KB
-rw-r--r--
2023-02-16 16:32
url.md
49.32
KB
-rw-r--r--
2023-02-16 16:32
util.html
199.74
KB
-rw-r--r--
2023-02-16 16:32
util.json.gz
20.67
KB
-rw-r--r--
2023-02-16 16:32
util.md
71.47
KB
-rw-r--r--
2023-02-16 16:32
v8.html
51.82
KB
-rw-r--r--
2023-02-16 16:32
v8.json.gz
6.4
KB
-rw-r--r--
2023-02-16 16:32
v8.md
16.55
KB
-rw-r--r--
2023-02-16 16:32
vm.html
123.73
KB
-rw-r--r--
2023-02-16 16:32
vm.json.gz
15.86
KB
-rw-r--r--
2023-02-16 16:32
vm.md
55.37
KB
-rw-r--r--
2023-02-16 16:32
wasi.html
21.38
KB
-rw-r--r--
2023-02-16 16:32
wasi.json.gz
2.81
KB
-rw-r--r--
2023-02-16 16:32
wasi.md
6.27
KB
-rw-r--r--
2023-02-16 16:32
worker_threads.html
90.53
KB
-rw-r--r--
2023-02-16 16:32
worker_threads.json.gz
13.2
KB
-rw-r--r--
2023-02-16 16:32
worker_threads.md
39
KB
-rw-r--r--
2023-02-16 16:32
zlib.html
95.31
KB
-rw-r--r--
2023-02-16 16:32
zlib.json.gz
10.35
KB
-rw-r--r--
2023-02-16 16:32
zlib.md
35.03
KB
-rw-r--r--
2023-02-16 16:32
Save
Rename
# C++ embedder API <!--introduced_in=v14.0.0--> Node.js provides a number of C++ APIs that can be used to execute JavaScript in a Node.js environment from other C++ software. The documentation for these APIs can be found in [src/node.h][] in the Node.js source tree. In addition to the APIs exposed by Node.js, some required concepts are provided by the V8 embedder API. Because using Node.js as an embedded library is different from writing code that is executed by Node.js, breaking changes do not follow typical Node.js [deprecation policy][] and may occur on each semver-major release without prior warning. ## Example embedding application The following sections will provide an overview over how to use these APIs to create an application from scratch that will perform the equivalent of `node -e <code>`, i.e. that will take a piece of JavaScript and run it in a Node.js-specific environment. The full code can be found [in the Node.js source tree][embedtest.cc]. ### Setting up per-process state Node.js requires some per-process state management in order to run: * Arguments parsing for Node.js [CLI options][], * V8 per-process requirements, such as a `v8::Platform` instance. The following example shows how these can be set up. Some class names are from the `node` and `v8` C++ namespaces, respectively. ```cpp int main(int argc, char** argv) { argv = uv_setup_args(argc, argv); std::vector<std::string> args(argv, argv + argc); std::vector<std::string> exec_args; std::vector<std::string> errors; // Parse Node.js CLI options, and print any errors that have occurred while // trying to parse them. int exit_code = node::InitializeNodeWithArgs(&args, &exec_args, &errors); for (const std::string& error : errors) fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str()); if (exit_code != 0) { return exit_code; } // Create a v8::Platform instance. `MultiIsolatePlatform::Create()` is a way // to create a v8::Platform instance that Node.js can use when creating // Worker threads. When no `MultiIsolatePlatform` instance is present, // Worker threads are disabled. std::unique_ptr<MultiIsolatePlatform> platform = MultiIsolatePlatform::Create(4); V8::InitializePlatform(platform.get()); V8::Initialize(); // See below for the contents of this function. int ret = RunNodeInstance(platform.get(), args, exec_args); V8::Dispose(); V8::ShutdownPlatform(); return ret; } ``` ### Per-instance state Node.js has a concept of a “Node.js instance”, that is commonly being referred to as `node::Environment`. Each `node::Environment` is associated with: * Exactly one `v8::Isolate`, i.e. one JS Engine instance, * Exactly one `uv_loop_t`, i.e. one event loop, and * A number of `v8::Context`s, but exactly one main `v8::Context`. * One `node::IsolateData` instance that contains information that could be shared by multiple `node::Environment`s that use the same `v8::Isolate`. Currently, no testing if performed for this scenario. In order to set up a `v8::Isolate`, an `v8::ArrayBuffer::Allocator` needs to be provided. One possible choice is the default Node.js allocator, which can be created through `node::ArrayBufferAllocator::Create()`. Using the Node.js allocator allows minor performance optimizations when addons use the Node.js C++ `Buffer` API, and is required in order to track `ArrayBuffer` memory in [`process.memoryUsage()`][]. Additionally, each `v8::Isolate` that is used for a Node.js instance needs to be registered and unregistered with the `MultiIsolatePlatform` instance, if one is being used, in order for the platform to know which event loop to use for tasks scheduled by the `v8::Isolate`. The `node::NewIsolate()` helper function creates a `v8::Isolate`, sets it up with some Node.js-specific hooks (e.g. the Node.js error handler), and registers it with the platform automatically. ```cpp int RunNodeInstance(MultiIsolatePlatform* platform, const std::vector<std::string>& args, const std::vector<std::string>& exec_args) { int exit_code = 0; // Set up a libuv event loop. uv_loop_t loop; int ret = uv_loop_init(&loop); if (ret != 0) { fprintf(stderr, "%s: Failed to initialize loop: %s\n", args[0].c_str(), uv_err_name(ret)); return 1; } std::shared_ptr<ArrayBufferAllocator> allocator = ArrayBufferAllocator::Create(); Isolate* isolate = NewIsolate(allocator, &loop, platform); if (isolate == nullptr) { fprintf(stderr, "%s: Failed to initialize V8 Isolate\n", args[0].c_str()); return 1; } { Locker locker(isolate); Isolate::Scope isolate_scope(isolate); // Create a node::IsolateData instance that will later be released using // node::FreeIsolateData(). std::unique_ptr<IsolateData, decltype(&node::FreeIsolateData)> isolate_data( node::CreateIsolateData(isolate, &loop, platform, allocator.get()), node::FreeIsolateData); // Set up a new v8::Context. HandleScope handle_scope(isolate); Local<Context> context = node::NewContext(isolate); if (context.IsEmpty()) { fprintf(stderr, "%s: Failed to initialize V8 Context\n", args[0].c_str()); return 1; } // The v8::Context needs to be entered when node::CreateEnvironment() and // node::LoadEnvironment() are being called. Context::Scope context_scope(context); // Create a node::Environment instance that will later be released using // node::FreeEnvironment(). std::unique_ptr<Environment, decltype(&node::FreeEnvironment)> env( node::CreateEnvironment(isolate_data.get(), context, args, exec_args), node::FreeEnvironment); // Set up the Node.js instance for execution, and run code inside of it. // There is also a variant that takes a callback and provides it with // the `require` and `process` objects, so that it can manually compile // and run scripts as needed. // The `require` function inside this script does *not* access the file // system, and can only load built-in Node.js modules. // `module.createRequire()` is being used to create one that is able to // load files from the disk, and uses the standard CommonJS file loader // instead of the internal-only `require` function. MaybeLocal<Value> loadenv_ret = node::LoadEnvironment( env.get(), "const publicRequire =" " require('module').createRequire(process.cwd() + '/');" "globalThis.require = publicRequire;" "require('vm').runInThisContext(process.argv[1]);"); if (loadenv_ret.IsEmpty()) // There has been a JS exception. return 1; { // SealHandleScope protects against handle leaks from callbacks. SealHandleScope seal(isolate); bool more; do { uv_run(&loop, UV_RUN_DEFAULT); // V8 tasks on background threads may end up scheduling new tasks in the // foreground, which in turn can keep the event loop going. For example, // WebAssembly.compile() may do so. platform->DrainTasks(isolate); // If there are new tasks, continue. more = uv_loop_alive(&loop); if (more) continue; // node::EmitProcessBeforeExit() is used to emit the 'beforeExit' event // on the `process` object. if (node::EmitProcessBeforeExit(env.get()).IsNothing()) break; // 'beforeExit' can also schedule new work that keeps the event loop // running. more = uv_loop_alive(&loop); } while (more == true); } // node::EmitProcessExit() returns the current exit code. exit_code = node::EmitProcessExit(env.get()).FromMaybe(1); // node::Stop() can be used to explicitly stop the event loop and keep // further JavaScript from running. It can be called from any thread, // and will act like worker.terminate() if called from another thread. node::Stop(env.get()); } // Unregister the Isolate with the platform and add a listener that is called // when the Platform is done cleaning up any state it had associated with // the Isolate. bool platform_finished = false; platform->AddIsolateFinishedCallback(isolate, [](void* data) { *static_cast<bool*>(data) = true; }, &platform_finished); platform->UnregisterIsolate(isolate); isolate->Dispose(); // Wait until the platform has cleaned up all relevant resources. while (!platform_finished) uv_run(&loop, UV_RUN_ONCE); int err = uv_loop_close(&loop); assert(err == 0); return exit_code; } ``` [CLI options]: cli.md [`process.memoryUsage()`]: process.md#process_process_memoryusage [deprecation policy]: deprecations.md [embedtest.cc]: https://github.com/nodejs/node/blob/HEAD/test/embedding/embedtest.cc [src/node.h]: https://github.com/nodejs/node/blob/HEAD/src/node.h