Express is a minimal and flexible Node.js web application framework, providing a robust set of features (regex-based routing, sessions, multiple view / templating engines) for building single and multi-page, and hybrid web applications.

learn more… | top users | synonyms (2)

1
vote
0answers
65 views

“RESTful” node.js server using express

I have attempted to construct a simple RESTful node server that allows for user authentication using passport and jwt: ...
1
vote
0answers
28 views

Site Registration Code causing multiple accounts to be registered [on hold]

I have an app that uses the MEAN stack, recently I have seen a little strange behaviour. Now this doesn't happen every time a user registers, so far it has happened 3 times. When a user registers the ...
1
vote
0answers
47 views

Basic Express + NodeJS REST API

I've created a REST API Endpoint for my website's Dashboard. ...
1
vote
1answer
61 views

Handling post-registration action

This code is Express NodeJS code that handles post registration .post action where the user must select a custom username. The username is validated, and if valid, ...
0
votes
0answers
26 views

Javascript / Promises

I'm working on converting a simple Python script into nodejs 4.4.5 with es6 features like Promises. The original Python script did the following: Contact a 3rd party SOAP service Attempt to ...
1
vote
0answers
17 views

Express middleware to handle errors and send them to Raygun

I signed up for Raygun on Heroku and wrote a middleware in Express to handle the error, however, I am afraid this might block a request from coming through or executing all the way. This article is ...
0
votes
0answers
19 views

Promisify NodeJS and Mongose callback even further

I've recently started to experience writing Node.js code, and JavaScript in general. Right now I am planning to promisify (with Q) some of the node.js callback code I had, and I come to this. The ...
5
votes
2answers
181 views

Express middleware to validate URL and tags

I am building an API where the client can send a url and some comma-delimited tags: ...
1
vote
1answer
43 views

Support multi functionality in server.js

i've node app that having the main function server.js(entry point) Following is the server.js file code ...
0
votes
0answers
7 views

Expressjs display specific error messages on signup

I'm using Node + Express + Mongo, my user Schema has three required fields: username email password I already took care of how the password is handled, but when it comes to username and email, ...
1
vote
1answer
79 views

Callback/Promises implementation for a boolean check

Currently I have the following callback system: ...
1
vote
0answers
16 views

MongoDB Per-Module Reusable DB Object With Reconnection Handled

This implementation was derived from the following requirements. I would like to learn that whether the implementation is clean enough, without memory leak and performance hit. Requirements Always ...
4
votes
0answers
90 views

Restructure of Express CORS middleware for unit test

How should one break this component down to better perform unit test on its behaviors? Issues: Authentication middleware component makes external request. Must recognize preflight and final flight....
2
votes
0answers
52 views

Chat application built with Node

In an effort to teach myself Node.JS and truly delve into its communication capabilities, I elected to recreate a previous chatting project. It took a bit of forethought to acclimate code to the ...
1
vote
1answer
587 views

Passing Node.js SQL connection to multiple routes

Here are the app.js, users.js and user.js routes of a node application I am building. As you can see I am connecting to the SQL DB in each route, and this is not ideal. I have tried passing the ...
0
votes
0answers
65 views

Routing through controller's file name

Before I started learning Node.js I was happy doing my projects with PHP codeigniter. When I learned Node.js, I tried to implement the routing mechanism codeigniter use by looking up controllers file ...
2
votes
0answers
79 views

Managing modules in phone book app

This is a test app built with NodeJS, Express and MongoDB. This code is the main and complete JavaScript file. I would like suggestions on dividing it into different modules and making the main app.js ...
1
vote
1answer
86 views

Very basic isomorphic JavaScript application

I'm trying to update my skillset by learning how to write isomorphic JavaScript applications. For my stack, I've chosen React and Express - no database yet. The problem many people seem to face when ...
6
votes
1answer
63 views

Baking homemade pies has made me so many new connections

Sorry, if you were looking for fresh baked pies, I only have a web client to help you sell them. I've recently picked up server-side JavaScript and have added it to my toolbox, and while I've had a ...
1
vote
0answers
31 views

Properly updating multiple MongoDB documents with Angular

In the app I'm creating, when a user upvotes a post, the post should be upvoted, as well as the user that wrote the post. But this updates two MongoDB documents. This presents a number of issues. I'll ...
3
votes
0answers
41 views

RESTful API for serving videos to a client

I'm building an app that serves videos to a front end client. My stack is Express/Angular/SQLite. The db doesn't hold users, only root. I'm concerned that my controllers are too hardcoded, but I'm ...
3
votes
1answer
225 views

Unit Testing Express Middleware That Verifies Auth Tokens

I am writing an Express middleware component that'll run on Node 4, which has limited ES2015 support. The fundamental purpose of this component is to verify JSON web tokens, using the jsonwebtoken ...
3
votes
1answer
78 views

API to verify whether a Redis entry exists

I come from a PHP object oriented framework background (Laravel, Symfony, Silex...). With that, validation comes in pre-built classes mechanism in a framework that validates for you parameters that ...
1
vote
2answers
741 views

Parsing a CSV file in node.js and express.js

I want to import a CSV file and do some operation on it. The following is the code I'm using and it is working fine: ...
0
votes
0answers
54 views

Initialize Express app with CoffeeScript

I do not care to create an extra layer if that leave the code more beautiful. But I do not want to be doing estupides. I'm using Node.js + Express + CoffeeScript, and I would like to know if what I'm ...
0
votes
0answers
228 views

File upload with Express

A sample file upload application on Express. It use busboy as form data parser ...
1
vote
1answer
146 views

Routes for a user controller in a Node.js application

I have a very simple Node application that routes requests to /users to the following file: users.js ...
4
votes
2answers
686 views

Promises with NodeJS and BlueBird

I'm using bluebird for promises in my Node/Express application and wrote an API call in which the user passes in a JSON Web Token that contains their user ...
8
votes
1answer
57 views

Retrieving StackExchange sites and tags

I have setup agenda tasks to periodically retrieve and possibly insert new SE sites and tags in my MongoDB database. Some things that bother me in particular: Lots of code duplication No string ...
1
vote
0answers
144 views

Optimizing redis cache

I am new to Express so I'd like to clear my code. This is Express with Redis support. I am getting someId and then I am searching it on Redis or using scraper which ...
1
vote
0answers
56 views

Pulling data quickly from mongodb with node.js

I am currently struggling with a request I am making to my server that is taking more than 4 seconds! I cut out a lot of the cruft to hopefully make it easier to read. Excuse my horrible variable ...
3
votes
1answer
39 views

Updating an incoming PUT query

I have the following spaghetti update method and I would like to improve its coding style. This takes an incoming PUT query for a survey object and updates it accordingly. ...
0
votes
1answer
63 views

Separate logic in files node

I have a Node project and am trying to make my code better, so I've created a new folder with a file like following which encapsulates the read and write file. This is working and my question is if ...
3
votes
2answers
247 views

Generate URLs from a complex JSON object using recursion

My task is here as follows : Input : A complex/nested JSON object with nested arrays as well objects Output : A JSON object that contains a set of URLs with their titles: ( key,value ) ...
3
votes
0answers
252 views

Exiting a Promise early

I'm using a Promise chain to write some data to a file, execute a command on it, inspect its results, and send the results, using Express.js. The thing about my function is that I need to be able to ...
1
vote
0answers
229 views

Save file from request to database

I am saving (image) files to PostgreSQL database in my Node.js and Express server application. The code is used to upload user images to server (at the moment it is not restricted to image files in ...
2
votes
1answer
91 views

Parameterized route

Is this approach considered good practice, or should I create separate router.delete functions for all my routes? Please, explain why. ...
2
votes
2answers
121 views

SQL Server to MongoDB Template

Looking for feedback on a set of templates I've just created. I'm planning on converting them to Yeoman but want to make sure they're ready for prime time before doing so. They are currently in ...
3
votes
0answers
120 views

Beginner's To-do app with Node.js

I get the feeling the code for this to-do app is not secure. I am just a beginner, and I don't know much about coding style so do you think it is conventional/elegant? Please don't hesitate to ...
1
vote
0answers
38 views
3
votes
0answers
117 views

Mongoose and Hapi/Express promise handling in controllers

I'm switching my code to promises - mostly as delivered by Mongoose. I use Hapi though I think something similar would apply to Express. In my models/services I perform queries such as: ...
1
vote
2answers
81 views

Handling with the 'error' parameter inside a callback function in node.js

I have multiple controllers and every controller has this error handler: if (error) { res.render('error', { error: error }); } Sometimes I have more ...
0
votes
1answer
89 views

Using app.use only in routes that start with /admin

I have several routes, and I need Facebook authentication only in the routes that start with /admin: ...
6
votes
1answer
50 views

Tag Fit: Team based mapping of wearable data

Our company is planning on doing a fitness competition. So as the hackathon project I threw together this team based tracking service. It measure a walk from Seattle to New York Player can log in via ...
4
votes
1answer
260 views

Node module for DRY CRUD endpoints

As a learning project I recently started writing a node module to generate / handle the creation of CRUD endpoints in a DRY way. The problem I was initially wanting to solve was that in my generator-...
6
votes
1answer
2k views

NodeJS and Express with Promises

I'm relatively new to NodeJS and Express, and I've recently run into the pyramid of Doom while doing stuff that requires multiple steps. I've found that promises are very promising indeed. But I ...
15
votes
1answer
199 views

Making an efficient and healthy db call for a real-time browser game

I'm doing a calculation for a real-time browser game, where users can invest some of their balances to the site. I need to update their invest's based on ...
2
votes
1answer
215 views

Is my Node/Express-based authentication implementation with session properly done?

I know that Passport.js exists, however, I wanted to code my own implementation using express-session module. I'm using: Express Mongoose express-session So I basically have 2 routes for handling ...
2
votes
1answer
240 views

ExpressJS easily serve static files

I have a NodeJS package, staticize, which takes an object of HTTP routes -> file locations, then serves them dynamically on each request. Could I get some feedback on the latest rewrite of the main ...
3
votes
1answer
4k views

Mongoose promise & error handling

I search for rails-like way of writing NodeJS code and it's more then hard to find the right way. The code quickly become bloated and unreadable. I would like my code to be as clean as possible. ...