Questions tagged [express-4]

Express is a minimalist web framework for Node.js which provides a set of features for web and mobile applications.

Express is a minimalist web framework for Node.js which provides a set of features for web and mobile applications.

Helpful links

105 questions
67
votes
2 answers

How to handle FormData from express 4

I tried sending some form data to my node server but req.body has none of my form fields the node side var express = require('express') var app = express() var path = require('path') var bodyParser =…
SuperUberDuper
  • 9,242
  • 9
  • 39
  • 72
59
votes
5 answers

Node Express 4 middleware after routes

Following the upgrade to Express 4, and the removal of app.router, I'm struggling to get middleware to execute after routes execute. e.g. the following code correctly responds with "hello", but never calls the configured middleware var express =…
goofballLogic
  • 37,883
  • 8
  • 44
  • 62
23
votes
1 answer

Express 4 + pm2 watch not working

I'm running pm2 with this: pm2 start bin/www --watch ../ Problem is that when I update app.js in the root folder, it doesn't seem to be autorestarting node. Any ideas?
ninjaneer
  • 6,951
  • 8
  • 60
  • 104
18
votes
6 answers

Forever Node.JS Express 4

How do you run the Express 4 app with Forever? (or is there a new package?) I am running my Express 3 apps with Forever installed locally with the package manager. I use the command: forever -a start app.js
Eric Sheasby
  • 235
  • 1
  • 4
  • 13
17
votes
1 answer

How to best structure an Express V4.11+ project with Socket.IO?

I've used the latest version of the express-generator (link) to generate a boilerplate Express 4.11.2 project. I'm trying to figure out the best way of setting up Socket.IO 1.3.3 with the changes that have been made a few major versions back in the…
Jamie Street
  • 1,527
  • 3
  • 14
  • 32
17
votes
7 answers

Check if redis is running -> node js

I just wanted to know, at the beginning of my NodeJS process, if Redis is started or not (so users session will be stored or not). Here is what I have for the moment : var session = require('express-session'); var RedisStore =…
Oliboy50
  • 2,661
  • 3
  • 27
  • 36
15
votes
4 answers

Express middleware cannot trap errors thrown by async/await, but why?

These two middleware functions behave differently and I cannot figure out why: Here, the error will get trapped by try/catch: router.get('/force_async_error/0', async function (req, res, next) { try{ await Promise.reject(new Error('my zoom…
user5047085
13
votes
7 answers

Elasticsearch show all results using scroll in node js

I am basically trying to show all records of an index type. Now, if you use match_all() in query elasticsearch shows 10 results by default. One can show all results using scroll. I am trying to implement scroll api, but can't get it to work. It is…
Jane
  • 283
  • 3
  • 5
  • 16
8
votes
5 answers

How do I disable jade/template engine in express 4

I'm new to express and I want to explore workings of Express. I am using latest version of express 4 (4.8.1) I don't want to use any template engine. I want to serve my HTML content manually. How do I do that? I searched a few questions here is…
user3844244
  • 77
  • 1
  • 1
  • 2
8
votes
2 answers

Node.js use csurf conditionally with express 4

I try to use csurf on just a few routes in my express app. that's the approach: var express = require('express'); var session = require('express-session'); var csrf = require('csurf'); // some more stuff var csrfExclusion =…
marschro
  • 791
  • 8
  • 23
6
votes
1 answer

How to pass the configured passport object into the routes modules in Express4?

Since from Express 4 you're not supposed to do require('./app/routes.js')(app, passport); // load our routes and pass in our app and fully configured passport module.exports = function(app, passport) { // ===================================== …
bolerovt
  • 623
  • 7
  • 18
5
votes
2 answers

ExpressJS 4 execute function after res.send()

I am new to nodeJS and asynchronous programming. I am using express as the base for my app, there is really only one route that serves a page and accepts an upload from a form. I would like to make a POST request to an external service after the the…
Jason Yost
  • 4,807
  • 7
  • 42
  • 65
5
votes
1 answer

Express 4, NodeJS, AngularJS routing

I am using Express 4 to host my AngularJS app on my backend, with Nginx as my frontend server. However html5 mode does not seem to work, as I will get a Cannot /GET error when I try to enter the page link (e.g. http://localhost/login) via the…
Wei Hao
  • 2,756
  • 9
  • 27
  • 40
4
votes
3 answers

Passing an include file into a Handlebars layout

I'm using Node.js, Express 4, and the Handlebars templating processor. Some of the page views that I'm rendering with Handlebars have several kBytes of static inline SVG code. Is there a simple clean way to put the SVG code into a separate file to…
natesrc
  • 61
  • 1
  • 3
4
votes
2 answers

Stuck on console.log(JSON.stringify(req)) in middleware

When I connect to my Express 4 node.js websocket server from my client and try to log req, the whole program just gets stuck. It still accepts new connections and executes it to the same console.log, but then gets stuck. I am trying to figure out…
Waltari
  • 1,052
  • 1
  • 30
  • 64
1
2 3 4 5 6 7