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
13 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 ...
3
votes
1answer
36 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
39 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 ...
0
votes
0answers
27 views

Sharing app methods to routes in Expressjs 4

I would like to know the right way to execute an action(a method) from my app into my routes. I have to do this because I have a POST route waiting to be call from other pages (like an API call) but ...
0
votes
0answers
25 views

Middleware code for preventing repetitive identical requests in Express

I have problems when some of my users starts to frenzy click the save button generating duplicate records on the database. I wanted to create a generic solution so I could reuse it on another projects ...
3
votes
2answers
136 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 ) ...
2
votes
0answers
91 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 ...
0
votes
0answers
84 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 ...
0
votes
0answers
51 views

Controller-view for each page in a mobile site

I have been creating a mobile site using Fluxxor, rendering components server side and after some work setting up the stores and components, I find that each page I have has a corresponding controller ...
2
votes
1answer
62 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
95 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 ...
0
votes
0answers
18 views

Organization options email to send email with sendgrid

I am working in this controller: ...
1
vote
0answers
34 views
3
votes
0answers
71 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
57 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
52 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
41 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
188 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 ...
5
votes
1answer
581 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 ...
0
votes
0answers
88 views

Validation in Node.js

I'm building a NodeJS application, but I'm not sure what will be the best way to structure my code. I have the following model: ...
14
votes
1answer
164 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
154 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
171 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 ...
4
votes
1answer
2k 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
129 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
97 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
96 views

Optimizing a Node.io server code for 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
124 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
64 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
12k 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 ...
1
vote
2answers
139 views

Testing individual nodes launched by naught using supertest

The purpose: an express node.js server which can be launched using naught, with an integration test using supertest. Each worker naught runs will test itself on a unique port, and only if passes it ...
4
votes
2answers
830 views

Modularize this node.js express server code for routes and session handlers?

I have express node.js server code using Passport. It receives a user to authenticate it and ...
3
votes
2answers
79 views

Node exports, architecture

My project is written in node JS + Express and has the following architecture: routes (e.g controllers) models (stateless functional modules) app Models objects only doing SQL queries like this: ...
6
votes
1answer
616 views

Express.js controller with Node.js style exports.methods

I have some Node/Express.js controllers which implement the exports.method Node module convention. This particular controller also has a few helper methods. The code works fine! However, I'm a ...
4
votes
1answer
84 views

Using EJS for a web page

For a few reasons I had to use EJS on a specific page in my Express project. This was previously like 13 lines of code with MustacheJS and a small JSON file. But now that it is hard-coded, it is a ...
2
votes
1answer
110 views

I'm torn between conditionals and abrupt return functions

Which one of these two is better? This one: ...
2
votes
1answer
7k views

Serving static assets through wildcard rule

I wrote this as a way to deliver static portion of the app. I'm wondering if there is a better way to write this, as I am new to Express. The goal is to let a single-page app to handle routing as ...
2
votes
1answer
379 views

Saving and listing Category model

I have this ExpressJS route for saving and listing Category model. ...
2
votes
2answers
7k views

Populating an unordered list from values in a JSON file

I have this view that populates an unordered list from values in a JSON file, which I am doing in Node. Is there a better way to do this, or a more 'node-like' way? Can I load the JSON file without ...
0
votes
1answer
560 views

Express, blade with connect-assets

I have this CoffeeScript code running here (with TZM-Blade) and would like to have your opinion on how to better optimize it. ...
1
vote
1answer
198 views

Render arbitrary jade in express

We've got a "catch-all" in app.js that renders a .jade file if it exists: ...
3
votes
1answer
941 views

Socket.io, Express and Delivering realtime data from backend socket

I've got server running to make serial data available on a TCP/IP port. My goal is to collect data coming from a realtime device connected to the serial port and deliver it to web clients connected to ...