Questions tagged [express]

Express.js is an innovative and versatile framework for developing web applications on Node.js, offering a comprehensive range of powerful features that enable seamless creation of robust web solutions.

Is it feasible to utilize the local strategy in PassportJS without a database?

I am currently working on a small NodeJS server that connects to ElasticSearch. However, I am facing the challenge of implementing user authentication as storing user information in ElasticSearch is not an ideal solution. Instead of adding complexity by u ...

NodeJS/express: server became unresponsive after running for some time

Initially, my service using express and webpack ran smoothly. However, I started encountering an issue where the server would hang with no message code being received, as shown in the server message screenshot (server message screenshot). This problem kept ...

What is the best way to make a service in minikube accessible from another device on the same network?

I have set up a service in minikube (expressjs API) on my local machine. When I start the service using minikube service wedeliverapi --url, I am able to access it from my browser at localhost:port/api. https://i.stack.imgur.com/Rhm3B.png https://i.stack ...

What is the process for integrating Express middleware after implementing Apollo-Server v2 middleware?

I've encountered a unique issue while working with Express and Apollo Server. Despite searching online for solutions, it seems like this requirement is specific to me. My dilemma arises when I attempt to integrate an Express middleware after using the Apo ...

Pulling information from MongoDB within a specified price range using Node.js

I am currently working on fetching data within a specified price range from the property model. For example, if a user provides a minimum and maximum price, I want to display the number of properties that fall within that price range. I have indexed the ...

Passing data between pages in Node.js/Express without disrupting the flow of RESTful routing

Within my Express app, the initial landing page prompts visitors to input their email address and then choose between "Sign Up" or "Log In", depending on whether they have an existing account. Following this input, users are directed to either "/signup" o ...

Transfer all image files from Node.js to the frontend

What is the best way to send all image files from my backend nodejs server folder to my Reactjs client? I have set up a website where users can sign in and upload their files. However, I am facing an issue where only one file is visible on the client side, ...

Parse the JSON object from the request when the content type is set to 'application/x-www-form-urlencoded'

I have an integration with a payment service, and they sent me a request using cURL like this: curl -d '{"merchantAccount":"pipedrive_youscore_rubicon_ltd","orderReference":"WFP-BTN-7181819-635e48482b33d"," ...

Guide on creating a sitemap using Express.js

I've been working with the sitemap.js package from While I can add URLs to the sitemap manually, my challenge lies in adding URLs based on data retrieved from MongoDB. Since fetching data from MongoDB is asynchronous and involves callbacks, by the time I ...

The functionality is verified in Postman, however, it is not functioning properly when accessed from my client's end

I am working on a project where I have a button in my client's application that is supposed to delete a document from a MongoDB collection based on its ID. Here is the backend code for this functionality: index.js: router.post('/deletetask', async functio ...

export const routes = expressjs

Switching over from php to nodejs + expressjs has been a bit challenging for me, especially when it comes to exporting/including variables in my routes/users.js file. In my app.js file, I have the following setup: //setting up database connection var con ...

I'm facing a challenge where Multer is preventing me from showing images in my React app

Hi there, I'm currently facing an issue where I am using multer to save files on my server and store their path in mongodb. However, I am struggling to display them on my React application. Any assistance would be greatly appreciated. Thank you in ad ...

Retrieve external document and offer for download

Is there a way to create a download link for a Google CDN file on the client-side? I have several links on my webpage that when clicked, should trigger a download. For example: <a href="//ajax.googleapis.com/ajax/libs/prototype/1.7.2.0/prototype.js"&g ...

Modifying the design of a website in real-time using the EXPRESS.js and NODE.js frameworks

I successfully set up a simple website using node.js and express.js by following this helpful tutorial. My express implementation is structured like this with a jade file for the web interface. // app.js var express = require('express'), routes = re ...

Encountering a 404 error when using Vue history mode in conjunction with an Express

I'm facing an issue with my Vue SPA hosted on an Express server. Whenever I use history mode and refresh the page, I encounter a 404 not found exception. I attempted to solve this problem by utilizing the connect-history-api-fallback package but unfor ...

What is the best way for me to trigger the error handler by using the "next()" function in this project?

Currently, I am conducting a test scenario that involves running a POST request to a specific endpoint using malformed and edge cases. test("POST /register, malformed and edge cases", async () => { await request(server).post(`/auth ...

Strategies for distributing a Node.js application across multiple machines

Currently, I am utilizing Express js along with Node-cluster to take advantage of clustering. Additionally, I have implemented PM2 for efficient process and memory management on my single machine setup. However, as my machine only has 2 cores, I am looking ...

Passport.js implementation in a Next.js application does not persist the user's login state when navigating between routes

I'm currently utilizing passport.js with the local-strategy for authentication in my next.js application. Data store requests and authentication are functioning properly. However, I need access to the req.user in another route to retrieve the users._ ...

Implementing Do Not Track in an express application

I am trying to implement a feature named "consent" in my Nodejs express app that utilizes the Do Not Track (DNT) functionality from browsers. This function is supposed to integrate Google analytics on rendered pages only when DNT is not active or its state ...

Guide to integrating Gandi.Net API with Node.js in server.js

I'm a beginner in Node.Js and I'm currently working on creating a Mean Stack application. One of the things I need to do is call a 3rd party API, specifically Gandi.Net, from my Node.js code. My Node.Js and Express Application are being used to ...

Permitting hyperlinks in Helmets Content Security Policy (CSP

Recently, I've been encountering problems with my CSP header in Helmet. No matter what changes I make, the links always seem to be broken or return an error. How can I go about fixing this issue? Below is my current code: app.use( helmet.conte ...

Using Backbone for the front end and Node.js for the backend, this website combines powerful technologies

Currently, I am in the process of developing a new website that will function as a single-page application featuring dialog/modal windows. My intention is to utilize Backbone for the frontend and establish communication with the backend through ajax/webs ...

Knex has encountered a deadlock issue and has detected it

There is a function that reduces the stock in a database, but Knex is showing a 'Deadlock Detected' error when attempting to subtract quantities of 2 different items. This code contains loops to manage this issue. const updateOrder = (req, res, ...

A service is currently operational on the specified port

As a budding developer, I've encountered an issue with ports while working with the MERN stack. Despite setting the port to various numbers in my JSON file, it appears that something is already running on all of them. Interestingly, I recently switched f ...

Ways to display the outcomes of an http query using Express?

How can I utilize Request and Express to retrieve the result of my http request in order to display it? var request = require('request'); var http = require('http'); exports.index = function(req, res){ var apiUrl = 'http://api.bitcoincharts.com/v1/wei ...

Having trouble with importing a variable in an Express application? You may encounter this error message: "Route.get() must

When trying to import requireSignin from the controllers/auth.js file into the routes/user.js file and adding it to the router.get('/user/:id', requireSignin, read); route, an error occurs: Error: Route.get() requires a callback function but r ...

express session could not be authenticated by passportjs

Currently, I am integrating passportjs for authenticating my express app. Even though I have followed a tutorial closely, I keep encountering issues with session authentication. In my primary workflow, I authenticate users using the local strategy. passp ...

What was the reason for needing to employ `toObject()` in mongoose to determine if an object contains a certain property?

From what I understand, there is no .toObect() function in JavaScript, but it is used in mongoose to convert mongoose documents into objects so that JavaScript built-in functions can be used. I sometimes struggle with when to use it. There are instances w ...

Continuously encountering the error code 0906D06C related to PEM routines and encountering issues with reading the start line from the BIO

Struggling to troubleshoot an error in my Node.js project while trying to connect with the Xero API. I've experimented with various combinations of '.cer', '.crt', and '.pem' files. I've followed suggestions from multiple users on StackOverflow. Node.js ...

What is the best way to transfer a request parameter from a URL to a function that generates an object with matching name in JavaScript?

I need to figure out how to pass a request parameter from an express router request to a function that should return an object with the same name. The issue I'm facing is that the function is returning the parameter name instead of the object. Upon c ...

Is it possible to execute a node child process with a node script directly from a buffer instead of from a separate file?

At the moment, I am creating a node script in a string/buffer within a parent node script. Subsequently, I write the generated script to a file and then execute that file in a child process. Once completed, I delete the temporary script file. Below is a b ...

Why is my res.render() in Node.js and Express not functioning as expected?

After exploring various resources and conducting extensive research online, I have yet to solve the issue I am facing. My problem lies in attempting to render an ejs template, but nothing seems to be taking effect. Below is my code: Front-end script: $( ...

When attempting to sort, I encounter two errors that seem to be interconnected. The first error states "TypeError: cart is not a constructor" in the post method, while the

Uncaught ReferenceError: cart is not a constructor I have been using these technologies for over a year and have never encountered such issues before, so please help me out. router.post('/add-to-cart', isLoggedIn, function (req, res, next) { ...

What is the inner workings of stream.Transform in Node.js?

Recently, I stumbled upon a code snippet on a blog showcasing the usage of the stream Transform class to modify data streams and display the altered output. However, there are certain aspects of this code that leave me puzzled. var stream = require('stre ...

Express POST request body is required

I am starting to learn nodejs and express, and while reviewing some code I found this interesting snippet. Can someone please explain what it means and how I can send a POST request to it using cURL? There are no specified data fields. app.post('/&apo ...

Creating PDF files with dynamic image paths retrieved from the database can be easily achieved using various npm packages. Below are the

As I work on building a software using express-mongodb-ejs, I've encountered some challenges with generating and downloading PDFs. While I've explored several npm packages for this purpose, I've found that I am unable to generate a PDF with a dynamic image ...

Understanding JSON Parsing in Jade

I am facing a challenge with handling a large array of objects that I am passing through express into a Jade template. The structure of the data looks similar to this: [{ big object }, { big object }, { big object }, ...] To pass it into the Jade templat ...

Mongoose encountered an error when trying to convert the value "me" to an ObjectId at the path "_id"

Although there have been multiple versions of this question, I couldn't find a helpful solution. function isAuthenticated() { return compose() // Validate jwt .use(function (req, res, next) { // allow access_token to be passed through ...

Basic task manager application experiencing difficulties connecting to mlab database on Node platform

I have been following a tutorial and have encountered an issue where I am unable to establish a connection with the mlab database I created. The error message "MongoError: failed to connect to server [ds129260.mlab.com:29260] on first connect" keeps poppin ...

Starting node.js express server with a delay implemented

Currently, I am utilizing Express for my http server. My aim is to set up the database connection before initiating any HTTP connections from the client side. A snippet of the code is shown below: function connect_to_db(connection_string) {...}; connect_ ...

Error in Node.js: Packet sequence mismatch. Received: 0, Expected: 244

For the past 10 days, I've been grappling with this issue. Despite trying everything I could find on Google, I still haven't found a suitable solution. After initiating "npm start" on the server at night, I woke up to an error in the morning. throw er; // ...

Express not receiving data from HTML form submission

Check out my HTML form below: <form method="post" id="registration-form" action="/register"> <div class="form-group"> <label for="UsernameRegistration">Username:</label> <input type="text" class="form- ...

ExpressJS: Elevating Bread to New Heights

I've been struggling with adding a toast using expressjs. I attempted to use the npm package "toastr" but encountered an error stating that $.extend is not a function. In an attempt to resolve this, I replaced it with Object.assign but still couldn't get i ...

Make Connections between Schemas with MongoDB, Express, and Mongoose

I need to establish relationships between my schemas in the "Movie" entity so that I can access information from other entities like: Category Actor Director Studio Right now, I am testing with categories. This is the code I have written: controllers/m ...

The route parameters in Vue SSR are being retrieved from a separate request

I am currently using Akryum/vue-cli-plugin-ssr along with vue-cli, but I have encountered an unusual issue in my Vue SSR application. It seems that the route params are getting mixed up with requests made either before or in parallel to the current one. F ...

Empty array in req.body using Express, Multer, and BodyParser would result in no

Apologies for my lack of experience, but I am encountering an issue with a form that uploads images and adds text to the database. The images upload successfully, however, the req.body object is consistently returning as an empty array. HTML <form cla ...

Exploring MongoDB through User Interface Requests

As part of a project to develop a minimalist browser-based GUI for MongoDB, an interesting question has arisen. How can we accurately display the current state of the database and ensure it is continuously updated? Specifically, what methods can be utiliz ...

Creating a feature that allows users to edit the order of items within a MySQL

I am working on a project where I need to display a table of items that can be added, deleted, and reordered by the user. Initially, I planned to store these items in a MySQL database with an order column in the table. However, I realized this method is in ...

Curious about how to utilize Gridfs to upload files or videos larger than 16mb with the help of express, mongoose, and mongodb?

I'm encountering an issue with my code. It works fine for uploading images, but when I try to upload videos or files larger than 16mb, it fails. I am a beginner and seeking help on what to do next. const Freecoursevideo = require("../models/freecour ...

Is there a way to ensure that Express JS retains local variables even after server restarts?

I have set up an Express server in NodeJS v14.15.1 to handle both HTTP GET and POST requests. As part of the server operations, a key is generated and stored as a global variable within my index.js file where the express() app is located. The issue I am fa ...

Utilize i18next Localization in a Function Instead of App.js

Currently, I am utilizing ExpressJS and i18next. Within app.js var express = require('express') , i18n = require('i18next') , user = require('./routes/user') ... //internationalization i18n.init({ lng: 'en-US', saveMissing: true, debug: true }) ...

Having trouble sending a PDF attachment with more than two photos through SendGrid

I encountered a strange issue with my API. The API I created allows users to upload photos to the server, save data to the database, generate a PDF with the data and photos, and send an email with the PDF attachment. Everything was working perfectly when I ...

Issue with rendering an object's property using EJS

Trying to include the author's username in reviews within an ejs template for my app. The following code snippet: <%= review.author %> is functioning correctly and displays: { _id: 5eff6793e7f26811e848ceb1, username: 'mike', __v: 0 } However, wh ...

How can I incorporate Bootstrap/Semantic UI into an Express project without relying on external CDNs

After downloading the minified version of Bootstrap and placing it in the root directory of my project, I added the following code to a HTML file located in /views/: <link rel="stylesheet" href="/bootstrap.min.css"> Despite this, the page remained ...

What could be the reason for my Express server returning a 404 error for all files other than index.html?

Currently, I am delving into Node.js with Express in order to set up a small server for educational purposes. Strangely, every request made to files linked within my index.html file, such as the .css, .js, and image files, results in a response code 404. ...

What is the best practice for storing angular partials - should they be kept in the public/ directory, views/ directory, or another location altogether

Currently developing a Pinterest-inspired platform to enhance my understanding of node.js. I'm contemplating where to store my partial views, such as those for rendering pins - should they be placed in the public/partials folder or within the views/ direct ...

What is the method for displaying html files in a POST request?

This is the code snippet I am working with: app.post('/convert', function(req,res){ var auxiliar = "somo Ubuntu command line(this works)"; exec(auxiliar, function(err, stdout, stderr){ if(err){ console.log ...

Navigating files using NodeJS and ExpressJS

Can NodeJS (or ExpressJS) facilitate the following task? Although I appreciate the flexibility that routing provides, I find the configuration process quite cumbersome. (I don't consider myself an expert in Express) For instance, imagine an application s ...

Encountering an issue retrieving static files through the Express static middleware

I'm having trouble with serving images on my backend. Here's the endpoint I've been trying to use, but with no success: app.use('/uploads', express.static(__dirname + '/uploads')); This is what "__dirname + '/uploa ...

How to manage rejections in async/await within the Array#map method

In my Node 8.1.2 project, I encountered a scenario where one file is calling another file's function within a map structure. While in a real example, I would normally use Promise.all on the map, that specific implementation is not the focus of this questio ...

What is the purpose of using the http module to specify the port when the app.listen function already sets the

var express = require("express"); var app = express(); // This code sets the port to 8080 by default, or else it will use the environment-specific port. app.set('port', process.env.PORT || 8080); app.get('/', function(req, res){ res.send('hello world ...

What is the best way to set up a dedicated upload file directory for testing purposes using express.js?

Looking for a way to handle file uploads during testing? The challenge is that the static folder location changes between production and development environments. In production, files are stored in the build folder, while in development they are stored i ...

How does the interaction between Express and Angular for routing in the MEAN Stack function?

Currently, I am utilizing Express static to direct to the public directory. //app.js app.use(express.static( __dirname + '/public')); I am looking for a way to have most of the UI routing done by AngularJS. However, it seems that it only works ...

What is the proper way to utilize express.json() and set headers (res.setHeader) at the same time?

I'm currently working on a POST request and need to both view the body of the request and set some headers. Specifically, I want to enable communication from localhost to localhost by adding Access-Control-Allow-Origin: * as a header. This is what my ...

Node.JS and MySQL integration problem: Failed to insert database record

I'm currently working on performing CRUD operations for a RESTFUL API using MySQL and NodeJS Express. I encountered an error while trying to insert a record into the database. Despite copying the insert query from SQL where it was functioning correctl ...

Is there a way to determine the selected radio button using Node.js?

I'm currently working on a form that includes two radio buttons. I am posting the request and using the body parser npm package to retrieve the values of the form inputs. Here is how the radio buttons are implemented in the form: <p> < ...

The client continues to request the file through the REST API

I have noticed a behavior with an audio file stored on the server that clients can request via a REST API. It seems that every time the audio is played again, a new request is sent to the server for the file. Is there a way to prevent this or cache the dat ...

Determining whether a request should be processed by a middleware in an Express application dynamically

New Beginnings: As a newcomer to the world of Epxress, I recently built a middleware for checking user credentials. Here is how I specified it: var check = function(req, res, next){/* checking user cred*/} I then used it in my code like this: app.use(c ...

Discover information lacking a specific identifier

I am currently trying to retrieve items from my database using the mongoose .find() function. In my router, here is the code I have for extracting specific items from the URL. For instance: mydomainname.com/market?type=1&name=hi&stats=123 ...?t ...

Looking to confirm client-side text in NodeJS?

As I work on constructing a to-do list, one challenge I am encountering is confirming that the correct task has been checked off. While considering using unique IDs for each individual task may seem like a solution, there is still the risk of users manipul ...

What is the best method for ensuring image orientation is displayed correctly?

When utilizing multer node and express for uploading images to my application, I've noticed that some of the images appear rotated 90 degrees once they reach the client side. What could be causing this issue, and how can I resolve it? Just to clarif ...

Learn how to manage Ajax GET/POST requests using nodejs, expressjs, and Jade Template Engine

I am currently working on a project that involves the use of NODE, EXPRESS, and JADE TEMPLATE ENGINE, as well as AJAX to optimize page loading. However, I encountered an issue when trying to utilize the data received from a GET request in AJAX directly wit ...

Error message 800A03EA in Windows Script Host encountered while running Express.js script

I'm currently diving into the world of JavaScript development, following along with the guidance provided in the book called "JavaScript Everywhere." The book instructs me to execute the following code: const express = require('express'); const ap ...

Is Exposing Database Passwords on Github a Potential Security Concern?

I recently set up an express server and I'm still fairly new to the world of databases. An interesting dilemma has come up - if my express server's code is hosted publicly on Github, and it contains this snippet: const pool = new Pool({ user: ...

Unresolved Issue: Inoperative Mongoose Populate and ExecPopulate

In my application, I have two mongoose models: 'Department' and 'Course'. These models have a one-to-many relationship, with the department ID stored under the 'department' field in the course document. My goal is to query all the departments and populate ...