RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 00002 #include "rtbkit/core/agent_configuration/agent_config.h" 00003 #include "soa/js/js_wrapped.h" 00004 #include "jml/utils/smart_ptr_utils.h" 00005 00006 using namespace std; 00007 using namespace v8; 00008 using namespace node; 00009 00010 namespace Datacratic { 00011 namespace JS { 00012 00013 00014 //set up the module 00015 00016 extern const char * const standaloneModule; 00017 const char * const standaloneModule = "config_validator"; 00018 00019 //set up the standalone function 00020 static Handle<v8::Value> 00021 validateConfig(const Arguments & args) 00022 { 00023 try { 00024 Json::Value config = getArg(args, 0, "config"); 00025 RTBKIT::AgentConfig::createFromJson(config); //will throw if unhappy 00026 return JS::toJS(true); 00027 } HANDLE_JS_EXCEPTIONS; 00028 } 00029 00030 00031 extern "C" void 00032 init(Handle<v8::Object> target) 00033 { 00034 Datacratic::JS::registry.init(target, standaloneModule); 00035 00036 static Persistent<FunctionTemplate> atn 00037 = v8::Persistent<FunctionTemplate>::New 00038 (v8::FunctionTemplate::New(validateConfig)); 00039 00040 target->Set(String::NewSymbol("validateConfig"), atn->GetFunction()); 00041 } 00042 00043 00044 00045 } // namespace JS 00046 } // namespace Datacratic