1#include <node_api.h> 2#include "../../js-native-api/common.h" 3#include <string.h> 4 5static napi_value Method(napi_env env, napi_callback_info info) { 6 napi_value world; 7 const char* str = "world"; 8 size_t str_len = strlen(str); 9 NODE_API_CALL(env, napi_create_string_utf8(env, str, str_len, &world)); 10 return world; 11} 12 13NAPI_MODULE_INIT() { 14 napi_property_descriptor desc = DECLARE_NODE_API_PROPERTY("hello", Method); 15 NODE_API_CALL(env, napi_define_properties(env, exports, 1, &desc)); 16 return exports; 17} 18