All Questions
132 questions
3
votes
1
answer
117
views
Consuming sharded database using node.js
I think the only big improvement that can be made is to check which shard to query based on the userIds of the followed users. One easy way is to check the last ...
2
votes
1
answer
91
views
Session-based authentication using Express.js
I'm currently learning Express.js and I wrote this authentication code. I'm unsure if what i have is correct, how to improve it and if it's secure. For user and session data storage I'm using ...
7
votes
2
answers
1k
views
Take postcodes and get the Lat long information from them
I had an interview task which was the final stage, however, the feedback I got back for my solution was that it lacked effort and structure. I would be grateful to ...
3
votes
0
answers
420
views
Mern stack app on error handling, async await, try-catch and avoiding DRY in controller functions
I'm looking for a review of my backend code on how to keep it more DRY. I see a lot of repetition in validation part of email and password, also I need some advice on if I have used the try-catch and ...
6
votes
1
answer
644
views
Any better pagination logic?
router/article.js
...
7
votes
1
answer
353
views
How do I refactor this fetch request?
I have this code that fetches data from a 3rd party api and sends it to my backend to be processed. The 3rd party api needs to target the user's localhost address so it has to come from the front end. ...
2
votes
2
answers
2k
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
1
answer
163
views
Catching Errors in Factory Method with express.js
My express.js application uses a lot of promises for interacting with a variety of services. Instead of including try/catch with each one, I've setup a fail safe factory method for all my express ...
2
votes
0
answers
3k
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
1
answer
1k
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 ...
1
vote
1
answer
156
views
Basic REST API for manipularing a MongoDB collection, using Node, Express, and Mongoose
I'm practicing back-end programming and NodeJS. As an exercise, I'm attempting to build a REST API for a MongoDB collection. I'm also learning to use the Express and Mongoose middle-wares, so that's ...
3
votes
1
answer
506
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 ...
0
votes
1
answer
256
views
NodeJS - Auto Module Loader
I took some time to try and solve a problem. I am building a basic Node + Express API. In the app I have created a models folder and will be adding new models as I continue development.
I attempted ...
3
votes
0
answers
59
views
Right structure, three-layered architecture webdevelopment
My question is have i gotten the three-layered architecture right with error handling etc. I have a webpage containing different resources. The code works but I am not sure if have structured it ...
3
votes
2
answers
182
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 ...