Questions tagged [express]

Express is a minimal and flexible Node.js web application framework providing a robust set of features for building web applications.

Express is a minimal and flexible Node.js web application framework providing a robust set of features for building web applications.

The official website of Express is expressjs.com. The source can be found on GitHub.

Useful links:

Older versions

76920 questions
13
votes
3 answers

Using express middleware in koa

I have existing code which implements an express middleware. How can I use this middleware in a Koa application? When I try to call app.use(expressMiddleware) in order to use the middleware in my Koa app, Koa complains that a generator function is…
urish
  • 8,420
  • 7
  • 48
  • 72
13
votes
2 answers

redirect Location but not URL

How do I redirect the user to a different route without redirecting the URL in vanilla Express? For example, if I have the routes express = require('express'); app = express(); app.route('/old').get(function(req, res, next) { …
trysis
  • 7,124
  • 12
  • 47
  • 74
13
votes
3 answers

ExpressJS - res.redirect after DELETE request

I have been searching all over for how to do this - I am trying to redirect after a DELETE request is made - here is the code I am using WITHOUT THE REDIRECT: exports.remove = function(req, res) { var postId = req.params.id; Post.remove({ _id:…
ewizard
  • 2,527
  • 4
  • 45
  • 94
13
votes
3 answers

Starting Node.js Express application

I created an application with $ express -c stylus express_example I can start my server with $ npm start but $ node app.js & $ nodemon app.js don't seem to work. I don't get any error messages though, terminal just goes to the next line. …
Bryan Grace
  • 1,500
  • 2
  • 13
  • 27
13
votes
1 answer

Script path for ExpressJS in node_modules

I have an index.jade in my 'views' folder. doctype html html head title= title link(rel='stylesheet', href='/stylesheets/main.css') script(src='../node_modules/some_package/package_script.min.js') I have index.js in my routes folder…
Bryan
  • 1,258
  • 3
  • 14
  • 23
13
votes
3 answers

Configuring Express 4.0 routes with socket.io

I have created a new Express application. It generated app.js for me and I have then created the following index.js bringing in socket.io: var app = require('./app'); server=app.listen(3000); var io = require('socket.io'); var socket =…
Ben
  • 5,466
  • 11
  • 48
  • 64
13
votes
4 answers

Mongodb session store in Expressjs 4

In express 3 I use connect-mongo for session store. var mongoStore = require('connect-mongo')(express); But after I switched to express 4 it doesn't work. I got this error: Error: Most middleware (like session) is no longer bundled with Express and…
Junyu Wu
  • 339
  • 3
  • 10
13
votes
2 answers

Error: write EPIPE with node.js and imagemagick

I'm lost as to where this error is coming from, and I'm hoping you can help me. I'm new to node and am trying to resize an image with imagemagick: var express = require('express'), fs = require('fs'), gm = require('gm'), imagemagick =…
iank
  • 790
  • 2
  • 10
  • 29
13
votes
2 answers

Embedded document vs reference in mongoose design model?

Let's say I am building a discussion forum using Node.js, and mongoose. A user can have multiple forums, and a forum can have multiple comments. A user can also invite other users to join a forum too. Thus, my question is about the model design…
c0mrade
  • 1,130
  • 1
  • 13
  • 24
13
votes
2 answers

Express can't upload file, req.files is undefined

I really apologize if I'm leaving something out and am totally stupid, but I've checked and checked over again a number of times, and the file upload functionality is just not working over here. I made a super minimal app to demonstate. Just…
hulufei
  • 427
  • 1
  • 5
  • 13
13
votes
3 answers

Is it possible to include external files when using Jade’s :markdown filter?

I'm building an Express.js Node app and using Jade templates. Jade provides a :markdown filter which enables embedding Markdown code inside Jade: h1 This is Jade :markdown ## And this is Markdown h3 Back in Jade (Note: In order to use this filter…
Šime Vidas
  • 163,768
  • 59
  • 261
  • 366
13
votes
8 answers

How to cancel user upload in Formidable (Node.js)?

I have been working on this problem for two days now, and I am stuck. I am using Node.js with Express, and I am trying to implement an upload form. Basically, I want the form to do the following: Check the size of the file and cancel the upload if…
jfizz
  • 435
  • 5
  • 16
13
votes
2 answers

Best place to handle data validation with mongoose and express

Maybe there is not a definitive answer here but I would like to know where to handle data validation when dealing with express.js and mongoose. Which of the following is the best practice (I currently use a combination and it's starting to feel very…
adamK
  • 3,789
  • 4
  • 34
  • 48
13
votes
3 answers

Getting the url parameters in an ejs template

I am trying to create an ejs conditional based on a URL parameter, for example, if the test parameter exists at localhost:3000/page?test, then show a div, else dont show it. My ejs template looks something like: <% include header %>
enducat
  • 1,598
  • 3
  • 16
  • 16
13
votes
1 answer

URL Fingerprinting / Agressive Caching with NGINX + Express

What is the recommended technique for handling aggressive caching and URL fingerprinting in an NGINX (proxy) and Node / Express stack? Google recommends to "use fingerprinting to dynamically enable caching." in their best practice guidelines and…
Palgie
  • 195
  • 2
  • 9
1 2 3
99
100