All Questions
Tagged with express or express.js
168 questions
4
votes
1
answer
64
views
2
votes
0
answers
107
views
To-do app with TypeScript backend (violations of TS best practices or unidiomatic code)
The working code in full is here.
It's a To-Do App with a TypeScript backend, written as practice for an upcoming 4-hour interview for a TypeScript backend role. My colleague and I would like to know, ...
3
votes
1
answer
134
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 ...
0
votes
1
answer
62
views
MVC Pattern - Need to include services file or not?
I am refactoring an old project, made in Nodejs with Express, applying the MVC pattern, today it is a fairly simple project: handling of the FCM and Remote Config tools from Firebase.
Would it be ...
2
votes
1
answer
113
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 ...
1
vote
1
answer
158
views
Rock, paper, scissors game in expressjs typescript
This is a simple 2 player game made in NodeJS and the ExpressJS framework with typescript. I've built using OOP approach to as far of an extent as I know of it. I'm really curious as to how further ...
5
votes
1
answer
95
views
Basic node authentication system
I built a basic authentication system for a node application and I have some security concerns. The username and password the user enters when they log in are stored as plaintext using express-...
2
votes
1
answer
176
views
Express.js and jsonplaceholder application
I have put together a small node application with Express.js and jsonplaceholder.
On the homepage, it displays posts by all users. You can also filter posts by one user (author).
In ...
4
votes
0
answers
91
views
Simple Markdown Blog
this is my first real website I created after learning about web development.
It's amazing to me that anyone would spare their free time to code review strangers' code. So thank you in advance. I'd ...
1
vote
1
answer
100
views
1
vote
1
answer
850
views
Common CRUD function in node js using Express
I have created common function for CRUD operations.
I am using Sequelize JS, I have created all models in Sequelize
I have written stored procedures in mysql for CRUD operations for each module/tables ...
2
votes
2
answers
110
views
Blog API implementation in node.js
This code is from my blog project. This project is almost done. This is working well.
I can create new posts and update and display all saved posts.
...
1
vote
1
answer
130
views
Making my login function more readable and maintainable
I recently wrote a login function in my express application that does the following:
Verifies the user's email and password are correct
Generates a JWT Access Token with a short expiry date, and then ...
3
votes
0
answers
71
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 ...
2
votes
0
answers
58
views
Tiny REST API for making CRUD operations on list of posts
This is not a question related to a bug.I've just created a very tiny node.js/express API for education purposes.
I've created a very little ...
4
votes
1
answer
196
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 ...
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 ...
5
votes
1
answer
209
views
Express.js blogging application
I have put together a blogging application with Express, EJS and MongoDB.
There is a public, front-end part and a dashboard. In index.js I have:
...
6
votes
1
answer
659
views
Any better pagination logic?
router/article.js
...
1
vote
1
answer
172
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 ...
2
votes
0
answers
80
views
Express compatible JSON Web Token authentication middleware
I am writing an Express.js middleware function in a TypeScript NodeJS project that uses a function from a third-party module to perform a small workload. When writing unit tests, I want to mock this ...
2
votes
1
answer
107
views
Role based permissions in Express.js
This is something I've done a few times, but I've found it to feel a bit error-prone with so many conditions, and am wondering if anyone can point me in the direction of a cleaner way. This is a PATCH ...
2
votes
1
answer
316
views
Using Node.js, Express, and Express Router to implement a very simple REST API
To learn the ropes of Node.js and Express, I'm trying to implement a very simple REST API. The API says what it should do instead of doing it, so I can focus on the framework's structure. The ...
7
votes
1
answer
400
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
1
answer
134
views
Performance and login security for NodeJS using Express with Express-sessions
I am new to this part of backend development using JS and the truth being a new programming language (for me) it is worrying that it suddenly does not meet the structuring and / or security standards.
...
3
votes
0
answers
433
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 ...
3
votes
1
answer
155
views
Correct way to unit-test express API
I wrote an express API for a document management service (repo to be found here) and even though I understand the importance of unit-testing I never quite managed to wrap my head around how I would ...
0
votes
1
answer
294
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 ...
0
votes
1
answer
80
views
Registering a user and login
I have these following controller functions for registering a user and login, in my app, and I want to make it more clean and maintainable.
Probably by using ...
1
vote
1
answer
57
views
Express error if agency not found middleware
In an api I'm building, I have multiple routes that require an agency to exist before any action is performed on the requested agency.
To avoid repetition I've written some middleware to check that ...
1
vote
1
answer
110
views
API using NodeJS to recive data from client and send it to a server
Hello I have a NodeJS which act like an interface it connects the client(mobile app) to the actual server
My node JS API receives data from the client to verify it and send it to the server.
I want ...
2
votes
1
answer
79
views
Express Rest API Async and Scaling
I am currently learning how to create nodejs express rest api using async making it fully scaleable and secure.
My goal is to ensure maximum functionality and speed, currently I am using MVC ...
2
votes
0
answers
49
views
Backend application to bookmark GitHub repository
The backend part has the following purposes.
An endpoint that takes a search term and returns a list of repositories.
An endpoint that allows bookmarking a repository by its id.
An endpoint to get all ...
4
votes
2
answers
99
views
A JavaScript class, which finalises the HTML of each page of my NodeJS (Express) website
Background
A request (req in the code) is made to my server, and a response (res) returned. By the time the response has ...
1
vote
1
answer
60
views
Express server for an artists website
I am currently creating a website for an artist (my grandfather). My main concern with the code below is readability, as for the most part I have not worked with others on a (programming) project. I ...
3
votes
1
answer
520
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 ...
2
votes
0
answers
133
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
1
answer
545
views
Blocking requests within Express
Is this the correct way to block requests in Express?
app.js
...
2
votes
1
answer
80
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
2
answers
300
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 ...
4
votes
2
answers
209
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
0
answers
38
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:
...
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
70
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
0
answers
53
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
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
0
answers
430
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
0
answers
77
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
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 ...
2
votes
2
answers
90
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 ...