Category "express"

Is there a way to cast a string of only hh:mm to Date in Javascript

I have a business hours object in a mongoose schema that represent a date. I'm passing a json object and retrieving the to parse to Date as string. I wonder if

How to change port using fetch and request react js?

This is the code I took from my professor's tutorial. LoginComp is just {username: '', password: ''} const request = new Request("/users/login", { method: "

TypeError: User.generateAuthToken is not a function

userSchema.methods.generateAuthToken = async function() { const user = this const token = jwt.sign({_id:user._id.toString()},'thisisnewcourse') ret

How do I handle res.download(pathname) on frontend(ReactJS)

I have written a code on my server(NodeJS) that will send a .csv file to the frontend with express res.download(path). I would like to know how I can handle the

Why the Azure Event Hub get events so slow?

Event Hub is fast to send but slow to get. I use next code: subscribe(cb: (event: any) => Promise<void>) { this.consumerClient.subscribe(

How to get value from db.any() promise in pg-promise?

I use pg-promise and i tried to make a request to database in user model to get an array of all users like this: exports.getAllUsers = function () { let

How to solve AWS Elastic Beanstalk 504 Timeout Error?

I am using AWS Elastic Beanstalk for hosting Express/Node.js API server. It's working well with just normal APIs but I am getting this 504 Timeout error with on

Client-side jwt token storage

I need advice, what is the best way to store a JWT token? Should we store in cookies or storages? But with the CSRF flaw and xss attacks I have a doubt. I'm sti

While deploy the MERN Stack at DigitalOcean error TextEncoder is not defined

My app works on development but gives Text Encoder error in production. When I run the Node index.js command, I get the error "TextEncoder is not defined". Erro

How do i solve this node.js error when im calling it with jQuery?

I have this assignment and I'm a bit stuck. When I press the button on the site the console I get this error: GET http://localhost:3000/getUser 404 (Not Found)

Is there a way to avoid stringValue Favicon.ico error in express js

I am trying to build an application in my Express and anytime i navigate to the admin page i get this error const castError = new CastError();

Getting "Cannot set headers after they are sent to the client" error in Express [closed]

Screenshot of the error: Code of client side: jwt attached api: Here's the jwt verifying function: const authHeader = req.headers?.auth

KoaJs cant handle POST requests on CloudFunctions

I have a NodeJS Application written in KoaJS, app.ts const app = new Koa(); app.use(healthCheck()); app.use(bodyParser()); app.use(errorHandler()); app.use(end

How to do multiple (simultaneous) versions of APIs with OpenAPI and express-openapi?

Re: https://www.npmjs.com/package/express-openapi#getting-started On many projects I've been worked on (in other technologies) we would always support multiple

How to delete and insert with a single command in mongoDB?

So, I have a collection like this: [{ "name":String, "address":String, "hobby":Array of Strings }...] Every hour I query an API and get the response l

Storing sessions with express-session, connect-mongo, and mongoose

I am looking for guidance on setting up session based authentication with with Express-Session, connect-mongo, and Mongoose. Currently it's just generating a ne

why hashedPassword = await bcrypt.hash(this.password, salt) is not working?

I'm basically trying to just hash a password using bcrypt using async/await but nothing is working... next() is not working and it is not saving the data into t

Why does Zod make all my schema fields optional?

I am using Zod inside my Express & TypeScript & Mongoose API project and when trying to validate my user input against the user schema it returns types

Why does Zod make all my schema fields optional?

I am using Zod inside my Express & TypeScript & Mongoose API project and when trying to validate my user input against the user schema it returns types

setting up s3 bucket to handle cross origin resource policy

I am facing issues playing audio files from my s3 bucket. I was wondering if I set up the cross origin resource policy poorly. Here is my server.js file: app.us