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.
0
votes
0answers
14 views
Node.js API Server for querying a Neo4j database
I've written a server in Node.js that listens to http requests via Express.js and forwards requests to a Neo4j server. It's my first time working with Neo4j and Express.js. The code runs as intended ...
1
vote
0answers
17 views
Dynamically loading and naming controllers in nodejs and express
I'm trying to write a module to dynamically load all the files from my "controllers" folder, and then add them to the main express instance as routers.
The files inside the controllers export an ...
1
vote
1answer
58 views
RESTful backend API for user account
I have made a RESTful API built with Node.js, Express, Basic-auth and Mongoose. it will respond JSON.
This is the folder structure:
...
0
votes
1answer
32 views
1
vote
0answers
43 views
Get a random movie based on user-provided criterion (release date, genre, etc.)
What could I do to better organize the Angular and Express code? On the other hand, is there anything that reflects a common beginner's mistake or violates a best practice? I've yet to touch up the ...
1
vote
0answers
113 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
58 views
1
vote
1answer
65 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
45 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
24 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
24 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
190 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:
...
2
votes
1answer
44 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
15 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
96 views
Callback/Promises implementation for a boolean check
Currently I have the following callback system:
...
1
vote
0answers
19 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
98 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
66 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
1k 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
69 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
90 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
108 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
34 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
44 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 ...
4
votes
1answer
362 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
92 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
1k 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
62 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
330 views
File upload with Express
A sample file upload application on Express. It use busboy as form data parser
...
1
vote
1answer
213 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
940 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
58 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
158 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
70 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
67 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
274 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 ) ...
4
votes
0answers
286 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
276 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
101 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
130 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
133 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
132 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
84 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
96 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
51 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
272 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 ...