无法使用Travis-ci构build和部署node.js项目 – 找不到Rakefile

我正在尝试在travis-ci中构build一个node.js项目。 这是我的.travis.yml文件: language: node_js node_js: – 0.8 after_script: # Install the Heroku package (or the Heroku toolbelt) – npm install heroku # Add your Heroku git repo: – git remote add heroku git@heroku.com:*****.git # Add your Heroku API key: – export HEROKU_API_KEY=KEYHERE # Turn off warnings about SSH keys: – echo "Host heroku.com" >> ~/.ssh/config […]

Node / Express – bodyParser为PUT请求为空

我得到一个ExpressPer错误与ExpressParter是无法parsing任何PUT请求…我的configuration是这样设置的: app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.query()); app.use(app.router); 然而,每次我向端点发出PUT请求时,req.body都会返回“undefined”。 我已经尝试通过Chromes REST控制台发出请求,并且也通过jQuery ajax请求这样做: $.ajax({ url: 'https://localhost:4430/api/locations/5095595b3d3b7b10e9f16cc1', type: 'PUT', data: {name: "Test name"}, dataType: 'json' }); 有任何想法吗?

nodejs,socket.io:如何从套接字函数获取请求和响应?

即时通讯创build聊天应用程序,使用nodejs(0.8.15),expression(> 3.0)框架和mongodb注册用户。 var express = require('express') , http = require('http') , path = require('path') , io = require('socket.io'); var app = express() , server = http.createServer(app) , io = io.listen(server); app.configure(function() { app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieParser('secret')); app.use(express.session({cookie: {maxAge: 60000*100}})); app.use(app.router); app.use(express.static(path.join(__dirname, 'public'))); }); […]

从CIDR范围检索最大/最小IP

我想从CIDR块获得最大和最小的IP – 我目前的代码工作正常,除了一些IP在最小数目上返回负数。 以下是我现有的代码和输出。 function long2ip (proper_address) { // Converts an (IPv4) Internet network address into a string in Internet standard dotted format // // version: 1109.2015 // discuss at: http://phpjs.org/functions/long2ip // + original by: Waldo Malqui Silva // * example 1: long2ip( 3221234342 ); // * returns 1: '192.0.34.166' var output = false; if […]

使用node-orm(在osx 10.6.8下)将node.js应用程序连接到PostgreSQL的问题

我想在osx(10.6.8)下运行一个小的nodejs应用程序,并连接到我的localhost Postgres数据库。 我正在使用node-orm(https://github.com/dresende/node-orm2)以及Postgres绑定(https://github.com/brianc/node-postgres)。 出于某种原因,当我使用orm.connect并将它作为string连接url时,它将失败: Error: getaddrinfo ENOENT at errnoException (dns.js:31:11) at Object.onanswer [as oncomplete] (dns.js:123:16) 如果我用127.0.0.1更改本地主机。 它也死于超时exception。 使用vanilla postgress绑定连接到数据库,使用相同的连接string是成功的,我甚至设法得到一些testing查询运行,得到的结果等。 我尝试使用vanilla postgress API手动设置数据库客户端,并使用orm.use将其传递给orm。 这pipe理成功连接到数据库,但每次我尝试执行一个查询,没有任何反应。 它不会产生一个错误,但sinply卡住了QueryQueue,并没有调用成功的callback。 我检查了数据库日志,似乎也没有检测到查询。 我该怎么办? 我有一点困惑

我如何在Jade中创build一个可重用的标记

我正在努力完成的。 我想要做的事情其实很简单,Jade模板引擎应该能够帮助我很多,但是我遇到了一些麻烦。 我build立了一个网站,使用了很多像这个jsFiddle中的半透明元素: http : //jsfiddle.net/Chevex/UfKnM/ 为了使容器背景为半透明,但保持文本不透明,这涉及3个元素: 容器DIV的position: relative 一个position: absolute ,背景颜色,高度/宽度设置为100%,并将其不透明度设置为所需级别的子DIV。 另一个孩子DIV的内容没有特殊定位。 这很简单,我在CodeTunnel.com上相当有效地使用它。 我想如何简化它。 我在node.js中重写了CodeTunnel.com,而Jade模板引擎似乎可以大大简化这段重复使用的标记。 翡翠mixins看起来很有希望,所以这就是我所做的: 我定义了一个mixin,所以我可以在需要的时候使用它。 mixin container .container(id=attributes.id) // attributes is an implicit argument that contains any attributes passed in. .translucentFrame .contentFrame block // block is an implicit argument that contains all content from the block passed into the mixin. 使用混合,传入一个内容块: +container#myContainer […]

低优先级Express.js app.get('/ route');

有没有办法注册express.js app.get()调用较低的优先级? 例如, app.get('*', function(req, res) {}); app.get('/page', function(req, res) {}); 有没有办法在第一次调用时指定一个较低的优先级,以便它在path查找的底部,从而允许先调用后面的path,就好像第一行代码在第二行之后执行一样的代码?

如何在node.js中asynchronous使用setTimeout

我是新来的node.js,我试图使用setTimeout来模拟长连接,并希望它asynchronous的行为。 var http = require('http'); http.createServer(function (request, response) { console.log('New request @ ' + request.url); (function (response) { setTimeout(function () { console.log('Time is up'); response.writeHead(200, {"Content-Type": "text/plain"}); response.end('Hello World\n'); }, 3000); })(response); }).listen(8124); console.log('Server running at http://127.0.0.1:8124/'); 但是,上面的代码像一个同步的单线程应用程序一样,每3秒只能处理一个请求。 我认为node.js中的所有内容都应该是asynchronous的。 那么,这里有什么问题?

为什么使用Redis代替正常variables存储?

使用Redis进行会话存储的优点是将所有数据简单地存储在应用程序中的variables中?

403 / Express 3 / Node的禁用错误自定义页面

我如何创build一个将处理来自Express的403错误的路线? 我有默认路由来捕捉404/500,但它似乎停止之前,有没有去路由器。 只需将堆转储到屏幕即可。