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
4
votes
1 answer

Express-session defined in one route file not available in app.js Node JS

I have issue with express-session in node js and express 4. I set a session variable inside routes/index.js and is not available in app.js.But available on another route file users.js routes/index.js var…
Mohammed Safeer
  • 20,751
  • 8
  • 75
  • 78
3
votes
2 answers

Express insert values into MySQL database

PROBLEM SOLVED. Please look below. I'm new into Express and NodeJS, ditched Laravel and PHP. What I want to do is to be able to add a record into MySQL database, but I am not able to connect the dots. I'm following this tutorial series :…
salep
  • 1,332
  • 9
  • 44
  • 93
3
votes
0 answers

TypeError: Router.use() requires middleware function but got a Object in Express 4.13.1

This is how it is configured in my express 4.13.1 application index.js var express = require('express'); var router = express.Router(); /* GET home page. */ router.get('/', function(req, res, next) { res.render('index', { title: 'Express'…
user1870400
  • 6,028
  • 13
  • 54
  • 115
3
votes
1 answer

MongoDB and Express: Type Error: Converting Circular structure to JSON

I am new to MEAN stack. I am trying to retreive a list of documents from MongoDB. I have used Visual Studio 2013 community edition to create a basic Nodejs Express application. Visual studio created app.js file on the root for configuration. I have…
learner
  • 581
  • 7
  • 27
3
votes
1 answer

File upload hangs on production code but works locally - multer, node.js

I am working on a aplication that was written in express 3, now we upgraded to express 4, and i have a problem whith file uploads. Everything works on my local computer mac OSX, but doesn't work on production server on ubuntu. i am uploading zip…
3
votes
1 answer

Express 4 + Socket.io = 404

For some hours ive been trying to get socket.io working with express 4. Ive started following this tutorial which gave me a working rest api. To get socket.io working i used the command npm install socket.io This added socket.io to my node_modules…
Sven van den Boogaart
  • 11,833
  • 21
  • 86
  • 169
3
votes
1 answer

Express 4 Dynamically delete middleware from app stack

i'm new in node and i'm trying to add and delete routes "on the fly" in Express 4. I'm adding them using app.use(path,route) and i'm able to locate them in the app._router.stack Array but i'm not able to delete a particular router. Is it possible?…
3
votes
2 answers

How can run app using Express 4 without "DEBUG=node:* ./bin/www"

I'm learning Node.js + Express 4 and command that running my app looks so: $>DEBUG=node:* ./bin/www And what is this command do ? How can I run my app like this: $>node app.js PS: I need to run under phpStrom and can't set in configuration first…
LIAL
  • 1,624
  • 4
  • 24
  • 30
3
votes
2 answers

Include a module for all routes at express.js 4

I'm using Express 4.2.0 Is it possible to include a module only once in app.js and use it in any defined route? Right now this won't work: app.js //.. var request = require('request'); var routes = require('./routes/index'); var users =…
Alvaro
  • 40,778
  • 30
  • 164
  • 336
3
votes
1 answer

Express 4: How to upload file to memory (e.g. as a UTF-8 string) rather than disk?

I have an Express 4 application which needs to process data files uploaded by users and return an output. The files are relatively small (1-2 MB), so I'd like to upload them directly to memory (e.g. as a UTF-8 string variable) rather than saving…
user456584
  • 86,427
  • 15
  • 75
  • 107
2
votes
1 answer

why bin\www is not a js file?

There are questions and answers dealing with the new www file in the folder bin for express 4. However I could not find the current question: Why eventhough www is a javascript file, it does not have the js extension?
KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
2
votes
2 answers

How to find path on express app for middleware

So my router looks like this: const app = express(); app.use('/login', router); app.listen(3000, () => { app._router.stack.forEach((middleware: any) => { console.log(middleware); }) }) when I console .log that middleware I get: Layer…
Vladimir Djukic
  • 925
  • 2
  • 9
  • 28
2
votes
2 answers

Async function throws error - yet express endpoint that calls it - does not see it

I have a helper function that hits an API and fetches a page by ID. It uses async/await and I am trying to handle errors with try catch. To test the error handling I am purposefully giving it an ID that does not exist. Here is the method: const…
2
votes
3 answers

Express middleware - add promise rejection handlers

I have the following simplified middleware function: router.put('/', function (req, res, next) { const data = req.body; const q = req.parsedFilterParam; const opts = req.parsedQueryOpts; ResponseCtrl.update(q, data, opts) …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
2
votes
1 answer

nodejs- unable to fetch data from a helper function

I am using ExpressJS 4 for my project and it follows MVC architecture. I created a helper where I can write commonly used functions which query data from DB (DRY approach) and these can be accessed from any controller. I'm able to call the helper…
version 2
  • 1,049
  • 3
  • 15
  • 36