Currently, I am utilizing the reload package during development. This particular package is listed under devDependancies within my package.json file. Within my app.js, the following code snippet can be found: if (process.env.NODE_ENV !== 'production') { ...
Is there a way to access the collection in the controller using mongodb and express? I came across this code snippet in the mongodb documentation db.getCollection("countries");, but how do you import the database name: db into a controller? serv ...
Currently working on a basic MEAN web application and just getting started with the stack. The front end is up and running smoothly, but when I try to integrate the following lines into app.js: var mongoose = require('mongoose'); require('. ...
Currently, I am working on a task page and I need to implement the functionality to upload a file along with the form submission to the NodeJs express server. @Component({ selector: 'tasks', template: `<div mdl class="mdl-grid demo-c ...
When attempting to send a file from the front end to my node js server, I encountered an issue with receiving the file on the back end. Here is the code snippet: <form id="file-upload-form" class="uploader" action="/uploa ...
While attempting to set up an express server using Angular 2, I noticed in various configuration examples that the angular-cli.json file was being modified to point to a server.js file as the main configuration. However, after making this change, the appl ...
I have been attempting to send a fetch request to my server, but I am consistently receiving an empty req.body. Here is the client-side script: const form = document.getElementById('form1') form.addEventListener('submit', (e) => { e.preventDefa ...
I am trying to find a way to push an object into an array inside my MongoDB database. When using the $push method with submits[postDate], I am encountering an error with the syntax highlighting the first "[". Any suggestions on how to resolve this issue? ...
I'm currently in the process of developing a multiplayer game using websockets, node, and JavaScript. I need advice on the most effective approach to update client information and manage their coordinates on the server. The method I am using at the mo ...
This problem is really frustrating... I'm having trouble with a throw exception that causes my express server to crash in my async login function. The issue here is that the error isn't caught by the try/catch block. Even though the user data is successful ...
I am a bit confused about the return value of updating documents in MongoDB and how to effectively handle errors that may occur. Currently, I am utilizing Node.js, Express.js, and Mongoose.js as my primary MongoDB driver. After reviewing various tutorial ...
When using express.js + ejs, I encounter two scenarios: 1. <a href="<%= prevDisabledClass ? '' : ?page=<%=+page - 1%>%>">prev</a> Unfortunately, this code throws an error: Could not find matching close tag for "<%=". ...
I keep encountering an error in my application (using Node.js as API) and Angular 8 as frontend. The error message says: Access to XMLHttpRequest at 'http://localhost:3000/socket.io/?EIO=3&transport=polling&t=NQJpoTm' from origin 'ht ...
Hey there, I'm currently working on setting up my routes and including a "content" file to execute a query. app.get('/participants', function(req, res, next) { var participants = require('./content/participants'); }); Next in the 'participants' file: ...
I'm having difficulty passing initial props to my React component from my Node (express) server-side rendering. Here's a summarized version of the component: /* mycomponent.jsx */ import React, {PropTypes, Component} from 'react/addons&apo ...
I am trying to initially render my ReactJS application on the server using ExpressJS. Although I have been able to import ES6 modules using require(), the module crashes upon loading because it contains ES6 code (ES6 import and export). Index Route var ...
Currently, I am in the process of developing a Node/Express web application for basic CRUD operations. However, I am encountering difficulties incorporating Handlebars into my project. Whenever I attempt to utilize Handlebars, none of the stylesheets from ...
The current authentication process is functioning properly app.post('/login', passport.authenticate('local-login', { successRedirect: '/home', failureRedirect: '/login', failureFlash: true }) ); Howev ...
I am currently developing a server using expressjs: 'use strict'; var express = require('express'); var logger = require('morgan'); var path = require('path'); var bodyParser = require('body-parser'); var api = require('./routes/main'); var app = ex ...
While experimenting with node.js, I encountered a puzzling issue where a setup works in one instance but fails to work in another instance after making a minor change. In my app.js file: app.use('/musicplayer', require('./routes/music/inde ...
I'm currently running a nodeJS server using the express framework. When sending a request to the server, it should respond with data in an array format. However, instead of receiving the expected data, I am getting ''. The specific test I'm attempting to ...
Hi everyone, I am a beginner in MEAN stack development and I'm facing an issue while trying to make a post request using Postman. The error message I'm getting is "username not defined". I have successfully established a connection with mongodb and it is w ...
I'm facing an issue with multiple MongoDB documents related to each other. I need help accessing keys and values from the parent document down to the grandchild relational document. Here's the structure I have: const itemSchema = new mongoose.Schema({ ...
I am currently working on populating a response array with Firestore snapshots and creating download links for stored files within each snapshot. Despite trying various solutions involving Promises, the response array consistently ended up being null. do ...
Currently, I am delving into the world of full stack web development with a focus on Node/Express. The project at hand is to create a voting app as part of a challenge from FreeCodeCamp, which you can find here. To display user votes in pie charts on the f ...
Our express js application includes a feature in the admin module where users can send emails at specific dates and times they select. For example, if the chosen date and time is [email protected], we need to execute the email code at that exact time ...
Utilizing node as well as express, I have set up my web applications on AWS Ec2 Linux, running on ports 8080 and 8081 using pm2. I have also added subdomains to my Elastic IP - admin.example.com and app.example.com. Both of my applications are currently ...
I am currently utilizing ExpressJS as my server and MySql as my local database. However, I am facing a challenge in retrieving data from a specific table and sending the query result to either a vanilla JS file or directly editing HTML through NodeJS. Her ...
Looking to retrieve information from an axios put request in order to update MongoDB data. Below is the client-side JavaScript: const saveProduct = (url, name, price, type, image) => { axios.put(url, {name: name, price: price, type: type, image: ima ...
As a newcomer to Node Express Mongo, I decided to venture into creating my own website after following tutorials. The page I'm working on is a login page. While other people's code has worked for me, my attempt didn't go as planned. Even con ...
I have successfully managed to host two separate angular applications (one for customers and one for company staff) on the same node server, under different paths. The setup looks like this: // Serve admin app app.use(express.static(path.resolve(__dirname, ...
On my React frontend, I have a select dropdown like this: <select name="level" value={level} onChange={this.handleChange} className="form-control"> <option>Begineer</option> <option>Intermediate</option> <option> ...
I am working with an Api Gateway Rest Api that is protected by Cognito Authorizer and integrated via VPCLink to access my container hosting a NodeJs Express app. The complete flow looks like this: Api Gateway -> VPCLink -> NLB (Network Load Balance ...
For the past few days, I've been struggling to send a proper redirect request in my App. Here's what should happen: If I attempt to perform an action that requires me to be logged in, my express app should automatically redirect to the login URL. router.u ...
I have a MongoDB schema that looks like this. { userID: 19202, products: [{ id: 020, name: 'first' }] } My goal is to remove items from the product array based on their id. I tried using the following command but it didn't give any errors and also ...
After mastering node.js, I decided to deploy my project on Heroku. However, upon deployment, Heroku started throwing error messages that have left me puzzled despite logging and analyzing the errors. Below are the detailed logs: 2016-04-13T14:24:17.24868 ...
After following the steps in this tutorial for deploying to a lambda function, I encountered some issues. When testing it using serverless offline, I kept getting 404 errors for each compiled JS file. However, once I deployed it, the errors changed to 403. ...
Having been successfully running node.js(0.8.20 and 0.9.10) on Windows Server 2012 for weeks without any issues, I recently added Nginx(1.2.6) to the mix. However, after configuring Nginx as follows: #user nobody; worker_processes 1; #error_log logs/e ...
After recently transitioning from Socket.io 2.x to 3.0.3 and integrating it with [email protected], I encountered an issue. Following the instructions provided in the original migration documentation, I attempted to retrieve a list of all open socket ...
I'm experimenting with a simple API that returns XML response: const express = require('express'); const bodyParser = require('body-parser'); const cors = require('cors'); const libxmljs = require("libxmljs"); const PORT = process.env.PORT || 5000; con ...
When dealing with a resource in the database, I am familiar with utilizing the mongodb npm package within my express app to apply filters like $gt, $lt, etc. This allows me to specifically retrieve values based on the desired filter criteria. In addition, ...
I have a variety of collections stored on a remote MongoDB server. My objective is to retrieve a specific collection based on the city name. I am currently using POSTMAN to mimic a GET request, but it seems that a different GET method is being triggered: { ...
When attempting to register a user using a Node.js app and MongoDB, I encountered the following error message: const utente = new Utente({ ||||| TypeError: Utente is not a constructor This is my model file, utente.js: const mongoose = require("mongoose") ...
Having an issue with sending data using JavaScript and AJAX. The objective is to send the data via PUT method to the server. var payload = 'id=' + id + '&brand=' + brand + '&model=' + model + '&country=' ...
I constantly find myself struggling with defining objects inside res.render. Is there a way to define them globally or outside of res.render? I hope someone can offer some guidance.. here is a sample code snippet: router.get("/home/blog", function(req,r ...
Greetings, all! I have been working on a web scraper using node-simplecrawler. Everything is functioning smoothly, but I am facing a challenge in stopping one instance when initializing a new one (I aim to run only one at a time). My setup involves expres ...
I have a situation where I need to update the document in MongoDB for three different chatrooms only if the user's id matches with the member's user_id. However, I am facing an issue where the token is being updated across all devices of the memb ...
Is there a way to display a progress bar loader based on the server process in the client-side? For example, if a user clicks on a download button, the server receives the request and then retrieves data from the "user" table in database1 (let's say there ...
After successfully setting up a node.js app and deploying it onto elastic beanstalk, I am now looking to establish a webhook for the app to listen to a typeform survey. What would be the most efficient method for achieving this? Should I opt for lambda i ...
I need to implement a key/cert with a passphrase in my project that's currently using saml2-js. I have already set up everything but encountering a bad decrypt error without the passphrase. Is there a way to incorporate this passphrase? Below are the ...
I am currently working with express.js and I have a requirement to log certain request data whenever someone attempts to log a message. To accomplish this, I aim to create a helper function as follows: function logMessage(level, message){ winston.log(le ...
Presently, I have a setup with a NodeJS + ExpressJS client-side server that communicates with the back-end server via API calls. However, every time I make a call, I need to manually navigate to the URL of the API back-end server and click on Advanced -> P ...
I am currently facing an issue while trying to host a vue.js single page app using a node.js server. The problem seems to be related to some express middleware. Specifically, my struggle lies in serving two components - my index.html file and a dist folde ...
I am currently utilizing the express framework, along with chai for testing purposes. When it comes to local login, I have been testing by passing data such as {mobile_number, otp}. Depending on the response received, the test either passes or fails ...
I have a MEAN application that is currently working on implementing a GET Request for '/changepassword'. The specific file I am targeting is located in the '/users/changepassword' directory. For password hashing, I am utilizing Mongoose along with bcryptjs ...
Recently, I enrolled in an advanced ExpressJS course. While exploring the course website, I stumbled upon the "hello world" section. Intrigued, I decided to copy and paste the code provided below: const express = require('express') const app = express() co ...
I am working on implementing a delay for an API call by using setTimeout. The goal is to return res.status(200).json(response) after a 2-second delay upon success. exports.someEndpoint = function(req, res) { return request.post({ url: //etc ...
It seems like there is a syntax error in the bash_profile file on line 9. When trying to run the server using nodemon, an unexpected end of file error occurs. Nodemon is set to restart at any time and is currently watching for chan ...
By default, Passport stores its user object in req.user. Is there a way to customize this behavior to store it in another location, such as req.whatever? ...
Essentially, I have a UserLadder model that contains a nested User model: try { const leaderboard = await UserLadder.findAll({ where: { weeklyLadderId: req.params.id, }, limit: req.params.playersNumber, attributes: [&a ...
I am new to Node.js and Express, and I am facing an issue with accessing the socket.io object in other modules. I tried creating a global variable to hold a socket object, but once the connection is closed by the user, the socket becomes unavailable. Altho ...
Currently, I am facing a challenge in rendering text using node/express. Within my project setup, there is an HTML file containing a form. The file named search.ejs looks like this: $(document).ready(function(){ var userInput; $("#submit-button-i ...
When trying to send a direct email through SendGrid in my Node.js project, I am encountering a 403 Forbidden error. The API Key that I am using has full access permissions, and the code integration seems to be correct since it worked flawlessly when using ...
I've been diving into nodejs and databases with the help of an online resource. As part of my learning process, I have been tasked with replicating the code below to fetch data from app.use('/server/profil'); However, I'm encountering ...
In my current project using ExpressJS, I have a specific route set up like this: router.route('/monitor') .all(function (req, res, next) { next(); }).get(monitor.monitorServers); There is also a controller named 'monitor' which co ...
How can I dynamically set App Engine based on the URL? In my application, I have two render engines available: serverSideRenderEngine & browserRenderEngine If the URL is /home, the app.engine should be set as serverSideRenderEngine If the URL is /l ...
As someone new to web development, I'm experimenting with Node.js, Express, and EJS to create a weather application that displays the temperature based on a zipcode. So far, retrieving and showing the temperature has been successful. However, I want t ...
Within the passport documentation for authentication configuration, there is a function that appears rather intimidating as it utilizes the enigmatic function "done." passport.use(new LocalStrategy( function(username, password, done) { User.findOne( ...
I am currently working on serving an HTML page with a linked JavaScript script using node.js and express. Here is the server that serves the page: var express = require("express"); var app2 = express(); app2.get('/', function(req, res) { res.sendfile(' ...
My goal is to transform my current webapp into a mobile app. The existing setup consists of a nodejs-express REST API server with an HTML/JS client. I aim to utilize the API from the REST server and replace the client with a phonegap/cordova based mobile ...
I recently created an application using ExpressJS, PassportJS, MongoDB with Mongoose, and JSON web tokens. When implementing the successful login route, I encountered the following code: await user.insertLoginTime(); const token = user.generateJwt(); res ...
Software Dependencies: "ejs": "^3.1.9", "express": "^4.18.2", The structure of my project directory is as follows: /usr/src/app/ | |- app.js |- api/routers/main.js |- website |- src/views/myView.ejs |- r ...
Can an Express.js server be initialized within the browser using Angular? I am interested in executing Node scripts on the Express server via an Angular component. ...
After using the create-nuxt-app npm command, I ended up with a server/index.js file for my app. const express = require('express') const consola = require('consola') const { Nuxt, Builder } = require('nuxt') const app = expre ...
After successfully setting up npm on my local machine and creating a project using parse, I encountered an issue when trying to run the project with the command npm start. The error originates from a specific line of code in the index.js file. var api = n ...