|
| 1 | +#include "constants.hpp" |
| 2 | + |
| 3 | +#include "session/config/contacts.hpp" |
| 4 | +#include "session/config/groups/info.hpp" |
| 5 | +#include "session/config/user_groups.hpp" |
| 6 | + |
| 7 | +namespace session::nodeapi { |
| 8 | +ConstantsWrapper::ConstantsWrapper(const Napi::CallbackInfo& info) : |
| 9 | + Napi::ObjectWrap<ConstantsWrapper>(info) {} |
| 10 | + |
| 11 | +Napi::Object ConstantsWrapper::Init(Napi::Env env, Napi::Object exports) { |
| 12 | + const char* class_name = "CONSTANTS"; |
| 13 | + |
| 14 | + // construct javascript constants object |
| 15 | + Napi::Function cls = DefineClass( |
| 16 | + env, |
| 17 | + class_name, |
| 18 | + {ObjectWrap::StaticValue( |
| 19 | + "CONTACT_MAX_NAME_LENGTH", |
| 20 | + Napi::Number::New(env, session::config::contact_info::MAX_NAME_LENGTH), |
| 21 | + napi_enumerable), |
| 22 | + ObjectWrap::StaticValue( |
| 23 | + "BASE_GROUP_MAX_NAME_LENGTH", |
| 24 | + Napi::Number::New(env, session::config::base_group_info::NAME_MAX_LENGTH), |
| 25 | + napi_enumerable), |
| 26 | + ObjectWrap::StaticValue( |
| 27 | + "GROUP_INFO_MAX_NAME_LENGTH", |
| 28 | + Napi::Number::New(env, session::config::groups::Info::NAME_MAX_LENGTH), |
| 29 | + napi_enumerable), |
| 30 | + ObjectWrap::StaticValue( |
| 31 | + "COMMUNITY_FULL_URL_MAX_LENGTH", |
| 32 | + Napi::Number::New(env, session::config::community::FULL_URL_MAX_LENGTH), |
| 33 | + napi_enumerable)}); |
| 34 | + |
| 35 | + // export object as javascript module |
| 36 | + exports.Set(class_name, cls); |
| 37 | + return exports; |
| 38 | +} |
| 39 | + |
| 40 | +} // namespace session::nodeapi |
0 commit comments