Category "express"

Docker Redis Error: connect ECONNREFUSED 127.0.0.1:6379

I'm following a tutorial from youtube creating a simple dockerized CRUD application in Express, Node.js, Mongo & Redis. I stucked at video 3:06:57 on Authen

why sequelize beforeUpdate hook doesn't work?

I have a simple user model with 2 hooks. User.beforeCreate(setSaltAndPass) User.beforeUpdate(setSaltAndPass) the first works perfectly but the beforeUpdate doe

Ask for credentials before showing my swagger

I'm trying to add security to my API swagger endpont. I have created my API using node.js and express and swagger-ui-express module. The problem is that anyone

Session Data is not updating

I m using express-session and memcached-connect package for maintaining session. Everything is working as expected. Here is my implementation: Middleware app

create-react-app shows an error of "You need to enable JavaScript to run this app."

I use express for my API. I have a folder named app and another folder named server. app is the client app, using create-react-app as boilerplate, while server

How does this function that takes in a RequestHandler in express work?

I was browsing through some code examples for Express server on GitHub and came across this function used to wrap around REST API controllers and was confused h

How to return id of uploaded file (upload with multer in nodejs express app)

I have an MEAN stack app and trying to upload file with multer. Upload is working fine the only problem is I want to return uploaded file's id. //multer setti

How to generate a refresh token?

I am implementing JWT in one of my node apps. I am wondering, if there is any definite format/ structure in which a refresh token should be generated? By de

Creating single instance or multiple instance of service layer in nodejs

I want to know what should I use to expose my service layer for nodejs api What are the pros and cons of using the approach 1 and 2. app.post("/", (req, res) =&

Using axios.post, response.data return html instead of data [Nodejs, React]

What I want is, when I click SUBMIT button, it should post some data using axios.post const sb = async () => { axios.post('/tagSearch',{ qual: qual

MongoParseError: URI does not have hostname, domain name and tld

I'm getting this error when I try to connect my app(nodejs) to mongodb. I really appreciate your help here. MongoParseError: URI does not have hostname, domain

Moment.js startOf is returning end of day

I am passing in the following date through query string: 2020-09-23 I am trying to figure out why the below code with the doesn't work comment above it is not w

Not able to add more than 1 post request in the mongo db

i am using mongo db to fetch and post the data but unable to post more than 1 request here is my code ON posting the different values second time i am getting t

How to make 301 redirect in NextJS Vercel project?

How can I make 301 re directions from one url to another in NextJS application that is stored on Vercel? I tried to add custom express server using server.js fi

How can i get specific error messages from a Mongoose Schema?

I am trying to set up user validation in Mongoose and struggling to get the specific messages to appear. Here is my model const userSchema = new Schema({ n

Appending a Prefix to Routes in One File in Express JS

I am currently refactoring my code and I am hoping there is a more efficient way to make my code look pretty. Here is what I currently have: router.route('/ap

Appending a Prefix to Routes in One File in Express JS

I am currently refactoring my code and I am hoping there is a more efficient way to make my code look pretty. Here is what I currently have: router.route('/ap

How to deploy my app to heroku when i have two different folders

I have a project with two defferent folders. One is frontend the another is back-end. I want to deploy this both folders on one heroku app. In the server.js i h

Node js express error hanlding middleware dont recognize 4 elements

I'm trying to create an error-handling middleware, and as you can see in the image attached when I'm making the app.use((err,req,res,next) => {...}) block

How to log - the 12 factor application way

I want to know the best practice behind logging my node application. I was reading the 12 factor app guidelines at https://12factor.net/logs and it states that