node.js

Mongoose & Express: How to properly Remove, Create & Store data that are reference

心不动则不痛 提交于 2021-02-10 20:10:20
问题 The first problem I am having is that whenever I try to delete the Comment, I also try to find the index of that specific comment inside post.comments as well as inside user.comments , it consistently returns -1, the reason why I am trying to find it, is so that I can splice it from the comments array that user and post do have. The second problem I am having is that whenever I create a comment, I try to store it in the comments array that user and post have, but it stores it only as a string

Heroku build failing on dependency install

雨燕双飞 提交于 2021-02-10 19:51:52
问题 Node Canvas isn't installing on Heroku build, even though it works just fine on my own PC. I'm on nodejs version 12.16.3. I can't find a solution for this anywhere. Canvas is a must, and I've never seen this error before until Heroku. Is this a problem with Heroku or a problem with my package/package-lock files? My Discord is Tom Becker#0590 in case you need it. Here's my build log: -----> Node.js app detected -----> Creating runtime environment NPM_CONFIG_LOGLEVEL=error NODE_ENV=production

Trust self-signed certificates — Node JS, Aurelia

♀尐吖头ヾ 提交于 2021-02-10 19:38:19
问题 Using Aurelia, backed is using self signed certificate and NodeJS refuses to forward requests over HTTPS if the certificate is not trusted. [HPM] Error occurred while trying to proxy request /rest/open/test/test-por tal-url=abcdsdf/ui-settings from localhost:9000 to https://localhost:9443 (DEPTH_ZERO_SELF_SIGNED_CERT) (https://nodejs.org/api/errors.html#errors_common_system_errors) Tried process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0; but I'm getting "process is not defined". Also, tried to

How to avoid two concurrent API requests breaking the logic behind document validation?

♀尐吖头ヾ 提交于 2021-02-10 18:56:21
问题 I have an API that in order to insert a new item it needs to be validated. The validation basically is a type validator( string , number , Date , e.t.c) and queries the database that checks if the "user" has an "item" in the same date, which if it does the validation is unsuccessful. Pseudocode goes like this: const Item = require("./models/item"); function post(newDoc){ let errors = await checkForDocErrors(newDoc) if (errors) { throw errors; } let itemCreated = await Item.create(newDoc);

How to avoid two concurrent API requests breaking the logic behind document validation?

非 Y 不嫁゛ 提交于 2021-02-10 18:54:43
问题 I have an API that in order to insert a new item it needs to be validated. The validation basically is a type validator( string , number , Date , e.t.c) and queries the database that checks if the "user" has an "item" in the same date, which if it does the validation is unsuccessful. Pseudocode goes like this: const Item = require("./models/item"); function post(newDoc){ let errors = await checkForDocErrors(newDoc) if (errors) { throw errors; } let itemCreated = await Item.create(newDoc);

How to avoid two concurrent API requests breaking the logic behind document validation?

不问归期 提交于 2021-02-10 18:54:34
问题 I have an API that in order to insert a new item it needs to be validated. The validation basically is a type validator( string , number , Date , e.t.c) and queries the database that checks if the "user" has an "item" in the same date, which if it does the validation is unsuccessful. Pseudocode goes like this: const Item = require("./models/item"); function post(newDoc){ let errors = await checkForDocErrors(newDoc) if (errors) { throw errors; } let itemCreated = await Item.create(newDoc);

How to avoid two concurrent API requests breaking the logic behind document validation?

纵饮孤独 提交于 2021-02-10 18:53:45
问题 I have an API that in order to insert a new item it needs to be validated. The validation basically is a type validator( string , number , Date , e.t.c) and queries the database that checks if the "user" has an "item" in the same date, which if it does the validation is unsuccessful. Pseudocode goes like this: const Item = require("./models/item"); function post(newDoc){ let errors = await checkForDocErrors(newDoc) if (errors) { throw errors; } let itemCreated = await Item.create(newDoc);

Server automatically getting closed and facing 'ERR_STREAM_WRITE_AFTER_END' error along with data sending every time to client

帅比萌擦擦* 提交于 2021-02-10 18:36:58
问题 I am trying to get real-time data using Server-Sent Events from the Database Mysql and sending the value to the client Reactjs. Here is the code: server.js const mysql = require('mysql'); const app = require('express')() const fetch = require('node-fetch'); const con = mysql.createConnection({ host: 'localhost', user: 'root', password: 'root', database: 'databasetest', }); var increment = 0; app.get('/stream/:abc/:qwe', (request, response) => { console.log(`Request url: ${request.url}`); var

Node-gyp. MSBuild.exe` failed with exit code: 1

心已入冬 提交于 2021-02-10 18:36:20
问题 I was trying to install sharp module, which requires: c++ compiler - I downloaded Visual Studio 2017 and visual c++ build tools node-gyp - It was installed successfully But running 'npm install -g sharp' I got many errors gyp ERR! stack Error: E:\VS\MSBuild\15.0\Bin\MSBuild.exe failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Users\MyUsername\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\li \build.js:258:23) gyp ERR! stack at emitTwo (events.js:125:13) gyp ERR!

Trying to run concurrently (npm ERR! code ELIFECYCLE npm ERR!)

僤鯓⒐⒋嵵緔 提交于 2021-02-10 18:30:31
问题 I am trying to create a Full Stack Node & Vue application that takes data from an API. I am running into an issue where I am trying to run both the client and server concurrently but the code is running into an error. Please bear with me if I am structuring this question wrong as I am still fairly new to coding! This is the following error log: [0] Error occurred when executing command: npm run server [0] Error: spawn cmd.exe ENOENT [0] at Process.ChildProcess._handle.onexit (internal/child