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
1answer
33 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
6 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
70 views

Callback/Promises implementation for a boolean check

Currently I have the following callback system: ...
1
vote
0answers
11 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 ...
1
vote
1answer
94 views

Unit tests for an Express middleware function that does basic authentication

I have written an Express middleware function called authenticateRequest that looks at the Authorization header of an incoming ...
4
votes
0answers
84 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 ...
2
votes
0answers
36 views

Node my Chatter

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
292 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
75 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 ...
0
votes
0answers
58 views

NodeJS link shortener

I made an app in NodeJS, with Express and Mongoose, that takes a URL as input into the address bar, and returns an alias to that URL. It can be used as a link shortener. The app is intended to ...
1
vote
1answer
80 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
62 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
26 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
35 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
155 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
69 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
563 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
51 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
167 views

File upload with Express

A sample file upload application on Express. It use busboy as form data parser ...
1
vote
1answer
120 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
519 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
56 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
134 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
51 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
38 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
60 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
228 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
227 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
210 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
87 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
114 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
119 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
113 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
77 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
85 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
49 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
252 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 ...
6
votes
1answer
1k 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
190 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
213 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
232 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. ...
1
vote
1answer
180 views

Controller making request to an external API

I'm starting on a new node/express backend and really want to keep everything clean and well tested. My previous project got a bit out of hand (in terms of test coverage and highly coupled code). So ...
2
votes
2answers
115 views

AJAX call to make an HTTP request

I am using node.js with express. There is a button that the user can click, and doing so calls this method on the server: ...
3
votes
1answer
144 views

Self-balancing robot

I am building a 3D printed self-balancing robot, and use the attached server script to control it. I coded using node.io, express and socket.io. The system is working, but I would appreciate some ...
2
votes
1answer
137 views

Simple web application for benchmark

There is an article where the author tries to compare performance of different web stacks. The result looks pretty controversial. I try to prove that in real use case the difference between scores of ...
2
votes
1answer
100 views

Pyramidal promises

I have a situation in my Node (express) controller where I need to check whether a particular language has a parent language, if it does, I need to do a new DB (SQL) call to retrieve the parent ...
11
votes
2answers
21k views

Exporting routes in node.js Express 4

I'm using Express 4 to provide routes to HTML/Jade files, and as well to provide an API. I want to separate routes from server file, and go even further- separate API from WWW. My code now looks like ...