express

TypeError: db.findWConditionandler is not a function MongoDB

扶醉桌前 提交于 2020-05-09 17:13:09
问题 This is actually a continuation of my previous question and I'm reasking as I've realised I didn't quite ask the question problem and now I have a different error response. This is in db.js, a separate file while I have the handlers. Context: I return func like this so that in my index.js, I can continue to perform mongodb sort operation to find users with the smallest timestamp! In my server console, I get this response. TypeError: db.findWConditionandler is not a function I'm not sure what

Download xlsx from S3 and parse it

百般思念 提交于 2020-05-08 03:19:18
问题 I need a service to download an excel file from Amazon S3, then parse with node-xlsx The problem is that I can't get xlsx to parse the file. When I try to read back the file I just wrote, it isn't found by the code. I'm not quite sure if this is the best approach, but this is what I got so far: router.get('/process', (req, res) => { var fileName = 'https://some-bucket.s3.amazonaws.com/some-excel-file.xlsx' https.get(fileName, response => { var body = '' response.on('data', chunk => body +=

Download xlsx from S3 and parse it

空扰寡人 提交于 2020-05-08 03:18:14
问题 I need a service to download an excel file from Amazon S3, then parse with node-xlsx The problem is that I can't get xlsx to parse the file. When I try to read back the file I just wrote, it isn't found by the code. I'm not quite sure if this is the best approach, but this is what I got so far: router.get('/process', (req, res) => { var fileName = 'https://some-bucket.s3.amazonaws.com/some-excel-file.xlsx' https.get(fileName, response => { var body = '' response.on('data', chunk => body +=

Download xlsx from S3 and parse it

本小妞迷上赌 提交于 2020-05-08 03:16:21
问题 I need a service to download an excel file from Amazon S3, then parse with node-xlsx The problem is that I can't get xlsx to parse the file. When I try to read back the file I just wrote, it isn't found by the code. I'm not quite sure if this is the best approach, but this is what I got so far: router.get('/process', (req, res) => { var fileName = 'https://some-bucket.s3.amazonaws.com/some-excel-file.xlsx' https.get(fileName, response => { var body = '' response.on('data', chunk => body +=

__dirname is not working in node js with webpack bundling

拜拜、爱过 提交于 2020-05-08 03:01:35
问题 My current directory is D:\bkp\Programming\TestWorks\nodejs\testApp but when i am using __dirname and trying to show a file with express server it gives me this error Error: ENOENT: no such file or directory, stat 'D:\views\index.html' my code for that is res.sendFile(__dirname + 'views/index.html'); when i am bundling it with webpack and run the bundle file then this happens. Otherwise if i just run the normal app.js file it works fine. Help would be appreciated. 回答1: This is because webpack

__dirname is not working in node js with webpack bundling

六眼飞鱼酱① 提交于 2020-05-08 03:00:51
问题 My current directory is D:\bkp\Programming\TestWorks\nodejs\testApp but when i am using __dirname and trying to show a file with express server it gives me this error Error: ENOENT: no such file or directory, stat 'D:\views\index.html' my code for that is res.sendFile(__dirname + 'views/index.html'); when i am bundling it with webpack and run the bundle file then this happens. Otherwise if i just run the normal app.js file it works fine. Help would be appreciated. 回答1: This is because webpack

express server doesn't start after adding checkSchema from express-validator

戏子无情 提交于 2020-04-30 07:04:15
问题 I'm working on an old express server, I was using check from express-validator and it works fine. But I have a post request where the body fields are nested and I need to validate them, so I'm trying to use checkSchema. Apparently its included in the new version, so i upgraded express and express-validator "express": "^4.17.1", "express-validator": "^6.4.0", But when I added checkSchema to my function (code below), the server does not start anymore. When i comment it, it works fine. my import

express server doesn't start after adding checkSchema from express-validator

早过忘川 提交于 2020-04-30 07:03:38
问题 I'm working on an old express server, I was using check from express-validator and it works fine. But I have a post request where the body fields are nested and I need to validate them, so I'm trying to use checkSchema. Apparently its included in the new version, so i upgraded express and express-validator "express": "^4.17.1", "express-validator": "^6.4.0", But when I added checkSchema to my function (code below), the server does not start anymore. When i comment it, it works fine. my import

What structure for create tree category and set in posts is better? and find posts by selected category in MERN

∥☆過路亽.° 提交于 2020-04-30 06:37:07
问题 I'm using MERN to develop my project, I have tree category with this structure: {id: { type: Number }, parent_id: { type: Number }, name: { type: String }, sub: { type: Boolean }} for example : { "_id": "5dfa22dbb04cee3960868fd8", "id": 1, "name": "Code", "parent_id": 0, "sub": true, "__v": 0 }, { "_id": "5dfa2358b04cee3960868fda", "id": 101, "parent_id": 1, "name": "JavaScript", "sub": true, "__v": 0 }, { "_id": "5dfa68735dc1004134b259ab", "id": 1001, "parent_id": 101, "name": "React", "sub"

Node.js: What's a good way to automatically restart a node server that's not responding?

橙三吉。 提交于 2020-04-29 09:55:50
问题 I've inherited a node.js/Express app that is a bit of a mess. It's regularly and fairly randomly getting stuck and not responding to any request until it is restarted. I suspect that something within the app is blocking and either getting stuck in a loop or making a request to an external api without using proper Async techniques, and never getting a response and never timing out at witch point the server just stops responding but doesn't crash. I would obviously like to find the culprit code