require('./helloworld');
А из командной строки запускается через node helloworld
, писать с расширениями node.exe helloworld.js
, как советуют выше, не обязательно. Командную строку запускать в винде нажатием Win+R и вводим cmd
и жмем enter. var mysql = require('mysql');
connectMySql();
function connectMySql() {
var connection = mysql.createConnection(connectionString);
connection.connect(function(err) {
if (err) {
setTimeout(function() {
connectMySql()
}, 3000);
}
});
connection.on('error', function(err) {
if (err.code === 'PROTOCOL_CONNECTION_LOST') connectMySql();
});
}
// Обработчик для API по урлу http://127.0.0.1/example/app/examples/mysql/getCities.json
module.exports = function(client, callback) {
aliasNameMy.query('select * from City', function(err, rows, fields) {
callback({ rows:rows, fields:fields });
});
}
D:\ab>npm install zmq
/
> zmq@2.8.0 install D:\ab\node_modules\zmq
> node-gyp rebuild
D:\ab\node_modules\zmq>node "C:\Program Files\nodejs\node_modules\npm\bin\node-g
yp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
Построение проектов в этом решении по одному. Чтобы включить параллельное построение, добавьте параметр "/m". binding.cc
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocale(323): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [D:\ab\node_modules\zmq\build\zmq.vcxproj]
D:\ab\node_modules\zmq\node_modules\nan\nan.h(1221): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
D:\ab\node_modules\zmq\node_modules\nan\nan.h(1247): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(367): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(564): warning C4344: behavior change: use of explicit template arguments results in call to 'v8::Local<T> NanNew<v8::String,char*>(P)' [D:\ab\node_modules\zmq\build\zmq.vcxproj]
with [ T=v8::String, P=char * ] but the regular function 'v8::Local<T> NanNew(const char *,int)' is a better match
with [ T=v8::String ] if you expect 'v8::Local<T> NanNew(const char *,int)' to be called then you need to make it an explicit specialization
with [ T=v8::String ]
..\binding.cc(590): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(591): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(592): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(593): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(594): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(595): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(596): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(597): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(598): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(599): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(614): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(615): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(616): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(617): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(618): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(619): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(620): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(621): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(622): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(623): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(957): warning C4244: '=' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(1049): warning C4244: '=' : conversion from 'int64_t' to 'int', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(1136): warning C4344: behavior change: use of explicit template arguments results in call to 'v8::Local<T> NanNew<v8::String,char*>(P)' [D:\ab\node_modules\zmq\build\zmq.vcxproj]
with [ T=v8::String, P=char * ] but the regular function 'v8::Local<T> NanNew(const char *,int)' is a better match
with [ T=v8::String ] if you expect 'v8::Local<T> NanNew(const char *,int)' to be called then you need to make it an explicit specialization
with [ T=v8::String ]
D:\ab\node_modules\zmq\node_modules\nan\nan.h(1036): warning C4244: 'argument': conversion from 'int64_t' to 'int32_t', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(540) : see reference to function template instantiation 'v8::Local<T> NanNew<v8::Integer,__int64>(P)' being compiled
with [ T=v8::Integer, P=int64_t ]
..\binding.cc(595) : see reference to function template instantiation 'v8::Handle<T> zmq::Socket::GetSockOpt<int64_t>(int)' being compiled
with [ T=v8::Value ]
D:\ab\node_modules\zmq\node_modules\nan\nan.h(1036): warning C4244: 'argument': conversion from 'uint64_t' to 'int32_t', possible loss of data [D:\ab\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(540) : see reference to function template instantiation 'v8::Local<T> NanNew<v8::Integer,unsigned __int64>(P)' being compiled
with [ T=v8::Integer, P=uint64_t ]
..\binding.cc(597) : see reference to function template instantiation 'v8::Handle<T> zmq::Socket::GetSockOpt<uint64_t>(int)' being compiled
with [ T=v8::Value ]
C:\Users\Timur\.node-gyp\0.10.32\deps\v8\include\v8.h(179): warning C4506: no definition for inline function 'v8::Persistent<T> v8::Persistent<T>::New(v8::Handle<T>)' [D:\ab\node_modules\zmq\build\zmq.vcxproj]
with [ T=v8::Object ]
Creating library D:\ab\node_modules\zmq\build\Release\zmq.lib and object D:\ab\node_modules\zmq\build\Release\zmq.exp Generating code Finished generating code zmq.vcxproj -> D:\ab\node_modules\zmq\build\Release\\zmq.node
zmq@2.8.0 node_modules\zmq
+-- bindings@1.1.1
L-- nan@1.3.0
Hash.prototype._transform = function(chunk, encoding, callback) {
this._binding.update(chunk, encoding);
callback();
};
var request = require('request'),
crypto = require('crypto');
var token, url;
for (var i = 0; i < 5; i++) {
token = crypto.randomBytes(16).toString('hex');
url = 'https://wu.wsiz.rzeszow.pl/wunet/photos/s' + token + '.jpg';
doRequest(url);
}
function doRequest(url) {
request.get(
{ uri:url, method:'GET', encoding:'binary' },
function (err, res, body) {
console.time(url);
body = new Buffer(body, 'binary');
console.timeEnd(url);
}
);
}