Questions tagged [node.js-connect]

Connect is a middleware framework for Node.js. It processes or decorates HTTP requests and responses to provide features such as session handling, authentication, asset management or compression.

298 questions
6
votes
1 answer

Connect / node.js - creating a simple server

I'm trying to get connect / node.js to work together nicely and simply. I have the following (in Coffeescript): connect = require('connect') io = require('socket.io') server = connect.createServer( connect.favicon() , connect.logger() ,…
minikomi
  • 8,363
  • 3
  • 44
  • 51
6
votes
2 answers

TypeError: expect(...).toBeA is not a function

this is my message.test.js file. var expect = require('expect'); var {generateMessage} = require('./message'); describe('generateMessage', () => { it('should generate correct message object', () => { var from = 'Jen'; var…
Priya
  • 102
  • 1
  • 14
6
votes
1 answer

Node.js Proxy with custom Http(s) Agent and Connect.js Middleware

I've put together a proxy server in Node that needs the ability to tunnel https requests over tls and that all works. Using the the following two packages this was extremely easy to setup: proxy, https-proxy-agent. My issue is that I'm trying to…
mike
  • 8,041
  • 19
  • 53
  • 68
6
votes
1 answer

Prevent favicon.ico from making a second request - Node.js

I'm trying to prevent favicon.ico form making a second request when a socket connects. Here is my server: var io = require('socket.io'), connect = require('connect'); var app = connect() .use(connect.static('public')) .use(function(req, res,…
Nilzone-
  • 2,766
  • 6
  • 35
  • 71
6
votes
1 answer

Connecting middleware in Node.js/Express

The following is a simple example of a Node.js/Express web server: var express = require('express'); var app = express(); app.get('/*', function(req, res){ res.end('Hello, you requested ' + req.url + '.'); }); app.listen(3000); When this is…
user2692274
  • 145
  • 2
  • 5
6
votes
2 answers

the connect middleware for coffeescript?

Yes I know connect-assets. But I hope the coffeescript files can be compiled on request. Just like in stylus middleware. app.use(stylus.middleware( src: __dirname + "/assets", dest: __dirname + "/public" )) So, is there anything that works this…
Lai Yu-Hsuan
  • 27,509
  • 28
  • 97
  • 164
5
votes
2 answers

Connect and Express utils

I'm new in the world of Node.js According to this topic: What is Node.js' Connect, Express and “middleware”? I learned that Connect was part of Express I dug a little in the code, and I found two very interesting files…
Pascal Qyy
  • 4,442
  • 4
  • 31
  • 46
5
votes
1 answer

Connect session middleware - regenerate vs. reload

I am trying to get a hang of Connect's Session middleware, and I would like to know the difference between: Session.regenerate() vs Session.reload(). Specifically, I checked the docs, and no explanation was given about what session reload actually…
jeffreyveon
  • 13,400
  • 18
  • 79
  • 129
5
votes
3 answers

Strange node.js error: TypeError: Object # has no method 'on'
I'm trying to run a simple screen scraping app in node.js. The code is posted here: https://github.com/anismiles/jsdom-based-screen-scraper http://anismiles.wordpress.com/2010/11/29/node-js-and-jquery-to-scrape-websites/ The server starts up fine,…
Avishai
  • 4,512
  • 4
  • 41
  • 67
5
votes
3 answers

How can I timeout slow Connect middleware and instead return the Node response?

I have a Node server that uses Connect to insert some middleware which attempt to transform a response stream from node-http-proxy. Occasionally this transformation can be quite slow and it would be preferable in such cases to simply return a…
maxcountryman
  • 1,562
  • 1
  • 24
  • 51
5
votes
2 answers

Express.js one function to handle GET and POST

Is it better to have a separate function to handle GET and POST requests for the same API endpoint or combine them into one function that discriminates based on the existence of req.body or req.params? i.e. app.get('/api/profilepic', …
max
  • 617
  • 8
  • 20
5
votes
1 answer

Using express.json instead of express.bodyparser

I'm building a simple REST API and I only want to accept JSON input. I am opting to use app.use(express.json({strict: true})); instead of app.use(express.bodyParser());. I am passing strict: true thinking that that would add a layer of security…
Xerri
  • 4,916
  • 6
  • 45
  • 54
5
votes
1 answer

Access control origin in connect (node.js)

I am running static pages via connect var connect = require('connect'); connect.createServer( connect.static(__dirname)).listen(8080); I have to add a response header to the above code to bypass the access control …
usercode
  • 309
  • 4
  • 20
5
votes
3 answers

Inexplicable node.js http throwing connect ECONNREFUSED (IPv6?)

I am running node.js as follows: > http = require('http') > http.get('http://myhost.local:8080', function (res) { console.log("RES" + res) } ).on('error', function (e) { console.log("Error:", e) }) > uri =…
Brian M. Hunt
  • 81,008
  • 74
  • 230
  • 343
5
votes
2 answers

How to clean all sessions in Node.js (heroku + redis)?

I'm using node.js (Expressjs) hosted on heroku. Sessions are stored in redis (Redistogo plugin for heroku): RedisStore = require('connect-redis')(express) app.use express.session secret: process.env.CLIENT_SECRET cookie: { maxAge:…
Oleg Dats
  • 3,933
  • 9
  • 38
  • 61