express

Configuring 'simplest' node.js + socket.IO + Express server

一个人想着一个人 提交于 2020-01-06 06:47:29
问题 Realized after setting up a simple node.js socket.IO server that it isn't sufficient to handle even the simplest webpages containing script tags. So I investigating express which is a simple web framework for node.js. After looking thru the express documentation http://expressjs.com/guide.html I was still confused as to how I simply combine express with socket.IO on a node.js server. Couple hours of googling later I came across this tutorial https://www.digitalocean.com/community/articles/how

Configuring 'simplest' node.js + socket.IO + Express server

北战南征 提交于 2020-01-06 06:47:25
问题 Realized after setting up a simple node.js socket.IO server that it isn't sufficient to handle even the simplest webpages containing script tags. So I investigating express which is a simple web framework for node.js. After looking thru the express documentation http://expressjs.com/guide.html I was still confused as to how I simply combine express with socket.IO on a node.js server. Couple hours of googling later I came across this tutorial https://www.digitalocean.com/community/articles/how

How do I pass data returned from a controller to Express' router?

佐手、 提交于 2020-01-06 06:45:52
问题 I'm trying to make a catch-all of sorts to return data to my Author endpoint. If the url that is passed to the endpoint contains no query parameters, I want the router to return the full list of authors available. If the url contains firstName and lastName parameters, I want the controller to find the authors that match and, pass that data back to the router. Currently if I send the urls http://localhost:3001/authors or http://localhost:3001/authors?firstName=tom&lastName=dooly , I get an

Cant access values in my EXPRESS / NodeJs response error [String: 'Error: Request returned error code: 404

自闭症网瘾萝莉.ら 提交于 2020-01-06 06:43:49
问题 i am trying to access values in my express response error. When I console.log the error like this... app.use(function(err, req, res, next){ console.log(err) }); The console looks like the following [String: 'Error: Request returned error code: 404 and body: {"status":404,"title":"No option(s) were found with this query.","type":"https://developer.bigcommerce.com/api#api-status-codes"}'] For Example; how do i access err.title so i can send this to the client. reference this question for more

Cant access values in my EXPRESS / NodeJs response error [String: 'Error: Request returned error code: 404

二次信任 提交于 2020-01-06 06:43:27
问题 i am trying to access values in my express response error. When I console.log the error like this... app.use(function(err, req, res, next){ console.log(err) }); The console looks like the following [String: 'Error: Request returned error code: 404 and body: {"status":404,"title":"No option(s) were found with this query.","type":"https://developer.bigcommerce.com/api#api-status-codes"}'] For Example; how do i access err.title so i can send this to the client. reference this question for more

How to save my data on mongoDB by using expressjs?

一世执手 提交于 2020-01-06 06:39:13
问题 I am a beginner in Backend developing, and I have this array called ( Movie ). I use expressJS and I want to save the array on MongoDB .I will use Mongodb atlas for my database. I appreciate your help I tried to follow this instruction on this website: https://medium.com/@lavitr01051977/node-express-js-aea19636a500 I ignored the first steps and starts from ( Connecting to the Database ) title but It doesn't work. var express = require('express') var app = express() app.get('/', (req, res) =>

Failed to load resource: net::ERR_CERT_AUTHORITY_INVALID

拥有回忆 提交于 2020-01-06 06:30:49
问题 I am implementing node js script over https. Node js const options = { key: fs.readFileSync('private.key'), cert: fs.readFileSync('cert.crt'), // This is necessary only if using the client certificate authentication. requestCert: true, rejectUnauthorized: true, // This is necessary only if the client uses the self-signed certificate. ca: [fs.readFileSync('client-cert.pem')] }; On each request this is giving error:- ERR_CERT_AUTHORITY_INVALID I have searched a lot but nothing found. I use

Express and Mongoose fail to handle multiple requests at same time

社会主义新天地 提交于 2020-01-06 06:28:30
问题 So I have an API call /add which will add a car into my intersection when POST to it. So currently I'm writing a batch to add multiple cars at a short time by calling curl command in the background with & in UNIX shell. According to my log, all requests (total 125) has successfully sent to the server and the server has received it properly. But no matter how many time I try the intersection won't have a total of 125 cars, sometimes it'll have around 80, sometimes I only get like 40. I'll

How to use one Mysql pool connection in many files in a NodeJS Express App

梦想与她 提交于 2020-01-06 06:25:33
问题 I've been scratching my head at this. I wanted to know if there was an efficient way of creating one Mysql connection and sharing it between different modules in an application served by Express. So far I have the following code at the top in all my JS files that require a database connection of sorts: const db = require('mysql2') pool = db.createPool(<config details>) // Below pool.execute(.. ) // etc I feel like this is an overkill. Is there a way to create one connection, say in express

Heroku can't find server.js

余生颓废 提交于 2020-01-06 05:58:24
问题 I'm having problems figuring out why Heroku can't find my server.js file under the 'app' folder which is where it's looking for it. I have followed the following steps more than once: 1. Deleted the existing .git folder and the existing Heroku respository. I then init a new git respository and created a new Heroku respository and push to Heroku. Here are my docs: server.js const express = require('express'); const app = express(); const path = require('path'); app.use(express.static(__dirname