Thursday, 2 January 2020

Mongo query using value that was serialized

I'm creating a child process to which I'm sending a serialized request. Request is parsed inside child process and some of its fields are needed to do mongo operations, but queries are not retrieving any values. Queries work fine with same values from unserialized request.Didn't help, but tried using:req.facilityId = mongoose.Types.ObjectId(req.facilityId), // loader.js const cp = require('child_process') exports.addExcel = async(req, res, next) => { req.objects.userId = req.objects.session.userId; req.objects.facilityId = req.params.facilityId; req.objects.file = req.file; const serializedObj = JSON.stringify(req.objects) try { let worker = cp.fork('./utils/excelHelper.js'); worker.send(serializedObj) } catch (error) { console.error(error) } } // childProcess.js const mongoose = require('mongoose'); const Facility = require('../models/facility'); (async () =>{ try { process.on('message', async function(serializedObj) { console.log('Object received in ExcelHelper:'); let req = JSON.parse(serializedObj); req.facilityId = mongoose.Types.ObjectId(req.facilityId), // findOne not working here, but working // if value was never serialized: let facility = await Facility.findOne({_id: req.facilityId}); doSomething(facility); }); } catch (e) { console.log(e); } })()

Submitted January 02, 2020 at 02:06PM by 81mv

I know this pain all too well

https://i.redd.it/rnqfbm0i8d841.png

Submitted January 02, 2020 at 01:21PM by hi-to-all

AdminBro v1.6 released with bulk actions and custom pages

https://medium.com/@wojciechkrysiak/adminbro-v1-6-released-with-bulk-actions-and-custom-pages-65fafe5b27a8

Submitted January 02, 2020 at 12:24PM by hotcto

AdminBro - a Modern Admin Panel for Node JS | React based Admin Panel

https://www.inkoop.io/blog/adminbro-a-modern-admin-panel-for-node-js/

Submitted January 02, 2020 at 11:56AM by jitendra_nirnejak

Wednesday, 1 January 2020

Access control - what's your favorite library for permission? (I recommend CASL)

https://medium.com/teamzerolabs/rbac-vs-abac-in-node-js-backend-321a426faae2

Submitted January 02, 2020 at 02:41AM by jack-tzl

iam-policies: Custom role creation package and permission matching. Looking for feedback.

https://www.npmjs.com/package/iam-policies

Submitted January 02, 2020 at 02:42AM by RoggerV

Node mocha tests exit in vscode, but hang in shell...? (might be a weird wasm/emscripten issue?)

I've spent a couple days on this (total node.js noob) and can't figure it out.I'm building an emscripten-compiled version of PCRE2. Something in the import/require of the .js wrapper of the compiled module is causing node to behave differently in vscode vs. shell.My tests run to completion and exit properly when invoked through a vscode launch task, but will hang for 80-90 seconds before exiting if run from command line (using the same command line as the vscode launch task).I've traced into mocha and confirmed that both invocations eventually call exitMocha in run-helpers.js. I think my mocha.opts are okay (ie. I didn't forget --exit).The most obvious difference in invocations is that vscode includes a --inspect-brk, but doing the same from the command line and debugging through chrome://inspect doesn't yield a clean exit.Code is at https://github.com/stephen-riley/pcre. Any hints are welcome!

Submitted January 02, 2020 at 01:23AM by TheFirstDogSix