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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
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"," ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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._ ...
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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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: $( ...
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) { ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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_ ...
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; // ...
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- ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 }) ...
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 ...
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 ...
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 ...
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. ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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> < ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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: ...
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 ...