The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [express.js]

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.

Filter by
Sorted by
Tagged with
2
votes
1answer
35 views

Reading a text file, manipulating it and saving it to a mongo database

We have an upcoming project at work which is going to require working with express.js. I have no prior experience with node.js, so I thought I'd try and do something aside from some courses. Are there ...
1
vote
0answers
20 views

Writing error handling and users routing for my JSON RESTful API

I'm currently making an app for my side project and I was looking to get some insight on the main js file, what can I improve, the error handling, what am I doing wrong, etc. I'm mostly confused about ...
2
votes
1answer
41 views

Blocking requests within Express

Is this the correct way to block requests in Express? app.js ...
0
votes
0answers
27 views

Server Design with GraphQL.Js

To learn graphql I'm creating a server for queries to a local postgres cluster. The pg cluster is populated with sample data from postgresqltutorial.com and I wanted to use GraphQL.Js instead of ...
1
vote
1answer
34 views

Middlewares with Route definition or Routes with Middleware definition

I am currently working on an Node based Express application. I have found Express's middlewares approach quite pleasing however, we all run in scenarios where a certain route or routes don't need a ...
4
votes
2answers
73 views

An Express route, which renders a page, and makes use of socket.io

This is the code for a basic endpoint in my express app routes folder. This firstly renders a page, and then on a continuous loop, renders information about some random "Breaking Bad" character. The ...
2
votes
2answers
65 views

Reading image files asynchronously and displaying them on the page

I am trying to display images from a folder in my project using the "fs" module with NodeJS. I need to read all images in a directory and run them in a loop for them to be displayed. I was able to do ...
2
votes
0answers
17 views

Error handling in express without middlewares and using class structure

This is a simple implementation of Django's sample project "Poll" using and express. The controller code: ...
1
vote
0answers
15 views

Node Express App - Create structure around incoming payload [closed]

I am working on a simple NodeJS express app that accepts an incoming payload from a few different systems. There is a single route that ships the data off to another method and waits for the promise. ...
1
vote
0answers
125 views

Initializing a Node JS Express Application with OOP [closed]

Overview I am attempting to learn Node JS with Express by creating a project. I have seen many examples of setting up an express.js application with functional based programming, like so: ...
4
votes
1answer
27 views

Better code for error handling in NodeJs and Express

I have this code for a post request, when the user wants to change his password. Because of all the cases and the following page renders the code came out really ugly. Is there a better way to ...
2
votes
0answers
29 views

The modularization of the Express entry point

I've been working on a project to make myself more comfortable with NodeJS, especially Express and TypeScript. Searching and reviewing a lot of approaches of the people, providing bootstraps for it, I ...
2
votes
2answers
69 views

Retrieve a city list for a country and state

The code below is working properly but how do I make this code faster and more efficient. How do I perfect this code? Let's assume I have 1000 country, state and city records in a mongodb collection. ...
4
votes
0answers
27 views

Get current user middleware from JWT using express

I'm using Sequelize and Google oAuth for authentication, I want to create a middleware that Verifies the sent token passed in the headers matches the one the user was initially signed to. Finds the ...
3
votes
0answers
36 views

Node/Express authenticate Google email address

Trying to set up express server that will authenticate a user's Google email before proceeding. The code below works, but is there any way to make it more elegant? The whole ...
4
votes
1answer
411 views

Node.js http retry do while mechanism

I have implemented a simple do/while loop to handle a http request to a third-party. I don’t know when the data I receive will have elements in its array so I retry up to 10 times until the array ...
0
votes
0answers
247 views

Gmail API list messages NodeJS

I use the following code to list and trash messages from the Gmail API in NodeJS. I call the getAllMessages method to get all email bodies because the Gmail API ...
2
votes
2answers
34 views

Express.js handler to update user fields

I have an express handler which i thought was pretty simple, but CodeClimate flagged this method as having a Cognitive complexity of 6 (5 is the max by default without flagging something) Curious how ...
3
votes
1answer
60 views

Express.js functions to start session, authenticate user, perform ping, search for user, reset password, and import product XML

I wrote the below code which contains the following functions: establish session with the user, determine if the user is authenticated, perform ping request, search about the user from the database, ...
1
vote
1answer
64 views

Authentication using express-session

I'm making an online shopping store or e-commerce and I use an express session for many things. Example: Shopping Cart, Authentication user* I store the data chart list in the database based on the ...
2
votes
2answers
55 views

Minimizing duplicate routes index.js

I am trying to build a REST API with express router, which contains of nested sub routes. I have mounted these sub routes in my index.js file. I have defined it as ...
1
vote
2answers
406 views

ACL express middleware implementation

I come to see you to help me improve an express middleware that allows you to control access resources by checking the rights of the user. The following code is supposed to be as generic as possible ...
3
votes
3answers
147 views

Upload .JSON product list to MongoDB and upload image to AWS S3

I'm using Node/Express/Mongoose to accept a JSON file containing a list of product details. These products are looped through, the images are uploaded to AWS S3, and the product is either accepted or ...
2
votes
1answer
38 views

Request for improvements on a simple React app

I'm looking for a review of a recent project I finished for school. It is an app that functions like Twitter. It includes an Express server and Routes. Instead of using databases, it uses JSON files. ...
2
votes
1answer
53 views

Allowing users to view and manage articles

This is a controller from an Express app that lets users view and manage articles. There are at least a couple of issues I'd like to address... The program displays a list of articles in a sidebar ...
0
votes
1answer
42 views

MongoDB database connector on NodeJS

What my code does I am building an Express API server with mongoDB as my database. I have a list of players which must be added to 2 mongoDB collections (teamList and countryList). The data schema ...
4
votes
2answers
323 views

Consume etherscan.io API, store in DB, serve from web app

I didn't make it to the next stage in this interview process, because another applicant did better than me, which wasn't surprising given that this was my first foray into Node.js. I'd like some tips ...
1
vote
0answers
40 views

Rendering server side errors on the client in Node/Express

I've set up a simple Node/Express service that creates new bookmarks to a database. In my Bookmark schema, one of the fields, URL, has validations. When you try to create a new bookmark without the ...
3
votes
1answer
76 views

Express.js routes management for large web application

I'm currently working on a large web application with numerous routes. Currently, our routes are in one large list in a single JSON file. We recently ran into a problem due to the precedence of ...
2
votes
2answers
63 views

POST to endpoint and GET data back

I'm working on a little project and although it all works, I think I might be doing it in an incorrect way. The front end consists of a simple form that gathers input data (make and color) and once ...
3
votes
1answer
55 views

JS ES6 Node/Express Mongo code that processes a CSV file

I'm a java dev that has started working with Node/Express and mongo. I'm looking to see how I can improve my code, especially in terms of the async jazz as that is still a bit new to me (and I feel ...
4
votes
1answer
144 views

Restful CRUD API with Node.js and Express

I build a RESTful CRUD API with Node.js and Express. This application allows, for example, to create a table on the client side with the ability to add, update and remove data by ID. I generate an ...
1
vote
0answers
42 views

Separating out router and model logic

I have an Express router that is doing all the heavy lifting. Should the router be handling all this stuff or is a layer required between these two like maybe a service that makes these calls? ...
3
votes
1answer
83 views

Mini Tor implementation (“CLI only anonymous network”)

The goal of my project is to build a mini "anonymous" network (like Tor is) (command-line only) using Node.js and frameworks (socket.io / axios / express). A ...
0
votes
1answer
27 views

Improving handling of Express endpoint

I have an API gateway in a larger set of microservices, and I'm handling one of my routes. The endpoint ends up making an RPC call to another service, and then I just log the response and send it back ...
2
votes
3answers
240 views

Fetching user details, posts, and comments using promises in ExpressJS

I'm creating an API service in NodeJS using Express (version 4) Framework. Created an MVC architecture for the same (no views, only model, and controller as this is an API). Also, there are routes. ...
1
vote
1answer
220 views

ExpressJS with Promises and Ethereum

I am making a small token project with front-end website to ease the use. The architecture is Ethereum private network with ERC20 contract, PostgreSQL to associate address with alias of wallet, NodeJS ...
1
vote
1answer
72 views

Avoid existSync function on Node.js - Express API controller

I have many json files that I want to serve through an API. The json files look something like this: ...
0
votes
1answer
288 views

JavaScript / Express error handling w/ promises

So I'm wondering how to properly handle errors in JavaScript when utilizing promises. I'm currently throwing errors for everything so that I can break out of the promise - if I can't find something, ...
2
votes
1answer
1k views

Node.js/Express middleware to relay requests to various APIs

I am creating a nodejs middleware server that will handle api transactions from a frontend and relay them to various api's (internal and external). The primary goal is to hide api keys from the ...
0
votes
1answer
828 views

Exception handling and releasing of OracleDB connection

Before I start implementing several REST API service endpoints, I'd like to make sure that I'm not doing it totally wrong. ...
2
votes
1answer
152 views

HMAC Middleware

I have been programming a middleware for my small application that verifies if an authentication header is present and verifies the HMAC present in it. I would like to know what I could optimize in ...
1
vote
0answers
3k views

Using async/await with Node.JS MySQL

Is this the right way to use async/await with the JavaScript MySQL client? I had to use the promise-mysql package because it wraps the function calls with Bluebird promises, so that I'm able to use ...
1
vote
0answers
31 views

Checks if a job exists, and appends a bid to that job

I am very new to Node.js and Express and have been doing a "learn as I go" scenario by building a Craigslist-style app where people can bid on jobs. I am looking to see if this is the best approach ...
1
vote
2answers
516 views

Router for quering MySQL results in NodeJS

What should I consider in order to refactor the following code ? It seems very close to proudly become a Pyramid of Doom: ...
1
vote
0answers
46 views

ExpressTemplate, from Cloud9 to Heroku

basic setup Body-Parser, Cors, Express & Nodemon I don't think I'm using the favicon correctly. I was calling it locally, but I don't have local resources on code pen. It seems to always be using ...
3
votes
1answer
151 views

Server side requiring parameters

I wrote this middleware for express enabling developers to require certain parameters the easy way. How good is this approach? Can you call this quality code? Is everything OK, or is something missing?...
1
vote
2answers
1k views

Send html with nonce for each script and style tag on each request

This working code inserts a nonce attribute and value for each style and script tag inside an HTML file, for each GET request. It is using Express. nonce1 and ...
1
vote
1answer
164 views

User authentication using Passport

I'm currently building a Node/Express app using Passport for user authentication and Sequelize for database queries. It's a 'To-do list' app which currently has 3 models: User, List and Task. My back-...
1
vote
0answers
576 views

Twitch chat bot using node, express, mongodb

I need help on truly understanding my self project. Javascript is a language I struggle the most with so I decided to create a project using Javascript. In my education I'm mostly familiar with C++, ...