nodex_plugin_helloworld/lib.rs
1#[doc = include_str!("../README.md")]
2use nodex::prelude::*;
3
4pub fn init(env: NapiEnv, mut object: JsObject) -> NapiResult<()> {
5 object.set_named_property(
6 "hello_world",
7 env.func(|this, ()| {
8 let env = this.env();
9 let res: JsValue = env.run_script(
10 r#"
11 console.log("hello, nodex!");
12 "#,
13 )?;
14 Ok(res)
15 })?,
16 )?;
17
18 Ok(())
19}