Tag: node.js connect

Redis快速应用程序的结构

我不确定在我正在构build的Express应用程序中,哪里是定义redis客户端的最佳位置。 我正在使用框架作为框架。 看起来像redis的连接应该在boot.coffee或app.coffee ,但是我不能轻易地在application_controller.coffee获得对它的引用,这就是我需要的地方。 如果我将client = redis.createClient放在application_controller.coffee ,是否意味着每个请求都会创build一个新的客户端?

如何在stunnel后面的node.js / connect应用程序中设置req.connection.proxySecure

我们有一个node.js / express应用程序,位于stunnel后面,用于ssl终止。 我无法弄清楚如何强制安全的会话cookie。 看着会话中间件源: // only send secure session cookies when there is a secure connection. // proxySecure is a custom attribute to allow for a reverse proxy // to handle SSL connections and to communicate to connect over HTTP that // the incoming connection is secure. var secured = cookie.secure && (req.connection.encrypted || […]

为什么我的连接中间件没有通过?

我正在使用"connect": "^3.3.5" ,我有app.use '/', messageMiddleware.incoming, userMiddleware.process 我的messageMiddleware有: exports.incoming = (req, res, next) -> fromNumber = req.body.From toNumber = req.body.To global.db.Message.create message: req.body.Body.trim() from: fromNumber to: toNumber .then (dbMessage) -> req.MessageId = dbMessage.id next() .catch (err) -> next err 我的userMiddleware有 'use strict' exports.process = (req, res, next) -> console.log 'processing' res.end() 但是,它不loggingprocessing或end 。 我做错了什么?

Http.request在node.js中

这是我在节点js中的代码: var http = require('http'); var options = { host : '127.0.0.1', port: 8124, path: '/', method: 'GET' }; http.request(options, function(res){ console.log("Hello!"); }).end(); process.on('uncaughtException', function(err){ console.log(err); }); 当我编译它,编译器显示我以下错误: 在这里input图像说明 编辑:随着快递的作品,但如果我想使它不工作,我怎么办?

res.write不会返回预期的值

这是代码: var http = require('http') var options = { hostname: 'localhost', method: 'POST', port: 8000, path: '/' } var s = 3; http.request(options, (res)=>{ }).end(s+'') http.createServer((req, res)=>{ res.writeHead(200, {'Content-type': 'text/plain'}) var a = ""; req.on('data', (data)=>{ a+= data }) req.on('end', ()=>{ res.write(a) res.end() }) }).listen(8000) 为什么当预期返回值为3时,服务器可能会向客户端返回无效信息?

在Express中,为什么.config()中的envvariables是可选的?

我正在阅读Express API: http : //expressjs.com/api.html#app.configure 我看到第一个参数是可选的。 这是什么意思? 如果缺less第一个参数,是否不会调用callback? 如果是这样,在app.config()中包装它的意义是什么? 换句话说,是这样的: app.configure(function(){ app.set('title', 'My Application'); }) …与此相同: app.set('title', 'My Application'); ? 如果是这样,我为什么要做第一个而不是第二个呢?

连接框架和socket.io有什么不同?

我是新来的node.js,所以我有一些关于连接框架和socket.io的问题: 有什么不同? 我很困惑。 我应该使用连接fw与socket.io或只是使用socket.io?

我可以在socket.io的命名空间中使用房间吗?

我想知道是否可以在socket.io中使用多个房间。 据我所知,你可以使用命名空间或房间。 我的目的是通过只有一个node.js-socket.io-server的websockets,让我的应用程序有多个独特的实例与这个独特的应用程序交谈。 有了这个应用程序,就有要求彼此交谈。 在一个房间或全球范围内。 没有必要与另一个命名空间交谈。 提前致谢, 丹尼尔

我怎样才能让连接资产重新编译我的咖啡文件,当他们改变?

相关,但希望有一个较低的摩擦答案: 如何使用Node和Express与coffeescript和requirejs? 我已经build立了连接资产,以便我可以将.js和.coffee文件并排放置在我的/ assets / js文件夹中。 唯一的问题:我必须重新获取包含任何编译的咖啡文件的页面,只要这些文件改变。 次要问题,我猜,但我已经做了很多CURL文件本身作为故障排除的一部分 – 对咖啡js文件本身的CURL不会导致它被重新编译。 连接资产是否具有任何“监视”function? 在文档中找不到一个。 我是否只coffee -bcw *.coffee在该目录中运行一个coffee -bcw *.coffee ? 编辑:最后我只是用咕噜重新编译上的变化。 这比连接资产要好得多。 我会在这里留下这个问题,因为它有一些意见。

接收捕获的exception:错误:运行吞噬时,侦听EACCES

我在我的项目中使用gulp。 我想通过一个吞咽任务启动node服务器。 这是我的gulpfile.js : var server = require('gulp-develop-server'); gulp.task('server:start', ['scripts'], function() { server.listen({ path: '/home/ubuntu/node-v0.10.33/TestApp/app.js', }); }); // restart server if app.js changed gulp.task('server:restart', function() { gulp.watch(['/home/ubuntu/node-v0.10.33/TestApp/app.js'], server.restart); }); gulp.task('default', ['server:start']); 我的节点端口号是80 。 我在Ubuntu服务器上运行这个代码: ubuntu@ip-xxx-xx-xx-xx:~/gulpReact$ gulp [12:32:35] Using gulpfile ~/gulpReact/gulpfile.js [12:32:35] Starting 'server:start'… [12:32:35] Finished 'server:start' after 3.27 ms [12:32:35] Starting 'default'… [12:32:35] Finished 'default' […]