https://ift.tt/2xO01P9
Submitted October 01, 2018 at 07:42AM by jsloverr
Sunday, 30 September 2018
7 JavaScript Frameworks/Libraries to Look Out For
https://ift.tt/2rd36nN
Submitted October 01, 2018 at 05:58AM by mydevskills
Submitted October 01, 2018 at 05:58AM by mydevskills
Write 1 million times
I see there's an example on the documentation for this but I was wondering if there was a faster way? To write a million + times to a filefunction writeOneMillionTimes(writer, data, encoding, callback) { let i = 1000000; write(); function write() { let ok = true; do { i--; if (i === 0) { // last time! writer.write(data, encoding, callback); } else { // see if we should continue, or wait // don't pass the callback, because we're not done yet. ok = writer.write(data, encoding); } } while (i > 0 && ok); if (i > 0) { // had to stop early! // write some more once it drains writer.once('drain', write); } } }
Submitted October 01, 2018 at 02:59AM by jsscrub
Submitted October 01, 2018 at 02:59AM by jsscrub
DNS rebinding protection for Express.js
https://ift.tt/2ujFyCv
Submitted September 30, 2018 at 11:35PM by brannondorsey
Submitted September 30, 2018 at 11:35PM by brannondorsey
Help needed to decide between MongoDB vs PostgreSQL
Hi, I am trying to decide which DB to choose for my application. I know it is a big decision therefore I will really appreciate your help. Even though I heard PostgreSQL is better than MongoDB in relational data, my tests always gave me faster results with MongoDB. I am trying to understand and decide which database to choose. I setup a github repo at https://ift.tt/2xORBal All methods and tests are same for both MongoDB and PostgreSQL.Following test commands were madeTesting all: npm testTesting MongoDB: npm run test-mongodbTesting PostgreSQL: npm run test-postgreMongoDB version uses Mongoose and PostgreSQL version uses Sequelize.I will appreciate any comments or corrections. Thanks.
Submitted September 30, 2018 at 10:59PM by Lapter
Submitted September 30, 2018 at 10:59PM by Lapter
Microservices With Node.js
https://ift.tt/2NSXLk1
Submitted September 30, 2018 at 11:18PM by jonathanbrizio
Submitted September 30, 2018 at 11:18PM by jonathanbrizio
node-rem - Rest Express MongoDB in typescript - and more: passport, JWT, socket.io, HTTPS, HTTP2, async/await, etc.
No text found
Submitted September 30, 2018 at 07:45PM by comart
Submitted September 30, 2018 at 07:45PM by comart
How to check from frontend if registration was successful in node backend
Hello, I want to check, if user was succesfully registered in node-expess-mongodb. When username is already in db, "status" is changed to false to stop registration and req.session.registrationStatus is set to false, to send info to front end with POST route. If username is unique, user is registered.I have problem, that although it is sort of working, status from req.session.registrationStatus is one step behind real registrationStatus. So registrationStatus is true (but only after second POST connection with db), but I cannnot see where is error. Thank youBackend:// Route to register user app.post("/register", (req, res, next) => { let username = req.body.content.username; let password = req.body.content.password; let status = true; //status to check if user is already registered db.collection("users") .find() .toArray(function(err, result) { for (let i = 0; i < result.length; i++) { if (result[i].username === username) { console.log("User already registered"); status = false; req.session.registrationStatus = false; //this info is send to frontend req.session.save(); return status = false; } } if (status === true) { bcrypt.hash(password, 10).then(function(hashedPassword) { db.collection("users").insertOne( { username: username, password: hashedPassword }, (err, result) => { if (err) return console.log(err); console.log("saved"); req.session.registrationStatus = true; //this let frontend notify that user was registered req.session.save(); } ); }); } }); }); // Route to check registration app.get("/register/check", (req, res) => { res.send({ registrationStatus: req.session.registrationStatus }); req.session.registrationStatus = false; //registrationStatus is reset to default false value after sending info to frontend req.session.save(); }); Frontend: handleSubmit(event) { post("/register", {username: this.state.username, password: this.state.password}) setTimeout(this.checkRegistration(), 600) event.preventDefault(); } checkRegistration() { const url = "http://localhost:3000/register/check"; fetch(url, { method: "GET", credentials: "include" }) .then(response => response.json()) .then(status => (status.registrationStatus) ? this.setState({ status: "registered." }) : this.setState({ status: "try again." }) ); } Even if user was registered, first response from node is "false" although it should be true.
Submitted September 30, 2018 at 07:06PM by berbebor
Submitted September 30, 2018 at 07:06PM by berbebor
Is your password common enough ?
Hey guys! I have recently published my NPM package called leaked sh npm install leaked Please give it try :)
Submitted September 30, 2018 at 07:27PM by TheRahulShaw
Submitted September 30, 2018 at 07:27PM by TheRahulShaw
PRESENTASI - CODING DI SERVER DENGAN NODE.JS - Coding Videos
https://ift.tt/2NQE7F3
Submitted September 30, 2018 at 06:38PM by ICYMI_email
Submitted September 30, 2018 at 06:38PM by ICYMI_email
How to create a web application using Node.js and Express.js - Part 3 - Coding Videos
https://ift.tt/2y1aENY
Submitted September 30, 2018 at 06:48PM by ICYMI_email
Submitted September 30, 2018 at 06:48PM by ICYMI_email
Better use of middleware
https://ift.tt/2NRpphl
Submitted September 30, 2018 at 06:53PM by rjoydip
Submitted September 30, 2018 at 06:53PM by rjoydip
Front-End Software Developer (Node.js & React) - Symless Careers
https://ift.tt/2xZcY8h
Submitted September 30, 2018 at 06:43PM by ICYMI_email
Submitted September 30, 2018 at 06:43PM by ICYMI_email
How do you structure your project by components if you are using mongoose as your orm?
I was browsing through the node best practices guide, and came across this issue. In all of my projects, I have had my models tightly couple to mongoose. It says there that"The major principle should be keeping your DAL as a data-mapper that maps domain entities into DB and NOT owning the canonical application entities. In other words, you have the domain models, simple JS objects that are agnostic to any DB concerns, which are the heart of the system - the DAL is responsible to serialize this model into DB. If you use ORM than that DAL will use its own internal models for the mapping. "I am a moderate expressjs developer and I am not sure how to do this using mongoose. Could someone help, if possible using code samples? Thanks in advance!
Submitted September 30, 2018 at 04:41PM by strawberrycandies
Submitted September 30, 2018 at 04:41PM by strawberrycandies
Help downloading file and using readline async
I can't get the codes in an async way. Comes up with empty arrayapp.jsconst argv = require('minimist')(process.argv.slice(2)); const appManager = require('./appManager/appManager.js');start(); function start(){ appManager.start(argv); }appManager.jsconst doanloadFile = require('../catalog/downloadFile.js'); const fileUtils = require('../utils/fileUtils.js'); const appConfig = require('../config/appConfig.json');async function start(args) { const result = await downloadFile.downloadFile(catalogTxtUrl, filename); console.log('result path: ' + result); const codes = await downloadFile.getCodes(result); console.log(codes); return 'start'; }async function getUrlPath(args) { let urlPath; // do we have file to start with or link if (args.l) { urlPath = args.l; } else { urlPath = await scraper.getLink(appConfig.url); } return urlPath; } module.exports.start = start;downloadFile.jsconst request = require('request'); const readline = require('readline'); const fs = require('fs'); async function downloadFile(urlToFile, filename) { const download = await request({ url: urlToFile, followAllRedirects: true }).pipe(await fs.createWriteStream(filename)); return download.path; };async function getCodes(filename) { return new Promise((resolve, reject) => { const codes = []; const rl = readline.createInterface({ input: fs.createReadStream(filename), crlfDelay: Infinity }); console.log('after const readline' + rl); rl.on('line', (line) => { console.log('line ' + line); const code = reCode.exec(line); if (code) { codes.push(code[0].replace(/ /g, "")); } }); console.log('before close'); rl.on('close', () => { console.log('in close'); resolve(codes); }); }); }module.exports.getCodes = getCodes; module.exports.downloadFile = downloadFile;
Submitted September 30, 2018 at 01:52PM by jonny_3000
Submitted September 30, 2018 at 01:52PM by jonny_3000
Ever wondered how to call git, c++ or python through a Node.JS script? Check out this awesome article about child_process!
https://ift.tt/2OZSaEW
Submitted September 30, 2018 at 01:40PM by dabomb007
Submitted September 30, 2018 at 01:40PM by dabomb007
Build a blog with Cogear.JS
Cogear.JS is a modern static websites generator, built with Node.JS and based on Webpack.It's frontend-framework agnostic. So you can use it either with Vue.JS, React, Angular, etc. or without it.To learn more about it, read recent article on Reddit.Today will learn how to build a blog with Cogear.JS.InstallationMake sure to fit the requirements.To install Cogear.JS do next:$ npm install -g cogear # or $ yarn global add cogear https://www.youtube.com/watch?v=UwWsSnFS0g0https://i.redd.it/asuuwg75ycp11.jpgBlog craftingWe need to transform default site into a blog.It requires two things:Blog plugin.Blog theme.There is a standard way via built-in generator:$ cd ~/Sites $ cogear new blog https://www.youtube.com/watch?v=fweOYQ-_FU0https://i.redd.it/8k124sw9ycp11.jpgBut I've prepared a preset for you which includes both plugin and theme.https://ift.tt/2IsiEMU install a blog with preset.$ git clone --recurse-submodules https://ift.tt/2Rd1RRL blog Now you need to install the dependencies:$ cd ~/Sites/blog $ npm install # of $ yarn install DoneThat was all you have to do.Now fire up Cogear.JS in the development mode.$ cogear You blog is ready: Cogear.JS blogI've uploaded the result to: https://ift.tt/2IrM9hD it out.https://ift.tt/2RhMtDY time to create the first post.Create ./src/pages/p/first-post.md file with the following content:--- title: First post tags: - news --- # This is my first post! Well done. Save it and browser page will be reloaded automatically.Cogear.JS blog with postThe result is also available by link: https://cogear-blog-with-post.now.shhttps://i.redd.it/dgb6em9zycp11.pngP.S. Why p folder has been chosen for a blog?It's easy to customize this behavior.Edit ./config.yaml file from thistitle: Blog | Cogear.JS – modern static websites generator description: keywords: theme: blog blog: index: "" regex: "^p/" tagUri: 'tag' perPage: 5 pages: ^p/: layout: post author: login: Dmitriy Beliaev avatar: 'https://ift.tt/2ItaVhx' link: https://cogearjs.org to thattitle: Blog | Cogear.JS – modern static websites generator description: keywords: theme: blog blog: index: "" regex: "^blog/" tagUri: 'tag' perPage: 5 pages: ^blog/: layout: post author: login: Dmitriy Beliaev avatar: 'https://ift.tt/2ItaVhx' link: https://cogearjs.org And rename folder ./src/pages/p to ./src/pages/blog.More about the config file in the following video:https://www.youtube.com/watch?v=hEUgZcoFKWMhttps://i.redd.it/k2p234hfycp11.jpgYour questions are welcome!
Submitted September 30, 2018 at 12:02PM by CogearJS
Submitted September 30, 2018 at 12:02PM by CogearJS
Being productive with node.js when coming from statically type languages like Java and C#?
The majority of my development career of building enterprise applications I’ve used Java and C#. I’ve always felt productive in these languages due to it being statically typed and the IDEs being able to give very accurate auto completion and immediate syntax errors. I really like JavaScript and Node, but missing the productivity I felt when using NetBeans and Visual Studio. I’m using Visual Studio Code for my development. Any suggestions or experiences you’ve been through to get more productive when writing JavaScript and Node applications?
Submitted September 30, 2018 at 12:09PM by le-brute
Submitted September 30, 2018 at 12:09PM by le-brute
How to write production-ready Node & express app
https://ift.tt/2RetMRF
Submitted September 30, 2018 at 10:57AM by banna2
Submitted September 30, 2018 at 10:57AM by banna2
The web built using node and vue, imitate Twitter's UI and features.
Project LinkThis project is built using Node and Vue.The target is learning Vue framework and technique of backend to implement a SPA website.All right of picture and sign is reserved for Twitter.Used techniques, tools and packages by this project are not actually used by Twitter.Welcome technical exchange, if this project has mistake of code or concept of programming, let me know, thanks
Submitted September 30, 2018 at 10:58AM by JayChang84
Submitted September 30, 2018 at 10:58AM by JayChang84
Saturday, 29 September 2018
Css help please..IM NEEWW
**Award StylesGo to the Award Styles section. In this section, you will create styles for the list of awards won by Pandaisia Chocolates. Information boxes for the awards are placed within the div element with ID #awardList. Create a style rule for this element that places it using relative positioning, sets its height to 650 pixels, and automatically displays scrollbars for any overflow content.Every information box in the #awardList element is stored in a div element belonging to the awards class. Create a style rule that places these elements with absolute positioning and sets their width to 30%.Position the AwardsPosition the individual awards within the #awardList box by creating style rules for the div elements with id values ranging from #award1 to #award5 at the following (top, left) coordinates:#award1: (80px, 5%)#award2: (280px, 60%)#award3: (400px, 20%)#award4: (630px, 45%)#award5: (750px, 5%)(Hint: In the pc_specials.html file, the five awards have been placed in a div element belonging to the awards class with id values ranging from #award1 to #award5).****Here is my Code**/* Award Styles */div#awardList {position: relative;height: 650px;overflow: auto;}div#awardslist[class^="awards"]>ul{position: absolute;width: 30%}div.awards>div#award1 {top: 80px;left: 5%;}div.awards>div#award2 {top: 280px;left: 60%;}div.awards>div#award3 {top: 400px;left: 20%;}div.awards>div#award4 {top: 630px;left: 45%;}div.awards>div#award5 {top: 750px;left: 5%;}
Submitted September 30, 2018 at 03:31AM by fredfred18
Submitted September 30, 2018 at 03:31AM by fredfred18
newbie question: issue with using "this" within promise
Hey guys,Sorry for the newbie question. This question will definitely expose my lack of understanding of javascript classes.So I'm trying to write a class with methods that return a promise. It seems that within the promise function, the "this" operator no longer refers to the class but is undefined.Here is a useless class that demonstrates what I am talking about:class foo { constructor(data) { this.bar = data; } set(data) { return new Promise(function(fulfill, reject) { this.bar = data; fulfill(); }); } }So obviously this is a fake example but "this" in foo.set no longer refers to foo when in the promiseThanks!!
Submitted September 30, 2018 at 03:12AM by thenewstampede
Submitted September 30, 2018 at 03:12AM by thenewstampede
newbie question about nodejs classes and promises
Hey guys!Really sorry for this newbie question about nodejs. I've started looking into how classes are done in nodejs and I had a question.Are there some general guidelines for when to use or not use promises in a class? For example, would it be bad practice for a class method to return a promise? I was looking around at example code for classes in nodejs and it doesn't seem that this is something people do.For example, is there anything wrong with this:class User {constructor(name) { this.name = name; }do_a_promise() { return new Promise(function(fulfill, reject) { console.log("hello world"); fulfill(); }); }This is just a dumb example but is there any reason that you would definitely not want a method to return a promise?edit: sorry for the formatting. I couldn't get the formatting to look quite right.
Submitted September 30, 2018 at 01:05AM by thenewstampede
Submitted September 30, 2018 at 01:05AM by thenewstampede
Node.js ¡En Vivo! - Desmitificando el Event Loop
https://ift.tt/2xWMlAQ
Submitted September 29, 2018 at 06:58PM by stevenscol
Submitted September 29, 2018 at 06:58PM by stevenscol
Topics for node course
Hello r/node,I've been node programmer for a little over a year now and want to make a course on it. What do you think what are some essential topics to put in it. I was thinking of something like introducing JavaScript, installing node, making a console app, making server in pure node, making server in express, deploying it, go over basics of git and Docker, and deployment. Maybe put some testing in it. Of course by making server I would go over HTTP, HTTPS,static content, template engines, clusters, sessions, cookies, databases, authentication, authorization and working with third party API's.
Submitted September 29, 2018 at 06:01PM by AthosBlade
Submitted September 29, 2018 at 06:01PM by AthosBlade
How does thread pool work in node.js?
https://ift.tt/2y2ssrU
Submitted September 29, 2018 at 03:19PM by rjoydip
Submitted September 29, 2018 at 03:19PM by rjoydip
Build a Sentiment Analysis API using Node.js
https://ift.tt/2DGKLcB
Submitted September 29, 2018 at 11:53AM by mubumbz
Submitted September 29, 2018 at 11:53AM by mubumbz
Huge noob question, I'm at a loss.
Hey all,I just picked up node.js and I'm trying to practice messaging between a server and client. I'm sending intentionally segmented JSON messages from the server and having the client reconstruct them. I'm just doing it for practice and to get an intuition of things in general. I'm stuck because I'm sending two JSON messages segmented into four separate connection.write()s, but the last message doesn't seem to be seen/assembled by the client. I'm going crazy and it's probably something dumb/easy. (See attached pic)If anyone could help, I'd be so happy. Thanks a lothttps://ift.tt/2xUZoCO
Submitted September 29, 2018 at 08:11AM by plantation_slave
Submitted September 29, 2018 at 08:11AM by plantation_slave
Friday, 28 September 2018
Is it just me or is file storage a major bottleneck for small projects?
Specifically, deploying on Heroku and other 1-button-setup services which have ephemeral storage. As a dev who wants to focus on dev and not ops but wants to deploy some small projects for portfolio and other small use cases.Fair enough, this teaches you the hard way that file storage and the server should not go together. And it feels like at this point you truly are near the end of mastering node/express, and this is probably one of the last nitty-gritty gotchas that's gonna come up.So, then you look at your options. The only real ones are AWS S3, which forces you to drag the, frankly, criminally disorganized AWS API and documentation into your project or... Cloudinary, the website where advertisements take 50% of the screen and it tries to recruit you into it's referral program upon signup.Anyways, is there some go-to service I am missing here that the veterans know about? The Heroku of file storage services? I like that Cloudinary can grab the req.file.path straight off multer without having to save anything to my server and I like how clean and short the module's method is (actually much cleaner than multer itself) BUT... the way the website looks just throws me off. Doesn't seem trustworthy.Thoughts? Ideas?
Submitted September 29, 2018 at 06:24AM by throwaway_nodejs
Submitted September 29, 2018 at 06:24AM by throwaway_nodejs
[Help] Not able to save files from Axios request chain
Hi All: As the title says!Essentially, i am not sure how to save the chunks of data being stored in totalData using available node modules without having a corrupted file. I am using fs.writeFile("downloads/file.zip", totalData.toString(), 'utf8', function (err) below in my code and a 7.6MB file gets saved, but it doesn't open. it says "unable to expand file.zip"(Error 21 - is not directory)const fs = require('fs'); const axios = require('axios'); // stitch together files const file_url = 'test.come/file.zip' const headerRange = 'bytes='; const headers = ['0-1048575', '1048576-2097151', '2097152-3145727', '3145728-4194304']; async function getFileInChunks() { try { const responseOne = await axios.get(file_url, { 'headers': { 'Range': `${headerRange}${headers[0]}` } }); const responseTwo = await axios.get(file_url, { 'headers': { 'Range': `${headerRange}${headers[1]}` } }); const responseThree = await axios.get(file_url, { 'headers': { 'Range': `${headerRange}${headers[2]}` } }); const responseFour = await axios.get(file_url, { 'headers': { 'Range': `${headerRange}${headers[3]}` } }); axios.all([responseOne, responseTwo, responseThree, responseFour]) .then((responses) => { //verify correct # of requests console.log('got data!', responses.length); const totalData = responses[0].data + responses[1].data + responses[2].data + responses[3].data; // console.log(totalData) fs.writeFile("downloads/file.zip", totalData, 'utf8', function (err) { if (err) { return console.log(err); } console.log("The file was saved!"); }); }) .catch((err) => { console.log(err) }); } catch (error) { console.log(error); } } getFileInChunks()
Submitted September 29, 2018 at 06:50AM by ohmynano
Submitted September 29, 2018 at 06:50AM by ohmynano
The 5 best use cases for the serverless beginner
https://ift.tt/2R3PVSm
Submitted September 29, 2018 at 03:22AM by nshapira
Submitted September 29, 2018 at 03:22AM by nshapira
cmd
I truned my cmd into 'Node.js'how can I bring the default cmd back
Submitted September 28, 2018 at 11:33PM by EDENRP
Submitted September 28, 2018 at 11:33PM by EDENRP
What are some good modules for mapping SQL query results to model objects?
Disclaimer: I'm using TypeScriptI'd like something that maps rows to object attributes with the same name, but also makes it easy to specify the attribute name if necessary (ie when mapping AssignmentID to just id or identifier)
Submitted September 28, 2018 at 08:42PM by ThePantsThief
Submitted September 28, 2018 at 08:42PM by ThePantsThief
[Question] Compression not working
So I have installed NPM package "Compression" into my app and included the following lines per the documentation:var compression = require('compression') var express = require('express') var app = express() app.use(compression()) However, when I run tests it still says gzip is not enabled. I'm not sure what further steps I should have taken or what I missed.Any insight would be greatly appreciated
Submitted September 28, 2018 at 07:20PM by onlyslavesobey
Submitted September 28, 2018 at 07:20PM by onlyslavesobey
IBM Cloud Private adds support for Open Source Java, Node.js
https://ift.tt/2OkSCAz
Submitted September 28, 2018 at 06:30PM by ICYMI_email
Submitted September 28, 2018 at 06:30PM by ICYMI_email
Google Cloud — Usando Datastore em ambiente local Linux/Node.JS
https://ift.tt/2QfgAKM
Submitted September 28, 2018 at 06:40PM by ICYMI_email
Submitted September 28, 2018 at 06:40PM by ICYMI_email
Could a node program be compiled to a C library?
npm nexe can compile a node.js program down to a single (node-independent) executable file, for any target architecture you want (within reason).I'm wondering if it's possible to make something similar, but instead of packaging a program into an executable file, package it into a shared library or DLL, such that a C client can call arbitrary functions that are exported from the node program (not just the main command-line entry point). (Obviously there would be a good amount of glue, marshaling parameters and return values and whatnot, but that could be abstracted away with a nice library.)If this were possible, it would allow us to create language bindings for node libraries.Does anyone understand how nexe works? And/or how possible/practical this idea is?
Submitted September 28, 2018 at 05:16PM by feugene
Submitted September 28, 2018 at 05:16PM by feugene
Node Performance Benchmarks - CPU Upgrade For Data Processing?
Hey Everyone, I'm primarily developing a data-processing heavy nodejs app on my late 2013 macbook pro (2.4 Ghz core i5 haswell 4258U).The problem is that my data set is doing calculations and a lot of regex on hundreds of thousands of items and it's taking FOREVER with my CPU at 99% for node. I know javascript is probably not the most efficient data processing language, but it's what I know. Have already refactored a few times to ensure I'm not running excess operations.Big question is, will I notice a large difference if I setup an Ubuntu workstation running an AMD Ryzen 8 core CPU? Like enough that I'm not waiting hours for this data set to finish, and I can me more productive?I tried running this in Google Cloud Functions and got hit with a $100 bill after only ~20 minutes of testing the data workflow, but it was FAST lol.
Submitted September 28, 2018 at 02:37PM by boon4376
Submitted September 28, 2018 at 02:37PM by boon4376
The Right Idea Becomes the Wrong Idea Over Time
https://ift.tt/2Pj3D23
Submitted September 28, 2018 at 01:52PM by fagnerbrack
Submitted September 28, 2018 at 01:52PM by fagnerbrack
Any good open source time tracking software like Kimai written in JS/Node ?
I really like Kimai but I was wondering if there are similarly good open source tools written in JS.
Submitted September 28, 2018 at 02:03PM by TaskForce_Kerim
Submitted September 28, 2018 at 02:03PM by TaskForce_Kerim
Suggestions for dashboard
I need to build a dashboard based on Zendesk's API. The dashboard will only be making GET requests.. nothing fancy.The dashboard should update itself (making requests) every 30 min. It will pretty much list some metrics based on the tickets in zendesk based on some logic. I would like to use node.js for this.What should be my approach to this? What do you recommend?To access the Zendesk API I will need to use basic auth which I am confident in using but one of my questions is, should the requests to the Zendesk API be made via my app's server side or client side? How should I handle the request to the API considering it needs authentication?
Submitted September 28, 2018 at 02:17PM by its_joao
Submitted September 28, 2018 at 02:17PM by its_joao
Building Node.js Applications inside Docker Containers on Top of Kubernetes
Docker and Kubernetes are great for deploying and running applications but they do not support the development workflow very well. Mounting a project from a local folder into a container, for example, often leads to problems with hot reloading tools like nodemon and make debugging a lot harder. And coding directly on top of Kubernetes is not supported at all at the moment.That's why a colleague from work and I built a small command-line tool that lets you create a remote workspace called DevSpace inside any Kubernetes cluster with just a single command. This DevSpace is connected to your local machine via 2-way code sync (optimized for performance and reliability), port forwarding and terminal proxy. That allows anyone to code and debug locally with their favorite IDE but still build, test and run code directly inside Docker containers running on top of Kubernetes.We decided to make our tool open source, so that everyone can use it: https://github.com/covexo/devspaceWhat do you think about the idea of coding directly inside a Kubernetes cluster? What are your experiences with developing nodejs applications with/for Docker and Kubernetes? Which tools are you using?
Submitted September 28, 2018 at 02:17PM by gentele
Submitted September 28, 2018 at 02:17PM by gentele
Rethinking JavaScript Test Coverage
https://ift.tt/2QfRqvN
Submitted September 28, 2018 at 12:09PM by hfeeri
Submitted September 28, 2018 at 12:09PM by hfeeri
Just have a simple Node.js GraphQL server + PostgreSQL database. Cheap way to host?
https://ift.tt/2zCGTFq
Submitted September 28, 2018 at 12:22PM by impossibletogetagf
Submitted September 28, 2018 at 12:22PM by impossibletogetagf
Anyone had any success using ReJSON with NodeJS? I currently cannot get any of the available module to work.
Any input appreciated.
Submitted September 28, 2018 at 10:22AM by OzziePeck
Submitted September 28, 2018 at 10:22AM by OzziePeck
Offering my services for free for your open source projects
Hello, community!I'm a junior full-stack web dev looking to start contributing to other people's projects. Please check out my portfolio, and do tell me if you have something you need my help with.GitHubCodePen
Submitted September 28, 2018 at 09:54AM by scorpion9979
Submitted September 28, 2018 at 09:54AM by scorpion9979
Overcoming Sequelize Hiccups
https://ift.tt/2NPq3f1
Submitted September 28, 2018 at 08:37AM by jsloverr
Submitted September 28, 2018 at 08:37AM by jsloverr
Thursday, 27 September 2018
Why these are no quality check on the node modules?
I was actually planning on writing a node module myself and when I was benchmarking it I realised that It is not very fast and eventually will slow down the application of who ever uses it. I came across a couple of modules myself which are not very optimized. I am not ranting and sorry If i sound like, I had this question so thought of putting it across and see what others feel and can we come up with a way where we can help each other write or validate there modules for performance issues.
Submitted September 28, 2018 at 06:17AM by soulreaper020693
Submitted September 28, 2018 at 06:17AM by soulreaper020693
Node.js native modules with Swift
Hi there. Has anyone had any experience developing node.js bindings for Swift libraries? There are lots of examples out there for creating bindings for C++ libraries. I feel like Swift should work, but I can't find any documentation or posts out there that suggest this would work. I'm not 100% sure where to get started with this.The closest thing I could find was this: https://ift.tt/2NKeXYJ
Submitted September 28, 2018 at 07:18AM by Dr_Dawwg
Submitted September 28, 2018 at 07:18AM by Dr_Dawwg
[help] Saving result of a Request in a variable
I am creating an app using an API that provides some configuration settings as a json object that I can pull using Request. however, i would like to store this into a var config object in my index.js so I may pass it into any modules that may need the config info, much like the mongoose that i pass around my app.I have only been so far able to use the information in callbacks and a .then callback on a Promise. I have dug through SO and can't find much help on storing this in a way that is useful anywhere else and any guidance is appreciated.
Submitted September 28, 2018 at 12:10AM by marconi_mamba
Submitted September 28, 2018 at 12:10AM by marconi_mamba
GitHub - mitjafelicijan/terrafirma: Minimalistic web app boilerplate with Gulp, Handlebars and Browser-sync
https://ift.tt/2zBS9BR
Submitted September 28, 2018 at 12:21AM by mitja-felicijan
Submitted September 28, 2018 at 12:21AM by mitja-felicijan
Having trouble running node scripts written in ES6...
I'm finding all sorts of confusing advice on the web. I have a script that will include other files from me /app directory, all written in ES6. I have babel configured for my project, but I'm having a hard tie figuring out how to just run the script, process it through babel first. There are mentions of using --harmony flag and such but that isn't working.
Submitted September 27, 2018 at 11:28PM by cheese_wizard
Submitted September 27, 2018 at 11:28PM by cheese_wizard
r/javascript - space-cleaner node package
https://ift.tt/2xXn35u
Submitted September 27, 2018 at 08:39PM by ICYMI_email
Submitted September 27, 2018 at 08:39PM by ICYMI_email
Node-RED Joins the JS Foundation – Code Channels
https://ift.tt/2NNpnqE
Submitted September 27, 2018 at 08:44PM by ICYMI_email
Submitted September 27, 2018 at 08:44PM by ICYMI_email
Fixing the deprecation warnings in MongoDB Node.js API
https://ift.tt/2Ob5I3p
Submitted September 27, 2018 at 09:19PM by tpiros
Submitted September 27, 2018 at 09:19PM by tpiros
Google OAuth, Nodejs and headaches...
So....I have added the following URL as an authorized URL on Google API's account:https://ift.tt/2zzGtiP also have this config:https://ift.tt/2QbXzJ6 it doesn't work. It gives me:https://ift.tt/2zBazTc can see that HEROKU is pointing the callback to HTTP (no S) whereas the authorized URI is HTTPS.I tried changing this on the callbackURI in my code to:proxy:trueor adding the actual HTTPS URL and it kind of works. It won't give me an error but gives me a request timeout error on my heroku logs. It just stays in the logging in with google page and won't budge to the callback URL as if the route is not being handled - but it is, it works on Localhost.Oauth is a headache.. .Does anyone have any idea of what is happening?
Submitted September 27, 2018 at 09:46PM by its_joao
Submitted September 27, 2018 at 09:46PM by its_joao
Hey Reddit, A quick survey (4 questions) about HTTP Framework
https://twitter.com/eranhammer/status/1045376566878859264?s=19
Submitted September 27, 2018 at 07:42PM by yoannma
Submitted September 27, 2018 at 07:42PM by yoannma
Node / socket.io / Heroku / Port issue with deployment - Please help!
require("dotenv").config(); var express = require("express"); var path = require("path"); var bodyParser = require("body-parser"); var exphbs = require("express-handlebars"); var expressValidator = require("express-validator"); var expressSession = require("express-session"); var MSSQLStore = require('connect-mssql')(expressSession); var db = require("./models"); let server; var app = express(); server = require("http").createServer(app); var io = require("socket.io").listen(server); var PORT = process.env.PORT || 8080; server.listen(3000); var config = { user: "root", password: "root", server: "localhost", // You can use 'localhost\\instance' to connect to named instance database: "forumdb", options: { encrypt: true // Use this if you're on Windows Azure } }; // Middleware app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.use(expressValidator()); app.use(express.static(path.join(__dirname, "/public"))); app.use( expressSession({ store: new MSSQLStore(config), key: "user_sid", secret: "JRS", saveUninitialized: false, resave: false }) ); // Handlebars app.engine( "handlebars", exphbs({ defaultLayout: "main" }) ); app.set("view engine", "handlebars"); // Routes require("./routes/apiRoutes")(app); require("./routes/htmlRoutes")(app); require("./routes/loginRoutes")(app); require("./routes/topics-api-routes")(app); require("./routes/users-api-routes")(app); require("./routes/post-api-routes")(app); require("./routes/reply-api-routes")(app); var syncOptions = { force: false }; // If running a test, set syncOptions.force to true // clearing the `testdb` if (process.env.NODE_ENV === "test") { syncOptions.force = true; } // Starting the server, syncing our models ------------------------------------/ db.sequelize.sync(syncOptions).then(function() { app.listen(PORT, function() { console.log( "==> 🌎 Listening on port %s. Visit http://localhost:%s/ in your browser.", PORT, PORT ); }); }); module.exports = app; // CHAT APPLICATION CODE users = []; connections = []; io.sockets.on("connection", function(socket) { connections.push(socket); console.log("Connected: %s sockets connect", connections.length); socket.on("disconnect", function(data) { console.log(data); users.splice(users.indexOf(socket.username), 1); updateUsernames(); connections.splice(connections.indexOf(socket), 1); console.log("Disconnected: %s sockets connected", connections.length); }); socket.on("send message", function(data) { io.sockets.emit("new message", { msg: data, user: socket.username }); console.log(data); }); socket.on("new user", function(data, cb) { cb(true); socket.username = data; users.push(socket.username); updateUsernames(); }); function updateUsernames() { io.sockets.emit("get users", users); } }); If I could get this fixed prior to 5 PM today it would really save my ass. This is my code. Deployed locally, it works perfectly. Socket's is listening on a separate port (3000) and fires accordingly. Deployed on Heroku however, there is an issue with the two ports. I can't figure out how to solve it.Is there anyone that might be able to fix this code so that it deploys correctly on Heroku?
Submitted September 27, 2018 at 06:54PM by DrHughJicok
Submitted September 27, 2018 at 06:54PM by DrHughJicok
[help] move npm logs from /root/.npm/_logs to a different directory
Is there a way to change the destination for these logs? I was pretty surprised to not see any questions about this on stackoverflow already. I don't want to host these logs at root on my server.Is the logging destination set relative to the directory set for process.env.HOMEDRIVE?Help greatly appreciated!
Submitted September 27, 2018 at 06:56PM by RunisLove
Submitted September 27, 2018 at 06:56PM by RunisLove
Sharing session between Express and Socket.io on separate processes? • r/javascript
https://ift.tt/2NO3ebB
Submitted September 27, 2018 at 07:08PM by Hectate
Submitted September 27, 2018 at 07:08PM by Hectate
Level promises/callbacks landscape with promback
https://ift.tt/2OkJdZC
Submitted September 27, 2018 at 07:14PM by rmdmoO
Submitted September 27, 2018 at 07:14PM by rmdmoO
Why is node considered server side?
Node can very well suit for non server side usage, same as Python or Ruby, as a general scripting language platform.Why is Node mostly considered and advertised as server side? I feel it should broaden and promote its use cases.
Submitted September 27, 2018 at 05:58PM by texasbruce
Submitted September 27, 2018 at 05:58PM by texasbruce
Just a question. What do you have to know to be able to say you're "Professional" as a Node Developer?
I've been getting really good at express API's, but I want to go deeper into Node. My end goal is to be a NodeJS back end developer.(Thanks for the early responses, I guess I can honestly say I'm a "Professional" Node Developer. Do NodeJS tasks at work already, but they're completely based on my judgement as I'm the only "Developer" at work. I use the quotes because my title isn't Developer, it's database coordinator.....)Edit: added detail to the question
Submitted September 27, 2018 at 05:59PM by cjrutherford
Submitted September 27, 2018 at 05:59PM by cjrutherford
Node Summit 2018 - NODE.JS APPLICATIVE DOS THROUGH NOSQL INJECTION - Vladimir de Turckheim
https://ift.tt/2N8Xi89
Submitted September 27, 2018 at 04:20PM by ecares
Submitted September 27, 2018 at 04:20PM by ecares
Hey Reddit, I gave a talk on fun yet practical projects you can do in Node.js. Slides, video & code are now up!
https://ift.tt/2xCCFMz
Submitted September 27, 2018 at 03:41PM by umaar
Submitted September 27, 2018 at 03:41PM by umaar
Summer is over — You should be coding, here’s yet another list of exciting ideas to build
https://ift.tt/2N3IOq1
Submitted September 27, 2018 at 03:37PM by thickoat
Submitted September 27, 2018 at 03:37PM by thickoat
[Help] Making a script that downloads a file in chunks
Hi All!I was wondering if any of you had a better idea on how to proceed with making multiple axios calls to download all chunks of a file, this is what I have so far.const file = require('file-system'); const fs = require('fs'); const axios = require('axios'); const file_url = 'https://ift.tt/1srKqxy' axios.get( file_url, { // params: { // ID: 12345 // }, headers: { Range: 'bytes=0-1' } }) .then((response) => { console.log('server status: ', response.status); console.log('server response: ', response.headers); fs.mkdir('downloads/', function(err) {}); fs.writeFile('downloads/example.zip', 'aaa', function(err) {}) // FileDownload(response.data); // console.log(response); // console.log(response.data); }) .catch(function (error) { console.log(error); }); My issue is:I need to make multiple axios requests, but not entirely sure how to make enough requests to download the entire file in chunks.I don't exactly understand how header-range works. Whenever I adjust it to '0-1', it still downloads all 3 bytes of the file, which is the size of the entire file.once I download the entire file in chunks do I need to do it with async await so I can stitch it back together or will it save the chunks on my drive and ill have to run it through my script to stitch it together?all help is appreciated. thank you!
Submitted September 27, 2018 at 02:54PM by ohmynano
Submitted September 27, 2018 at 02:54PM by ohmynano
Node.js Hosting from Jelastic PaaS
https://ift.tt/2xOsqVF
Submitted September 27, 2018 at 11:22AM by MarichkaHepalova
Submitted September 27, 2018 at 11:22AM by MarichkaHepalova
Build a Lead Generator in 5 Minutes with Typeform, Clearbit, Airtable and Standard Library
https://ift.tt/2DAu0Qd
Submitted September 27, 2018 at 08:06AM by J-Kob
Submitted September 27, 2018 at 08:06AM by J-Kob
Become an Expert Nodejs Developer While Building Real World Applications
You love this! . You have read and watched so many tutorials on node.js and this is by far the best.Those who have a tiny experience with nodejs based on small videos in you tube, so the information goes well for them.Very suited for beginners who are beginning to dip their toes or want to learn more about these subjects. Well explained, and very responsive on the Q&A forums.So far this seems to be the perfect starting point , and many of the projects relate to elements you intend to tie into your own project. Hopeful this will set you on the right path.It Includes12.5 hours of videoFull lifetime accessAccess on mobile and TVCertificate of Completion49 Downloadable resourcesyou can enroll here : https://www.udemy.com/learn-nodejs-by-building-10-projects/?couponCode=SEPJA10
Submitted September 27, 2018 at 07:34AM by docksonpaul
Submitted September 27, 2018 at 07:34AM by docksonpaul
Wednesday, 26 September 2018
What exactly is nodejs ? A must read article.
https://ift.tt/2J9W1fn
Submitted September 27, 2018 at 12:21AM by hamsa_hiennv
Submitted September 27, 2018 at 12:21AM by hamsa_hiennv
Promise error
``` const Influx = require('influx') const si = require('systeminformation');const influx = new Influx.InfluxDB('https://ift.tt/2O8GW3V siInfo = si.getAllData((data) => { console.log('Pulling Data') });siInfo .then(result => console.log(result.os.hostname)) .then(result => influx.writePoints([ { measurement: 'promise test', tags: { host: result.os.hostname }, fields: { cpu: parseInt(21), mem: parseInt(434523) }, } ]) ) .catch(err => console.log('Error', err.message));```Can anyone help me? Im trying to get the hostname pushed to the DB, i can console.log it but when i call it inside the field i get an error.."Pulling DataDESKTOP-GTE5ISFError - Cannot read property 'os' of undefined''
Submitted September 27, 2018 at 01:22AM by rendsolve
Submitted September 27, 2018 at 01:22AM by rendsolve
Cogear.JS — modern static website generator (Node.JS/Webpack)
Cogear.JS is a static websites generator built with Node.JS (9.x or higher) and based on Webpack (v4.6).It's inspired by Jekyll and others, but built on the top of the latest frontend technologies.Provides awesome hot reloading experience in development mode.https://ift.tt/2ONnxSR video on YouTubeFeatures🖥 Modern stack of technologiesBuild modern static websites with bundled scripts and styles.Rapidly prototype and instantly deploy to the server.Use any modern frontend stack (webpack bundled) – Vue.JS, React, Angular, Ember, etc.🚀 Blazing fast and reliablePerforms nearly 1.000 pages per second (depends on the pages content and raw computer processor power).Server can handle thousands requests per second to serve static files (even on tiny VPS).📦 For any hostingDoesn't requires any database (data stored in flat files) and works with any hosting (as it produces static html and assets files).🚚 Deploy built inCreate a preset and update your site to the server via FTP, SFTP or even rsync.🔓 Secure. No updates neededJust forget about annoying regular updates from usual CMS.It's 100% secure for hacking because there is no backend after being deployed to the server.🌏Free. Open SourcedUse it for free. For any needs. Forever.Github Pages (or any similar project) you can host generated site for free.What it can be used for:Rapid site prototypingPortfolio siteCompany siteProduct sitePersonal blogArtist or musician siteAny site that has admin-generated content.Multi-user content management can be provided via Github. Just store your source in the repository, accept pull-requests from other users and build a site after commits (can be automated).Using Firebase or any other backend, written in any lang (PHP, Ruby, Python, Node.JS) or even with CMS like a WordPress, with help of modern frontend technologies like Vue.JS or React, it can be turned into more dynamic site like e-commerce, products catalog and so on.What it cannot be used for:ForumSocial networkChatOr any other site type with great amount of user-generated content which relies on heavily database usage and dynamically generated pages.Of course you can try, but it has to be modern SPA which handles data from dedicated API.RequirementsYou have Node.JS (9.x or higher) and NPM (usually comes together) to be installed.Download and install.The latest version (v10.9.0) is recommended.You can also use Yarn instead of NPM.Cogear.JS runs on:MacLinuxWindowsYou may want to use awesome VSCode editor.InstallationInstallation video on YouTubeUsageGo to the directory where all your local sites are hosted.$ cd ~/Sites Create a new site via command:$ cogear new site.io # where "site" is your site folder name How to create a new site?After that go to site directory:$ cd ~/Sites/site.io And start up Cogear.JS in development or production mode (learn more).$ cogear # run in development mode with hot-reload – by default $ cogear production # build a site and run local server Next time we will dive deeply into the workflow.Github repository: https://ift.tt/2zxcWGD site: https://ift.tt/2ONnztX https://ift.tt/2zxcHeH
Submitted September 26, 2018 at 09:22PM by CogearJS
Submitted September 26, 2018 at 09:22PM by CogearJS
E-commerce sits in nodejs
I want to create a e-commerce site in nodejs but I don't know which packages can be used to build that app note: I finished all inbuilt functions in nodejs.org documentation so I can do this site with these in built packages or not Anybody suggest me
Submitted September 26, 2018 at 07:19PM by mohamedimy
Submitted September 26, 2018 at 07:19PM by mohamedimy
The simplest path to Typescript Code Coverage in Node with Webpack
https://ift.tt/2InmerL
Submitted September 26, 2018 at 07:27PM by tomasAlabes
Submitted September 26, 2018 at 07:27PM by tomasAlabes
Node.jsでのイベントループの仕組みとタイマーについて – 技術探し | ニュース速報TRIPLE-D
https://ift.tt/2Q5sUx2
Submitted September 26, 2018 at 06:38PM by ICYMI_email
Submitted September 26, 2018 at 06:38PM by ICYMI_email
結婚式二次会用に Node.js x ブラウザでタイピング対決アプリを作ってみた - 凹みTips
https://ift.tt/1oYUhvD
Submitted September 26, 2018 at 06:43PM by ICYMI_email
Submitted September 26, 2018 at 06:43PM by ICYMI_email
ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself..... How do you install a peerDependency?
I know I can npm i -D ajv, but what's the best way to handle this warning?
Submitted September 26, 2018 at 07:00PM by hotsaucetogo
Submitted September 26, 2018 at 07:00PM by hotsaucetogo
node.jsでMACアドレスを取得する時に便利なライブラリ「getmac」 | cupOF Interests
https://ift.tt/2NMjSso
Submitted September 26, 2018 at 06:48PM by ICYMI_email
Submitted September 26, 2018 at 06:48PM by ICYMI_email
SnapTrash: a mobile app to get rid of plastic waste
https://ift.tt/2Q9e8W2
Submitted September 26, 2018 at 05:12PM by sandrobfc
Submitted September 26, 2018 at 05:12PM by sandrobfc
Performance best practices - call for ideas
Our repo with over 75+ Node best practices kicks off a new section: Performance best practicesAt first, we call for ideas: can you kindly share an advice or a great article/video on performance? what are the performance-related best practices/tools that you use?This post is likely to contain dozens of ideas - keep followinghttps://github.com/i0natan/nodebestpractices/issues/256
Submitted September 26, 2018 at 04:50PM by yonatannn
Submitted September 26, 2018 at 04:50PM by yonatannn
How to build a Blog with React, Apollo & GraphQL: Ep 7 Apollo Server & GraphQL Schema
https://www.youtube.com/watch?v=y6FJ8sso284
Submitted September 26, 2018 at 04:06PM by adjouk
Submitted September 26, 2018 at 04:06PM by adjouk
Developing a Real-Time, Collaborative Editor with Pusher
https://ift.tt/2OdYKub
Submitted September 26, 2018 at 02:52PM by Ramirond
Submitted September 26, 2018 at 02:52PM by Ramirond
A lost traveler trying to find his way through this realm (Node.js, EJS, Apache, A2 Hosting)
Greetings all,Preface: I tried to post this in /r/webdev first but due to my low karma it got flagged and the mod hasn't approved my post yet so for now I will reach out here because I've already talked to some awesome people in this community who were very helpful before. So without further ado, welcome to my problems!I'm having some issues hosting a Node.js application on a shared/managed server that's hosted by A2 Hosting, which of course means I do not have root access on it (yes, I know I should be using a VPS but unfortunately I can't due to work restrictions). I figured I would post a little about it here just in case anyone can spot something I'm not seeing or maybe just point me in the right direction. I feel like I'm surprisingly close to having this thing actually work under these constraints and I'm super excited but it's also driving me insane. Any and all comments would be greatly appreciated!First, a little about the server itself - as I mentioned before it is a shared/managed linux server that is hosted by A2 Hosting and is running CentOS 6.x. The application structure and surrounding file system looks like this...(The ~/ represents the true linux /home/$user/ directory, not the web server root.) ~/ ├── public_html (Apache web server root directory) │ └── .htaccess └── myapp_repo (My Node.js app) └── myapp ├── app.js ├── bin │ └── www ├── node_modules │ └── * ├── package-lock.json ├── package.json ├── public │ ├── images │ │ └── img.png │ ├── javascripts │ │ ├── init.js │ │ └── menu.js │ ├── materialize │ │ ├── css │ │ │ ├── materialize.css │ │ │ └── materialize.min.css │ │ └── js │ │ ├── materialize.js │ │ └── materialize.min.js │ └── stylesheets │ └── style.css ├── routes │ ├── about.js │ ├── contact.js │ ├── index.js │ ├── send.js │ └── services.js └── views ├── about.ejs ├── contact.ejs ├── error.ejs ├── index.ejs ├── partials │ ├── banner.ejs │ ├── foot.ejs │ ├── head.ejs │ ├── menu.ejs │ └── script.ejs └── services.ejs I was able to install node and npm just fine and also configured my application to run on port 49157 because...To run a Node.js application on a managed server, you must select an unused port between 49152 and 65535 (inclusive). ^ directly from their docs.The next step that I took was figuring out how to re-route all web traffic to my node app instead of the apache root (i.e "~/public_html/"). I did that by writing a rather simple .htaccess file that routes everything to my loopback address at the port that I configured my app to listen on. It looks like this...$ cat ~/public_html/.htaccess RewriteEngine On RewriteRule ^.*$ http://127.0.0.1:49157/ [P,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d To my surprise after starting my application using $ nohup npm start --production &it was actually somewhat working when I visited my domain in my web browser. From what I can tell it seems like the HTML from my index.ejs file is rendering correctly but all the CSS and JavaScript is not (I linked bootstrap via their web link, hence the visible text styling). It looks like this...Obviously I immediately checked out those JS files and there is nothing wrong with them. I'm not really sure why I'm receiving those errors. Maybe one of my templates is inserting an extra character when it renders? I of course do not get this error when running it locally.Obviously I immediately checked out those JS files and there is nothing wrong with them. I'm not really sure why I'm receiving those errors. Maybe one of my templates is inserting an extra character when it renders? I of course do not get this error when running it locally.At first I thought it would be an easy fix, probably just the file paths had gotten a little offset from how I was running it locally on my dev machine but after trying every possible relative path and also absolute paths all the way from the root directory of the machine itself, nothing worked.Like I said before, this is driving me insane because I feel so close yet so far from getting this working correctly. I'm still new to building with node and also on the web in general so please pardon my stupidity in any and everything I have said or may say! I still feel like it's most likely a file path issue but I just can't seem to spot it. Again, any and all comments or suggestions would be super! Thanks for reading this and please feel free to comment and yell at me for being dumb because honestly... you're not wrong!
Submitted September 26, 2018 at 01:49PM by srclord
Submitted September 26, 2018 at 01:49PM by srclord
What is the best way to handle querystrings in an express api?
I am a beginner nodejs developer, working on developing an express rest api with optional query params.For example consider the following schema for a user:phone: {countryCode: String,number: phoneType},phoneVerified: { type: Boolean, default: false },emailVerified: { type: Boolean, default: false },rating: Number,balance: { type: Number, default: 0 },occupation: String,gender: { type: String, enum: genders },I want to expose this resource at /users and allow querying through optional query strings.For ex, /users?emailVerified=true&phoneverified=false&gender=male&occupation=plumber&limit=10This should return all the users which satisfy the criteria, while keeping almost all of the options optional.What is the best way to do this in a maintenable and futureproof way?Appraoch 1: My first approach was to use if blocks to check which parameters exist in the query and build mongoose queries accordingly, but that looks ugly and very hard to read.queryObj = {};if (req.query.params.occupation) {queryObject = {...queryObject,occupation: req.params.occuption};}if (req.params.phoneVerified) {queryObject = {...queryObject,phoneVerified: req.params.phoneVerifed};}const users = await User.find(queryObject);I also found the querymen package which looks promising. If someone experinced could guide me as to what is the best practice? Thanks in advance
Submitted September 26, 2018 at 09:49AM by strawberrycandies
Submitted September 26, 2018 at 09:49AM by strawberrycandies
Mongoose error handling
I really like mogoose schema and how it validates the data but I don't know If I'm the only one who think that the hardest task when you are working with mongoose it's error handling and it's even harder when you are developing an api for third parties and you have to forward those error in the prettiest and understandable way to them. So, I want to know how you guys handle mongoose errors?
Submitted September 26, 2018 at 06:26AM by foocux
Submitted September 26, 2018 at 06:26AM by foocux
Tuesday, 25 September 2018
Recommended node libs for RabbitMQ?
Was just checking node libraries on github for working with RabbitMQ and couldn't help but notice that a lot of the recommended libs on here from 2-3 years back seem dormant or dead.Just wanted to check and see what you guys would recommend currently for working with rabbitmq in node?Thanks.
Submitted September 26, 2018 at 12:21AM by m9js
Submitted September 26, 2018 at 12:21AM by m9js
Getting confused designing REST API that has Users
I have an auth router and an api router for my Koa app.The auth router looks something like:const router = new Router({ prefix: '/auth' }) router.post('/signup', async ctx => { ... }) router.post('/login', authenticate(), async ctx => { ... }) router.post('/logout', async ctx => { ... }) and the api router looks something like:const router = new Router({ prefix: '/api' }) // Get user by ID router.get('/users/:userId', async ctx => { ... }) // Create a user router.post('/users', async ctx => { ... }) // Delete a user router.delete('/users/:userId', async ctx => { ... }) // Get food by ID router.get('/foods/:foodId', async ctx => { ... }) ... The main question I have is about the users part of it (not the food stuff). I am noticing that both the POST /users and the POST /signup do the same thing (essentially call myDB.createUser()). I am wondering if I shouldn't have a POST /users in my API at all. I just felt weird not having it because the food stuff and other API routes are probably going to have POST, GET, DELETE, and PUT methods in each of them.TLDR: Should I only have 1 create user route (instead of 2), or should I somehow be calling POST /users in my POST /signup route.I do have one other small question – should I be desigining my API to be like GET /users/:userId or GET /users:/username or somehow allow both?
Submitted September 25, 2018 at 11:49PM by intftbbts
Submitted September 25, 2018 at 11:49PM by intftbbts
having trouble using MSSQL with node and express
I am coming from a "mongo/mongoose .then .catch" background. Now I need to learn mssql with node/express. Surprisingly, I am having trouble finding documentation on how to GET/POST/PUT/DELETE using mssql commands (instead of mongo/mongoose).Quite a few tutorials out there show "proof of concept", as far as how to set up node/express, a sql db on azure, and return a random table from the classic adventureworks db , in console.log upon successful db connection. I get that.But I'm having trouble finding out how to configure my API to send GET/POST/PUT/DELETE commands to my sql server using express routing like server.get, router.post, etc.I know I must have the wrong approach because of my lack of search results. Can anyone point me in the right direction?Thanks!
Submitted September 25, 2018 at 11:04PM by BeerInTheRear
Submitted September 25, 2018 at 11:04PM by BeerInTheRear
Bundling a Node.js Function for AWS Lambda with Webpack
https://ift.tt/2OaGmSZ
Submitted September 25, 2018 at 10:42PM by code_barbarian
Submitted September 25, 2018 at 10:42PM by code_barbarian
Connecting to Database via Vanilla JS and Node, Using Only Built in Modules.
I am looking to build a project using only vanilla js on the client side and node js on the server side, with only the build in modules. Are there any tutorials, or does anyone know how to connect to a Postgres or Mongo DB without using pg, mongoose or the like? I would like to try and avoid reverse engineering those packages if at all possible.
Submitted September 25, 2018 at 10:19PM by weedzgobot
Submitted September 25, 2018 at 10:19PM by weedzgobot
Learn nodejs
I want to learn nodejs and if I learn full documentation in nodejs.org,it is enough or not (If I finish all modules and packages in docs ,it is over or not) anybody can tell me
Submitted September 25, 2018 at 09:40PM by mohamedimy
Submitted September 25, 2018 at 09:40PM by mohamedimy
Node.js のバージョン管理ツール n を使ってみました : (*x).b=z->a+y/c
https://ift.tt/2Q66FHh
Submitted September 25, 2018 at 06:50PM by ICYMI_email
Submitted September 25, 2018 at 06:50PM by ICYMI_email
ブラウザを開くだけでエディタ、Webサーバ、DB等の開発環境が整う PaizaCloud Build web app in browser! Build app in browser! Web/DB server, Editor, Terminal is ready in 3 sec!
https://paiza.cloud/en/
Submitted September 25, 2018 at 06:40PM by ICYMI_email
Submitted September 25, 2018 at 06:40PM by ICYMI_email
Learn MongoDB, Express, React and Node.js
http://sumo.ly/Uw6J
Submitted September 25, 2018 at 06:21PM by jstcmng
Submitted September 25, 2018 at 06:21PM by jstcmng
Run Node.js Online - Turbo.net
https://ift.tt/2Od3nVA
Submitted September 25, 2018 at 06:45PM by ICYMI_email
Submitted September 25, 2018 at 06:45PM by ICYMI_email
I want to build a Node ftp client, where should i start?
No text found
Submitted September 25, 2018 at 07:03PM by Giiin
Submitted September 25, 2018 at 07:03PM by Giiin
Embeddable file based object databases for NodeJS
I have been using nedb for a while on my projects but it being not maintained for about 3 years now, I decided to switch to some other such database. Modules like levelup are out because it doesn't provide query operations like lte, gte ...etcI found a few solutions like nedb-core (looks like unmaintained) tingodb, tedb ...etcI am unsure about which module to go with. Both tingo and tedb looks like they suit my need. Which one would be the better option out of the two? And if there are other options, please let me know about those too. Or is NeDB still relevant that I can keep on using it?
Submitted September 25, 2018 at 12:27PM by p765
Submitted September 25, 2018 at 12:27PM by p765
Why Nodejs is considered the best for developing Web Application?
Node.js is not even a framework. It is an application runtime environment. It empowers the developer to write JavaScript on the server-side! Imagine using a front-end language outside its environment! Sounds fancy, right? That’s exactly how Node.js empowers you.This question pops up quiet often, here is a blog which I wrote coveing all the key elements about Nodejs.Do read it and share what I missed:https://ift.tt/2pB8r8k
Submitted September 25, 2018 at 09:30AM by dhananjaygoel1
Submitted September 25, 2018 at 09:30AM by dhananjaygoel1
Should I test locally on my computer, or on the cloud(where my finished project will eventually go)?
No text found
Submitted September 25, 2018 at 06:28AM by smiles_low
Submitted September 25, 2018 at 06:28AM by smiles_low
Monday, 24 September 2018
Machine Learning in JavaScript (TensorFlow Dev Summit 2018)
https://www.youtube.com/watch?v=YB-kfeNIPCE
Submitted September 24, 2018 at 10:55PM by fagnerbrack
Submitted September 24, 2018 at 10:55PM by fagnerbrack
On Linux web server, where to put NodeJS projects?
I know it doesn't matter, but anyone mind to share his knowledge what the "industry" standard is of setting up an Linux web server and which folders to use for what?
Submitted September 24, 2018 at 09:50PM by Tanckom
Submitted September 24, 2018 at 09:50PM by Tanckom
Help with creating a server
Hello, I'm coming here as a last resort. I've been trying for a few hours now to get something wired up, but I've hit nothing but roadblocks.What I have:Hapi API server running on port 9001All routes are under `0.0.0.0:9001/api/v1`A bundled Vue.js single page appI need a webserver than can connect the two togetherServe the static vue files at `/public`Serve static media files from `/mediaSupport HTML5 history API (fallback to index.html)Proxy all requests from `0.0.0.0:9000/api` to `0.0.0.0:9001/api/v1`I have tried several strategies but I can never seem to meet all the criteria. I've tried Koa, and express (haven't looked into using hapi)If anyone can point me in the right direction, or help out that would be great.
Submitted September 24, 2018 at 09:52PM by Captainfuckoffthisis
Submitted September 24, 2018 at 09:52PM by Captainfuckoffthisis
How to build a Facebook Messenger chatbot with Node.js and Dialogflow
https://ift.tt/2xLV6gR
Submitted September 24, 2018 at 09:58PM by prtkgpt
Submitted September 24, 2018 at 09:58PM by prtkgpt
[tutorial] Building a Blog with React, Apollo & GraphQL Tutorial: Ep.6 MongoDB Schema/Models
https://www.youtube.com/watch?v=UyS4KPB4ZPY
Submitted September 24, 2018 at 09:30PM by adjouk
Submitted September 24, 2018 at 09:30PM by adjouk
An updated overview of the JavaScript ecosystem
https://ift.tt/2pMyZ77
Submitted September 24, 2018 at 06:11PM by sandrobfc
Submitted September 24, 2018 at 06:11PM by sandrobfc
Amazon.co.jp: JavaScriptでのWeb開発 ~ Node.js + Express + MongoDB + ReactでWebアプリを開発しよう 〜 その1 〜(改訂版三版) eBook: ナカノヒトシ: Kindleストア
https://ift.tt/2R0w3Qe
Submitted September 24, 2018 at 06:32PM by ICYMI_email
Submitted September 24, 2018 at 06:32PM by ICYMI_email
Martin Korvas's answer to What is the difference between async and async-await in Node.js? - Quora
https://ift.tt/2xLbT3L
Submitted September 24, 2018 at 06:37PM by ICYMI_email
Submitted September 24, 2018 at 06:37PM by ICYMI_email
LINE BOTをNode.jsで作る - Qiita
https://ift.tt/2hrUzc9
Submitted September 24, 2018 at 06:42PM by ICYMI_email
Submitted September 24, 2018 at 06:42PM by ICYMI_email
Node.js Authentication
HiI am looking into building a login system, something not too complicated to start. I have no idea where to start from and I would like some guidance, please.I am using nodejs and express and mongoDB (mongoose) so if you could limit the responses to these that would be great.I am aware there are a few options for authentication if I am not mistaken- JWT - Passport.js - Auth-0/2 ?I would really appreciate any videos, blogs, links, books, with some steps on this.
Submitted September 24, 2018 at 03:57PM by its_joao
Submitted September 24, 2018 at 03:57PM by its_joao
V8's new website
https://v8.dev/
Submitted September 24, 2018 at 02:07PM by ecares
Submitted September 24, 2018 at 02:07PM by ecares
[Tutorial] One-Liner Test Cases with jest-each
https://ift.tt/2IcoSjQ
Submitted September 24, 2018 at 02:27PM by gesscu
Submitted September 24, 2018 at 02:27PM by gesscu
Why is a Java guy so excited about Node.js and JavaScript?
https://ift.tt/2PGjKrF
Submitted September 24, 2018 at 12:12PM by fagnerbrack
Submitted September 24, 2018 at 12:12PM by fagnerbrack
Real-time CRUD guide: Front end (part 1) – Hacker Noon
https://ift.tt/2zqwBbj
Submitted September 24, 2018 at 07:54AM by jonpress
Submitted September 24, 2018 at 07:54AM by jonpress
Sunday, 23 September 2018
Authenticating my app with another service using OAuth 2
Looking for some help to point me in the right direction, I've searched for tutorials/guides on this but it all seems to be about creating the authentication on my side rather than authenticating my app with another API service.Scenario: I'm creating a SlackBot to hook up with another API service. This service uses OAuth 2.0 to authenticate. I need to make REST API requests from my Node.js app to the API service, authenticate with an OAuth token, retrieve the data, manipulate it and then send it to the SlackBot to post in a channel.I'm fine with working with the API and getting data into Slack, I'm looking for assistance with how to properly get and store OAuth tokens inside my app for use. Does anyone know of any guides on this topic?
Submitted September 24, 2018 at 06:17AM by vanweapon
Submitted September 24, 2018 at 06:17AM by vanweapon
Separation of concerns with MERN?
So I'm working on trying to teach myself how to not suck with the MERN stack. Already have a lot of good experience with React, trying to get a good handle on the back end. I've made a couple of apps that work great, but the code looks like garbage since there's a thousand different things going on at once in the same file.I'm used to separating out files with React so everything has one or two jobs and that's it - makes it easy to read and manage if stuff needs to change. So, along a similar vein, is there a general practice for separation of concerns with Express / MongoDB handling / etc, or is it more of a 'however the project requirements shape it' kind of thing?As an example - currently in this project I'm using Express, Mongoose, Body-Parser, and Passport. Is there a particular way that I should be handling these libraries in order to separate everything out appropriately? Everything is in one file (minus Routes) and works like a charm but it's also, to put it bluntly, an unreadable clusterfuck, so I'm trying to do this right. If there's any advice, thoughts, or resources that anybody thinks would help, I'd greatly appreciate it. Alternatively if there's any must-read books or must-watch lessons on this, I'm down for it. Thanks!
Submitted September 23, 2018 at 10:39PM by WaifuCannon
Submitted September 23, 2018 at 10:39PM by WaifuCannon
Why Scala is always better than Node.js
https://www.youtube.com/watch?v=jCPP2A9mHtM
Submitted September 23, 2018 at 11:27PM by ablock1
Submitted September 23, 2018 at 11:27PM by ablock1
i am stuck at creating rest APi using express-es6
So, i am messing around, trying to create a REST api. A found a boilerplate which is a great starter kit, but unfortunately i stuck at some point.I have created an issue as a question in the relevant github repo, but since i wanna understand this as quick as possible, i decided to leave the issue link here.Please take a look at it if you can :)https://ift.tt/2DnxAgv /api/facets/1 404 5.114 ms - 24 GET /api/facets/1 404 0.838 ms - 24Thank you!
Submitted September 23, 2018 at 09:27PM by rzilahi
Submitted September 23, 2018 at 09:27PM by rzilahi
unsplash-js/examples/node at master · unsplash/unsplash-js · GitHub
https://ift.tt/2Dn69Dd
Submitted September 23, 2018 at 07:12PM by ICYMI_email
Submitted September 23, 2018 at 07:12PM by ICYMI_email
Google App Engine Node.js Standard Environment Documentation | App Engine standard environment for Node.js docs | Google Cloud
https://ift.tt/2NAT91w
Submitted September 23, 2018 at 07:17PM by ICYMI_email
Submitted September 23, 2018 at 07:17PM by ICYMI_email
Curso Node.JS Desde Cero - TecGurus - Coding Videos
https://ift.tt/2DodVNl
Submitted September 23, 2018 at 07:22PM by ICYMI_email
Submitted September 23, 2018 at 07:22PM by ICYMI_email
Node.js and Mongoose Boilerplate For GraphQL Server With Modular Schema
https://ift.tt/2I89l4x
Submitted September 23, 2018 at 08:51PM by sangaloma
Submitted September 23, 2018 at 08:51PM by sangaloma
How to build binary releases for some dependency modules?
I'm trying to pack an app with PKG, I know I can ship some modules that are not required by static strings, like for instance var foo = require(bar ? "m1" : "m2");, but how can I generate binary releases for those dependency modules?
Submitted September 23, 2018 at 09:09PM by rraallvv
Submitted September 23, 2018 at 09:09PM by rraallvv
nodenv and Jenkins pipelines
Hey everyone, I have struggled few times managing different NodeJS, Ruby, and Python versions, the plugins are not well integrated with pipelines, NVM and RVM sometimes sucks, so I decided to find a different way.Locally I love use nodenv, rbenv and pyenv, so I created a Jenkins shared library that install the those tools and allows you setup multiple different versions.You can find the repo and documentation here: https://ift.tt/2xwJ3VI use and contribute to the project or let me know if you have any suggestions.
Submitted September 23, 2018 at 06:49PM by pedrocesar-ti
Submitted September 23, 2018 at 06:49PM by pedrocesar-ti
Traffic and tracking API
What java-script API can I use to track someone's route and create actions when traffic is found in their route?
Submitted September 23, 2018 at 06:21PM by munzaroo
Submitted September 23, 2018 at 06:21PM by munzaroo
Modules for creating register/login forms in nodejs without express framework
I want to know how to create login app with nodejs without any framework what are the packages required anybody suggest
Submitted September 23, 2018 at 02:03PM by mohamedimy
Submitted September 23, 2018 at 02:03PM by mohamedimy
10 Steps to Setup and Containerize an Express Server
https://ift.tt/2NBOOLT
Submitted September 23, 2018 at 01:39PM by acdota0001
Submitted September 23, 2018 at 01:39PM by acdota0001
Mongoose $pull
I have this "Todo" model which has an array called "notes" as one of its keys. This array contains objects (instances of Notes model). I am trying to delete from this array a specific "note" via its" _id", but it is not working. It works via text.One Todo with one NoteI tried:var _id = req.params.id; //Todo _id Todo.findOneAndUpdate({_id}, {$pull: {notes: {"_id": "5ba7618e43cb2cbedb91e986"}}} ... but it isn't working... if I use {"text": "Some note"} it works... what am I missing?Thank you for you help - you're all amazing! :)
Submitted September 23, 2018 at 11:12AM by its_joao
Submitted September 23, 2018 at 11:12AM by its_joao
How to force Express.js to use HTTPS
https://ift.tt/2MTijID
Submitted September 23, 2018 at 11:27AM by dvaOfTheWeb
Submitted September 23, 2018 at 11:27AM by dvaOfTheWeb
How much child processes can I execute concurrently ?
I have an application that requires about (max) 300 child process to run. Normally, its about 90 child processes at a time. I ran the app on Heroku free tier and the app restarted.How can I know how much child processes I can execute simultaneous ? What specs do I need to look for ?
Submitted September 23, 2018 at 09:35AM by Ncell50
Submitted September 23, 2018 at 09:35AM by Ncell50
TensorFlow.js Crash Course – Machine Learning For The Web – Handwriting Recognition
https://ift.tt/2puywFO
Submitted September 23, 2018 at 09:12AM by codingthesmartway
Submitted September 23, 2018 at 09:12AM by codingthesmartway
Saturday, 22 September 2018
Hi, NodeJS community. I'm making a SaaS Point of Sales system, for Merchants, to be able to accept CryptoCurrency. (10 min)
https://ift.tt/2OEb43X
Submitted September 23, 2018 at 04:18AM by arturgvieira
Submitted September 23, 2018 at 04:18AM by arturgvieira
What does it mean by "Using Node as front end"?
I get this a lot but I really never understood what does it mean when someone say they are using node for frontend? Currently, I write our business API in spring and use angular for front end. When it comes to deployment, I create a production build of angular and deploy it on a tomcat server exposing index.html file..this build has js code which will call spring apis in my backend once it lands in user's browser..In past instead of spirng, I have used node as backend and written business apis using express js..But, Where and how one uses node as a front end and how would it talk to backend?
Submitted September 23, 2018 at 05:06AM by nitinsh99
Submitted September 23, 2018 at 05:06AM by nitinsh99
retra-static: Easily & efficiently host static files on your retra HTTP server!
https://ift.tt/2pwSGza
Submitted September 23, 2018 at 06:02AM by Etha_n
Submitted September 23, 2018 at 06:02AM by Etha_n
Help me fix my "Node Dev to Deployment" app
I'm a fucking noob. So, I recently finished Brad Traversy's "Node Dev to Deployment". What I built sorta works but it's got major issues. I'm hoping some good samaritan can clone this code, run it, identify my fuckups, and advise me on how to fix them.In the navbar partial, I'm unable to conditionally display the "Login/Register" and "Logout" links depending on whether the user is logged in or not. It seems I may not be able to successfully extract the user object and pass it to the template. I don't know.In controllers/ideas.js, I'm protecting the routes with the "checkIfAuthenticated" function, but for some reason, this results in login loops, causing redirects to the login page even after seemingly successful logins. I don't get it.Not sure if the delete route for an idea is properly configured to allow only the creator of that Idea to delete it.There are probably other issues, but the above were the major ones I identified and couldn't fix. HELP!!!
Submitted September 23, 2018 at 03:10AM by ncubez
Submitted September 23, 2018 at 03:10AM by ncubez
Is Node JS right for me.
Hello Everyone,Please tell me if this does not belong here, or belongs in another subreddit.I mean to use Node Js ExpressI am a complete Node newbie :) I mainly use Java for android.The ProblemA main page selling 3 products with customization, Heavy JavaScript animations and stuff moving and displaying the products.A Checkout system which works with multiple vendors.And an account storing system, to help view the shipping or activity on the product.The SolutionUsing nodeJS to create it?I seem to struggle with the whole template engines especially for just a heavy front (PUG, Jade.....etc) with the only real actions with a database is the checkout side.Is Node JS Express right for me?{Sorry accidentally clicked enter and made the post so I may still be editing}
Submitted September 23, 2018 at 01:14AM by vaughan2
Submitted September 23, 2018 at 01:14AM by vaughan2
retra - the powerful, lightweight HTTP server library for Node
https://ift.tt/2I7IO7z
Submitted September 22, 2018 at 11:42PM by Etha_n
Submitted September 22, 2018 at 11:42PM by Etha_n
NVM Question - Difference between 'nvm run' and 'nvm exec'?
They seem to do the same thing. For example to get the version:nvm exec 8 node --versionnvm run 8 --versionWhen should we use one over the other?(Hope this post is appropriate here)
Submitted September 22, 2018 at 10:48PM by asheq100
Submitted September 22, 2018 at 10:48PM by asheq100
Gracefully handle a Promise error?
Hey,I am trying to learn how to use promises and what not. In my code, everything works just fine until I hit an error.The application hard exits on error. //dbManager.js const mysql = require("mysql"); const dbHost = "localhost"; const dbUser = "root"; const dbPassword = "password"; const dbName = "mydb"; const dbPool = mysql.createPool({ host: dbHost, user: dbUser, password: dbPassword, database: dbName }); module.exports.get = () => new Promise((resolve, reject) => { dbPool.getConnection((err, connection) => { if (err) { reject(err); return; }; resolve(connection); return connection; }); }); //app.js const db = require("./dbManager"); db.get() .then((conn) => { let sql = "Show Tables"; conn.query(sql, (err, results) => { if (err) console.log(err); console.log(results); conn.release(); }); }) .catch((e) => { //Please, stop exiting! console.log(e); }); How can I handle the error gracefully?Thank you for your time.
Submitted September 22, 2018 at 11:22PM by Ratatatah
Submitted September 22, 2018 at 11:22PM by Ratatatah
How does your company use Node.js? (I'll show you mine if you show me yours)
Hi, long time lurker here. I personally find it difficult to get a read on patterns businesses use for node.js. Obviously it's easy to find patterns that are common throughout open source projects, but these are mostly frameworks rather than large applications intended to be hosted and run somewhereSo, let's compare notes! I'm going to give a short summary of the technical domain of the company I work for, how many employees and then an overview of patterns we use within the code and if I'm lucky some of you will too :)What we doThe company I work for is basically a big ETL pipeline, pulling in data from various sources. Data is filtered, transformed and finally aggregated into a search engineWe're a startup and so only have 3 developers including me. We've been working on our technology for 3 years. In our first 2 years, we played about with Python, Node.js and Clojure. About a year ago we decided to settle on Node.js. The three of us are relatively new to Node.js but have picked up the basicsHow we doProject structureThese files are just made up of course but show the general structure- src/ - todos/ # some of our projects are monoliths and some are (micro?)services. Monolith projects have separate components in different folders and code is kept separate to reduce monolith complexity - route/ - postTodoRoute.js # Express route - getTodosRoute.js - worker/ - removeObsoleteTodosWorker.js # job that runs on a schedule. Generally just setInterval. Now that node.js has workers, this is a bad name 🐶 - service/ # all code that talks to external dependencies. Useful to keep them separate by convention so it's clear what needs to be stubbed in integration tests - postgres/ - getTodosService.js - datadog/ - auth0/ - transform/ - pgTodoTransform.js # transform a Todo from postgres representation to in-memory - models/ - todoModel.js # though our code is not object-oriented, we still represent common data structures in `class`es as they work well with JSDoc and editors tend to be able to autocomplete fields - dependencies.js # an object that contains all side-effect dependencies. This can be stubbed in integration tests and is passed to routes as req.dependencies and passed to workers as a function arg - utils/ # other stuff - router.js # express router for routes exposed by this component - index.js # set-up workers and any other initialisation logic for this component - someOtherComponent/ - test/ - todos/ - integration/ - unit/ Coding styleOur code is sort of procedural, sort of functional. By this I mean that we very rarely mutate state and that code that has external side-effects is confined to services/ folderI'll give some contrived examples:src/todos/route/getTodosRoute.js:async function getTodosRoute(req, res, next) { try { logger.info('todos/routes/getTodosRoute() - starting..', { 'req.query': req.query }); const result = Joi.validate(req.query, GetTodosRequestQuerySchema); if (result.error !== null) { throw result.error; } const pgTodos = await req.dependencies.getTodosService(req.query); const transformedTodos = pgTodos.map(pgTodoTransform); const response = { todos: transformedTodos, }; logger.info('todos/routes/getTodosRoute() - finished'); return res.json(response); } catch (error) { logger.error('todos/routes/getTodosRoute() - error', { error }); return next(error); } } module.exports = getTodosRoute; src/todos/worker/removeObsoleteTodosWorker.js:function create(dependencies, frequencyInSeconds=60) { // again, a worker is not a Node.js Worker. We just foolishly named these workers const worker = new RemoveObsoleteTodosWorker({ depencencies, eventEmitter: new EventEmitter(), intervalId: null, state: {}, }); worker.eventEmitter.on('start', () => { worker.intervalId = setInterval(async () => { try { logger.info('todos/workers/removeObsoleteTodosWorker/create() - starting iteration..'); worker.state = await onIteration(worker); worker.eventEmitter.emit('iterated'); // used by integration tests to inform when worker has iterated logger.info('todos/workers/removeObsoleteTodosWorker/create() - finished iteration'); } catch (error) { logger.error('todos/workers/removeObsoleteTodosWorker/create() - error during iteration', { error }); worker.eventEmitter.emit('error', error); } }, frequencyInSeconds * 1000); }); return worker; } function start(worker) { worker.eventEmitter.emit('start'); } module.exports = { create, start, }; A word on componentsSome of our components are separate microservices and some are simply modular bits of code within a monolith. Right now these only ever talk to each other via REST interface or by setting state in an integration database. We're looking into more robust and asynchronous communication soon like RabbitMQ or SQSWould be VERY interested to hear how other companies deal with inter-component communication :)Commonly used frameworks / librariesexpressmocha/chai/sinoneslintlodashjoi (https://ift.tt/2PXsXuJ Schema validationmoment-timezone (https://ift.tt/2O7S6Wi Datetime / timezone stuffdotenv (https://ift.tt/2PXsYyN Loads env vars for local development. We store the .env files in a password manager so they never touch version controlnose-sql-template-strings (https://ift.tt/2O1cbxC We just directly write SQL rather than using an ORM, as we have some bizarrely esoteric queries. This library makes sure its escaped and sanitiseddb-migrate (https://ift.tt/2PXtnRP Database migration scripts. We use --sql-file so that migrations are directly written in SQLwinston (https://ift.tt/2O40nus Logging. We log as a JSON so that any log service can parse and search structured dataTl;drWasn't expecting to write that much but hope it helps someone else also wondering how other companies do itVery excited to hear people's thoughts and even moreso how they do it :D
Submitted September 22, 2018 at 08:43PM by chaptor
Submitted September 22, 2018 at 08:43PM by chaptor
E se invece JavaScript (Node.js) – 1 | Ok, panico
https://ift.tt/2MQC4eY
Submitted September 22, 2018 at 05:00PM by ICYMI_email
Submitted September 22, 2018 at 05:00PM by ICYMI_email
Ipenywis Learning Website
https://ift.tt/2MURXRm
Submitted September 22, 2018 at 05:05PM by ICYMI_email
Submitted September 22, 2018 at 05:05PM by ICYMI_email
(2016) Numerical Computing in Javascript
https://www.youtube.com/watch?v=1ORaKEzlnys
Submitted September 22, 2018 at 02:43PM by fagnerbrack
Submitted September 22, 2018 at 02:43PM by fagnerbrack
Send SMS in Node.js via SMPP Gateway
https://ift.tt/2O4Prgb
Submitted September 22, 2018 at 02:15PM by banna2
Submitted September 22, 2018 at 02:15PM by banna2
MongoDB, Mongoose, etc...
HiMongoose is driving me crazy with the lack of updated instructions on their website and so many deprecated warnings I get with simple routes. I am considering using vanilla mongoDB syntax over this crap.But not before asking you if there is any other ORM language you can recommend?I found this article and there is a good recommendation, but I would like to hear from someone who uses/has used it.:)
Submitted September 22, 2018 at 12:52PM by its_joao
Submitted September 22, 2018 at 12:52PM by its_joao
Hi friends! I just published “Practical Inversion of Control in TypeScript, Functional Way”, maybe check it out :)
https://ift.tt/2DoH5fd
Submitted September 22, 2018 at 11:35AM by danydughy
Submitted September 22, 2018 at 11:35AM by danydughy
I'm Coming from Laravel to Nodejs world, Does Nodejs have any framework like Laravel?
Hi, I'm a newbie in Nodejs world and I'm learning Nodejs And Expressjs but Express is just a router we don't have ORM &...Is there any mature Node.JS framework like Laravel/Django or can you suggest some packages to add to express to create functionality like Laravel?
Submitted September 22, 2018 at 08:51AM by 8_CHAINZ
Submitted September 22, 2018 at 08:51AM by 8_CHAINZ
Friday, 21 September 2018
Old Versions of Hapi.js Are Planned to Be Maintained Under Commercial License
https://ift.tt/2I5MuGH
Submitted September 22, 2018 at 05:46AM by ilyaigpetrov
Submitted September 22, 2018 at 05:46AM by ilyaigpetrov
Is there an alternative to Passport.js?
Is there an easier (and sensible) alternative to Passport, preferably something that can also do social media login, in addition to the regular username and password combo? The complexity of Passport is astoundingly stupid and unnecessary, imo.
Submitted September 22, 2018 at 04:39AM by ncubez
Submitted September 22, 2018 at 04:39AM by ncubez
In the node apps you’ve written or contributed to, how much business logic is located in the app layer (by means of an ORM etc.) versus in your database as functions/procedures (for those using postgres/rdbms etc)?
Torn on architectural approach. I.e. try to keep everything high-level via sequelize, possibly support multiple databases, versus going straight to postgres functions (with rich triggers for updating creation/modified times, and more).The software is a CMS designed to be used by multiple users standalone, as opposed to a SaaS offering that is largely hosted/managed by one user/company. One day it will probably be extensible (users can add components without modifying core). Is there more flexibility in handling most business logic in the app layer in this case?
Submitted September 22, 2018 at 03:01AM by MyyHealthyRewards
Submitted September 22, 2018 at 03:01AM by MyyHealthyRewards
How to generate binaries for some modules in the dependencies?
I'm trying the pkg module to see if I can generate a standalone executable for my Node.js app, but some modules are loaded conditionally like it's shown below, and the app throws and exception at runtime saying that those modules are missing:var foo = require(bar ? "module1" : "module2"); How can I generate binaries for those modules in order to ship them with my app?
Submitted September 22, 2018 at 01:38AM by rraallvv
Submitted September 22, 2018 at 01:38AM by rraallvv
(2017) High Performance JS in V8
https://www.youtube.com/watch?v=YqOhBezMx1o
Submitted September 21, 2018 at 11:16PM by fagnerbrack
Submitted September 21, 2018 at 11:16PM by fagnerbrack
how to loop through collections of a mongodb database?
I want to loop through each collection documents of my database to read properties I've assigned to these documents. I've tried db.collections() and db.listCollections but they do not work for me because they return information about each collection but not the properties that I want to access.
Submitted September 21, 2018 at 10:11PM by xAmrxxx
Submitted September 21, 2018 at 10:11PM by xAmrxxx
Maximum number of concurrent connections
Hello,I know that I can change the maximum number of concurrent connections using server.maxConnections. I've seen this used in the booting phase of a node.js application, but I've never seen it used at runtime. Is it a "good practice" (I mean, excluding the fact that there should be a layer before a node serve to do this, eg a load balancer) to change it at runtime? Will it work properly?
Submitted September 21, 2018 at 10:21PM by honestserpent
Submitted September 21, 2018 at 10:21PM by honestserpent
Session - user is undefined after login request
hello, I have problem with authenticating user with session.Session id is reseted after every reload of page and req.session.username is undefined. I am using react frontend on one IP and node on another one. Tried almost everything from other posts about this issue, but cant set it right. could you please help me? Thank youconst express = require("express"); const app = express(); const bodyParser = require("body-parser"); const MongoClient = require("mongodb").MongoClient; const bcrypt = require("bcrypt"); const session = require("express-session"); const MongoStore = require("connect-mongo")(session); app.use( session({ cookieName: "session", secret: "XXXXX?.XXXXXX?EOXXXX", duration: 24 * 60 * 60 * 1000, activeDuration: 1000 * 60 * 5, saveUninitialized: true, resave: true, cookie: { path: "/", maxAge: 60000, httpOnly: false, secure: false }, store: new MongoStore({ url: "mongodb://admin:xxxxx@xxxxxx.mlab.com:xxxx/DBNAME" }) }) ); app.use((req, res, next) => {req.username = req.session.username; next()}) app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); }); MongoClient.connect( "mongodb://admin:xxxxx@xxxxxx.mlab.com:xxxx/DBNAME", (err, client) => { if (err) return console.log(err); db = client.db("DBNAME"); app.listen(8000, () => { console.log("listening on 8000"); }); } ); app.get("/test", (req, res) => { res.send({ session: req.session.username }); }); app.post("/login", (req, res, next) => { let username = req.body.content.username; let password = req.body.content.password; db.collection("users") .find() .toArray(function (err, results) { for (let i = 0; i < results.length; i++) { if (results[i].username === username) { bcrypt.compare(password, results[i].password, function (err, res) { if (res) { console.log("login"); req.session.username = username } else { console.log("incorrect"); } }); } } }); });
Submitted September 21, 2018 at 10:21PM by mikebun2
Submitted September 21, 2018 at 10:21PM by mikebun2
Best way to implement a transaction queue in my Node app?
Basically, currently I have a REST API on Node+Express that takes about ~40 seconds (or more) to process the request (encode and store some data) and return a response (receipt).But a 40-second response tine is not very nice, and I want to implement a system that allows me to return a promise or an ID of the transaction instantly whenever it is requested, and put the said transaction into a queue for it to be processed so that the API caller doesn't have to wait almost a minute or sometimes even more to get a response, and instead get something that is able to look up if the transaction has succeeded later.Ideally this should be able to handle simultaneous/very consecutive calls too, as long as I can return some response to check the results later. Transaction processing time doesn't matter, as long as it is in the queue and it is going to be executed.Thanks in advance!
Submitted September 21, 2018 at 10:09PM by thunderforce41
Submitted September 21, 2018 at 10:09PM by thunderforce41
Best way to append to a file on every request in a Node app?
I am working on a Node app that uses Express to handle requests. I have a file I want to append a line to for each request, and eventually this file gets sent off to do some batch processing. Yes, kind of like a log file.I don't have a great grasp of how exactly Node handles each request. If I simply call appendFile in the express route handler, will that cause the file to get corrupted? I assume I don't want to do appendFileSync because then the request handler will block, right?
Submitted September 21, 2018 at 09:25PM by The_Talisman
Submitted September 21, 2018 at 09:25PM by The_Talisman
Node noob in need of help due to an issue that most likely is just his lack of knowledge.
Greetings All,I'm sorry if this is the wrong place to post this, I'm relatively new to this. I've been an observer on reddit for years but this is my first time ever reaching out.I'm having some difficulties getting a website I built with node.js up and running and I'm posting this here to see if anyone can spot something I'm not seeing or maybe just point me in the right direction. Any and all comments are greatly appreciated!So I'm host a site I built with node on an A2 managed server (work constraints, trust me I know smh). It's a CentOS 6.X box. I got node and npm installed just fine and also configured my application to run on port 49157 because...To run a Node.js application on a managed server, you must select an unused port between 49152 and 65535 (inclusive). ^ directly from their docs.I got my application directory all setup, "~/myapp_repo/myapp" to keep it simple. I'm just trying to deploy the default express page right now to test things out. I've setup the .htaccess file in the "~/public_html" directory to forward all web traffic to port 49157. When I try to access the site via my web browser I am presented with the default a2 hosting page but when I curl the site at port 49157, I get the page I'm hoping for!$ curl http://mysite.com:49157
Submitted September 21, 2018 at 08:00PM by srclord
Express
Welcome to Express
^ This is the page I want to receive when I request my site's domain in a web browser.It's driving me insane because I feel so close yet so far away from figuring this out. My node app is at least somewhat working correctly since I am receive a successful curl response. The re-routing of traffic is where I think the issue lies. I'm still new to building with node and on the web in general so please pardon my stupidity in any and everything I have said or may say!My best guess is that I'm doing something wrong within my .htaccess config so here's that$ cat ~/public_html/.htaccess RewriteEngine On RewriteRule ^$ http://127.0.0.1:49157/ [P,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ https://ift.tt/2I59iqb [P,L] Again, any and all comments or suggestions would be super! Thanks a ton.UPDATE - I forgot to clearly state the fact that I DO NOT have root access to the server. Unfortunately when accessing a managed (shared) server, you are not provided root access.Submitted September 21, 2018 at 08:00PM by srclord
Can you contribute to this repository? welcome.
I created this library out of desperation even though I was very basic in my JS then. I have had help from a few folks. I would like to invite reviews and contributions.
Submitted September 21, 2018 at 06:50PM by zemuldo
Submitted September 21, 2018 at 06:50PM by zemuldo
ws library is not sending or receiving messages.
So I am creating a simple WebSocket server that takes messages sent by one client and broadcasts it to all clients. The code is below.const WebSocket = require("ws"); const ws = new WebSocket.Server({port: 8081}); ws.on("message", message => { console.log("message"); ws.send(message);}); setInterval(()=>{ws.send("test");}, 1000); All clients connect successfully. However, when I send a message, the function in ws.on("message") does not get called. "message" does not appear in my terminal. The last line was added just to test sending, but when ws.send("test") gets called, I get TypeError: ws.send is not a function. The API docs for ws tell me that this will work, so what is going on here?
Submitted September 21, 2018 at 05:48PM by Windows-Sucks
Submitted September 21, 2018 at 05:48PM by Windows-Sucks
Why framework needed?
Many languages produce their documentation ,even nodejs has a document but why express needed?
Submitted September 21, 2018 at 04:56PM by mohamedimy
Submitted September 21, 2018 at 04:56PM by mohamedimy
Creating a Bug-Tracking Bot Using Node
https://ift.tt/2OIPBH0
Submitted September 21, 2018 at 04:44PM by tomasAlabes
Submitted September 21, 2018 at 04:44PM by tomasAlabes
Best app structure for big apps in NodeJS?
Hi,What structure of nodejs aplications do you recommend for big and medium projects?Here my two solution examples:Modular, on register.js i add 'module' to routesClassic MVCRecommend something good.Thanks!
Submitted September 21, 2018 at 03:25PM by kodonator
Submitted September 21, 2018 at 03:25PM by kodonator
Full stack web development courses by devslopes are available for free [ Node, React, HTML & CSS ] you can pick it up for 3 more days
https://ift.tt/2QLRfZX
Submitted September 21, 2018 at 12:22PM by Emitasx
Submitted September 21, 2018 at 12:22PM by Emitasx
I'm making a series where I design, develop and deploy a blog using React, Apollo & GraphQL. Here's the link if you wish to follow along!
https://www.youtube.com/watch?list=PLTXFz3WKxvNKm0_IRoQY1VAapbO1gYktt&v=EHqBe3-Ilto
Submitted September 21, 2018 at 11:20AM by adjouk
Submitted September 21, 2018 at 11:20AM by adjouk
Buffer endianness - Little Endian or Big Endian? How to choose proper method?
Hi,I'm reading metadata from mobi file. I have trouble with choosing which method should I use to read UInt16. Should it be Little Endian or Big Endian? How can i determine which method should be used to convert Buffer?
Submitted September 21, 2018 at 11:27AM by GaHeee
Submitted September 21, 2018 at 11:27AM by GaHeee
node.js + express + serialport, command from a POST does not get written to serialport
I wanna control an Arduino via webinterface which is hosted by an node.js server. The idea is, that I send (POST) a command (String) to the server, which forwards the command via 'serialport' to the Arduino. I use 'express' for the website, so my folder structure is something like. ├── app.js ├── bin │ └── www ├── package.json ├── routes │ └── index.js └── views └── index.pug The website works great and I can make a POST to send a command to the server.Now I wanna forward this command via 'serialport' to the Arduino. So I have in /routes/index.js this:router.post('/', function (req, res, next) { console.log(req.body.command); mySerial.write('I am sending a command!', function(err) { if (err) { return console.log('Error on write: ', err.message); } console.log('message written'); }); }); This cause an error: ReferenceError: mySerial is not definedOk, I think I get why: It's bc the code below about 'serialport' is located in /app.js . If I put mySerial.write() here in this section, node.js will send a String to the Arduino, but here I can't handle the command from the POST. I can't figure out myself what I have to do, to make it possible, that the command from POST is forwarded to the serialport.I am looking for a solution which makes it possible in the future to send a status from Arduino to the Browser.const SerialPort = require('serialport'); const Readline = SerialPort.parsers.Readline; const parser = new Readline(); const mySerial = new SerialPort('COM3', { baudRate: 115200 }); mySerial.on('open', function () { console.log('Opened Serial Port'); }); mySerial.on('data', function (data) { console.log(data.toString()); }); mySerial.on('err', function () { console.log(err.message); }); Thank you!Greetings
Submitted September 21, 2018 at 10:31AM by Iamnotagambler
Submitted September 21, 2018 at 10:31AM by Iamnotagambler
API REST skeleton using JavaScript async/await, Node.js, express.js, MongoDB, JWT and more. Great for building an MVP for your front-end app (Vue, react, angular, or anything that can consume an API)
https://ift.tt/2N93Bgu
Submitted September 21, 2018 at 08:59AM by davellanedam
Submitted September 21, 2018 at 08:59AM by davellanedam
Thursday, 20 September 2018
mongoose doesn't return the false values
router.get('/:_id', function(req, res, next) { Car.findById(req.params._id, function (err, cars) { if (err) { res.send(err); } res.render("cars", { cars: cars }); }); }); if i look trough mongo shell my object has false values but it actually return a cars object with everything true ** basically it cast the false value into true for some reason
Submitted September 21, 2018 at 05:20AM by shiust
Submitted September 21, 2018 at 05:20AM by shiust
Is there no best practice way to install Node?
Okay, let me preface with a bit of backstory. (I'm running mac OS High Sierra)Back a month or two ago, I decided to install npm and node with Homebrew. That's right, I installed a package manager with a package manager. I had no idea the headache this would cause.I uninstalled my Node and NPM versions that I had downloaded from the official disk image on the Node.js website (following these steps https://ift.tt/2PSpP3q), installed them both via brew, and was happily on my way.Well, I knew very little about running globally installed NPM packages on a Node binary installed by Homebrew. I ran sass to compile some stupid web project CSS I was working on and ended up literally crashing my computer. I almost had to reformat my disk and reinstall mac OS.So, I went ahead and somehow fixed everything, realized the philosophical problems behind installing NPM with Homebrew, and stuck my official Node.js disk image installation. I've never had any symlink issues since.Fast forward to now.I am trying to now install nasm via Homebrew, and I'm honestly terrified to move forward.I ran brew doctor and have about 200 or so unlinked header files all contained in /usr/local/include/node/*/Brew is prompting me to either 1. run brew install node (no thanks) 2. run brew pruneIs brew prune going to break anything?The output of my current which node and which npm is /usr/local/bin/node and /usr/local/bin/npmI don't want these unused Node headers just sitting there, it feels dangerous. If anyone has any recommendations, that would be much appreciated.Also, I'm planning on getting a new computer soon (a newer Macbook Pro). Is there a "best practice" to install node? Maybe install nvm via homebrew and then install node through nvm? I'm doubting myself because I read the first answer to this SO post: https://ift.tt/2xs7YcO help is greatly appreciated!
Submitted September 21, 2018 at 05:29AM by mjvolk
Submitted September 21, 2018 at 05:29AM by mjvolk
Most efficient way to receive a file from a fetch request?
No text found
Submitted September 21, 2018 at 03:09AM by smiles_low
Submitted September 21, 2018 at 03:09AM by smiles_low
Coding: How to debug any problem
“How to Debug Any Problem” @DuncanARiach https://ift.tt/2EQTlVc
Submitted September 21, 2018 at 12:31AM by hamsa_hiennv
Submitted September 21, 2018 at 12:31AM by hamsa_hiennv
Mongodb Derived fields that update when the data is changed
I have to run calculations ($sum $avg $divide) on some fields that get updated frequently.Right now every time i update the database i run the aggregations to update it again. Is there a better way to do thisI looked at $addsfields pipeline stage but will that make the field dynamic when the data changes
Submitted September 21, 2018 at 12:33AM by jimjim1000
Submitted September 21, 2018 at 12:33AM by jimjim1000
Mongoose/MongoDB query not working when adding two $nin values
this works fine Post.find({ username: { $nin: user.blocked } }) .sort({ created: -1 }) .then(posts => { res.json({message: posts}); }) this doesn't work even though it's how the mongodb docs describe combining $nin values Post.find({ username: { $nin: [ user.blocked, user.following ] } }) .sort({ created: -1 }) .then(posts => { res.json({message: posts}); })
Submitted September 21, 2018 at 12:55AM by temporarilyembarasse
Submitted September 21, 2018 at 12:55AM by temporarilyembarasse
Convert Bitmap image object to Base64?
So I have a Bitmap object that looks like this { "width": 504, "height": 28, "byteWidth": 2048, "bitsPerPixel": 32, "bytesPerPixel": 4, "image": { "type": "Buffer", "data": [ 255, 255...} How do I convert it into a base64 string with javascript? It is also possible for to turn the bitmap object into a hex string that would look like "ffffffdfdfdf333333..." If direct from bitmap into base64 isn't possible, would hex to base64 be possible?
Submitted September 20, 2018 at 09:30PM by ProfessionalSpace5
Submitted September 20, 2018 at 09:30PM by ProfessionalSpace5
How much do you charge for a simple NodeJS project?
Tell us about your project scope and tell us how much do you charge your clients for it. I'd like to know the average pricing in order to not fluctuate the market.
Submitted September 20, 2018 at 09:35PM by rangka_kacang
Submitted September 20, 2018 at 09:35PM by rangka_kacang
Nodejs Event Loop System: A Hand’s On Approach — Part 1
https://ift.tt/2xBLo0N
Submitted September 20, 2018 at 04:25PM by JSislife
Submitted September 20, 2018 at 04:25PM by JSislife
Rethinking JavaScript Test Coverage – Node.js Collection
https://ift.tt/2OEK7gD
Submitted September 20, 2018 at 07:56PM by _bit
Submitted September 20, 2018 at 07:56PM by _bit
No such app
http://developers.io/
Submitted September 20, 2018 at 08:06PM by ICYMI_email
Submitted September 20, 2018 at 08:06PM by ICYMI_email
Chalk 3 · Issue #300 · chalk/chalk
https://ift.tt/2xs34N4
Submitted September 20, 2018 at 08:11PM by ICYMI_email
Submitted September 20, 2018 at 08:11PM by ICYMI_email
To use Glitch, please enable JavaScript
https://ift.tt/2PXt2in
Submitted September 20, 2018 at 08:16PM by ICYMI_email
Submitted September 20, 2018 at 08:16PM by ICYMI_email
Mongoose: how to populate nested schemas with cross-references?
Hi guys,I am building a webapp for learning purposes with NodeJS and Mongo (Mongoose). It should be a Job Board that allows users (HR managers) to keep track of the job openings and the candidates. I am probably creating too much confusion with Mongoose Schema so I'd be happy to find some suggestion.I have 3 Schema for:- Company- Position- CandidateThese are the working cross-references amongst them (using mongoose.Schema.Types.ObjectId):- each Company has a property that includes the array of open positions for that companyname: String, logUrl: String, positions: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Position' }] - each Position has a reference to its own companyrole: String, salary: Number, jobDescription: String, company: { type: mongoose.Schema.Types.ObjectId, ref: 'Company' } - each Position has also an array of candidates that applied... candidates: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Candidate' }] - each Candidate has an array of positions (a single candidate can apply to multiple positions).name: String, surname: String, email: String, positions: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Position' }] Using .populate( ) I am able to manage all of them and access specific properties of linked objects. In this example, I can open the profile of a candidate, read the list of positions he applied and display the logo of the companies that have those openings. In this other example, I can open the profile of a company, read the list of openings and see the number of candidates for each one of them.So far so good, everything works as expected ✌️Now my goal is to add two properties to the array of positions in the Candidate schema than can keep track of the status of that application and the notes taken by the HR manager: the output should be similar to this.My Candidate schema is now:name: String, surname: String, email: String, positions: [ { detail: { type: mongoose.Schema.Types.ObjectId, ref: 'Position' }, progress: { type: String }, // keep track of the status comment: { type: String } // keep track of internal notes }], My code for opening and populating the candidate's page is:app.get('/:id', (req, res) => { Candidate .findById(req.params.id) .populate({ path: 'positions.detail', model: Position, populate: { path: 'company', model: Company } }) .exec(function (err, foundCandidate) { if (err) { console.log(err) } else { res.render('candidates/show', {candidate: foundCandidate}) } }) }) Now the problem: positions.detail is not getting populated. With the previous Schema (and without these two new properties), I was able to easily retrieve data on the position with position.property as well as on the company with position.company.property; now I am using position.detail.property and position.detail.company.property but they don't work: Cannot read property 'property' of undefinedCan anyone help me with this?
Submitted September 20, 2018 at 06:49PM by kuro1988
Submitted September 20, 2018 at 06:49PM by kuro1988
I was told JWTs are insecure
I get that if you store the token in localStorage a malicious script can read it, but don't we have this problem no matter what we use?
Submitted September 20, 2018 at 06:43PM by penguingspe
Submitted September 20, 2018 at 06:43PM by penguingspe
Cannot update NPM from 5.6 to 6.4.1
Everytime I use npm I see this message:Update available 5.6.0 → 6.4.1 Run npm i npm to update Every time I run npm i npm I get: + npm@6.4.1 added 387 packages in 6.771s Then I check npm --version and it says 5.6.0 again.
Submitted September 20, 2018 at 05:37PM by thinsoldier
Submitted September 20, 2018 at 05:37PM by thinsoldier
Whart is a TCP stream in a NodeJS context ?
cannot edit the title : What is a TCP stream in a NodeJS context ?\*I'm working with NodeJS buffer and I have found this definition:class was introduced as part of the Node.js API to enable interaction with octet streams in TCP streams, file system operations, and other contexts. I haven't found any relevant definition of TCP streams on the web, so please if someone can explain us the concept, would be great
Submitted September 20, 2018 at 02:32PM by JoonDoe
Submitted September 20, 2018 at 02:32PM by JoonDoe
Vulkan API for Node.js
https://ift.tt/2OFaPWt
Submitted September 20, 2018 at 02:59PM by Schampu
Submitted September 20, 2018 at 02:59PM by Schampu
Node v10.11.0 (Current)
https://ift.tt/2PU2tKR
Submitted September 20, 2018 at 01:02PM by dwaxe
Submitted September 20, 2018 at 01:02PM by dwaxe
Node.js Open Source of the Month (v.Sep 2018)
https://ift.tt/2ppXTsx
Submitted September 20, 2018 at 01:55PM by Rajnishro
Submitted September 20, 2018 at 01:55PM by Rajnishro
Why use react native for app development
https://ift.tt/2xCgUf2
Submitted September 20, 2018 at 12:39PM by xtreem-solutions
Submitted September 20, 2018 at 12:39PM by xtreem-solutions
Simple server side cache for Express.js with Node.js
https://ift.tt/2uzTWoX
Submitted September 20, 2018 at 12:12PM by hamsa_hiennv
Submitted September 20, 2018 at 12:12PM by hamsa_hiennv
Eleven Tips to Scale Node.js
https://ift.tt/2DabUnJ
Submitted September 20, 2018 at 11:41AM by ConfidentMushroom
Submitted September 20, 2018 at 11:41AM by ConfidentMushroom
Help needed reading mail inbox
I want to create an email fetching application having the following operations like save mail in db, save the attachment if found, Mark that mail as read. Has anyone done that before? I am not looking for solution but the way it can be done I have been trying that for days but I am not able to do these operation single atomic operation. I have tried the following package mail-notifier, mail-listener2 and imap
Submitted September 20, 2018 at 10:47AM by nitty727
Submitted September 20, 2018 at 10:47AM by nitty727
Why Node.js is Preferable for Web App Development
There are several reasons to prove node.js 's candidacy but some of are as Below:why nodejs for web app backend-- Node.js can increase any framework’s speed. [Developers need to do is write the program correctly and Node.js applications will adhere to the steps prescribed.]-- encourages sharing with the presence of the NPM, developer can reuse codes with utmost ease [Therefore, it can be stated that Node.js package manager is robust and a consistent solution for developers.]-- Data streaming in Node.js is like work with data uploading in real time. [The fact that data streaming wins with Node.js can actually be leveraged by developers to take extraordinary advantage when creating features like – processing files while they are being uploaded.]-- Node.js can be used as proxy server if an enterprise lacks its professional proxy infrastructure.-- easy to send and synchronise the data between these two points [helping developers to save time.]So instead of thinking for one time, better to think for long term and work according to it.
Submitted September 20, 2018 at 10:27AM by DSinghavi
Submitted September 20, 2018 at 10:27AM by DSinghavi
How can I handle randomized selectors?
I'm trying to post things to Facebook automatically via Puppeteer.The selector I'm trying to click is:#u_0_2e > div._sa_._gsd._fgm._5vsi._192z._1sz4._1i6z > div > div > div > div._3399._a7s._20h6._610i._610j._125r._2h27.clearfix._zw3 > div._524d > div > span:nth-child(3) However, it will randomly change from #u_0_2e to #u_0_2f or something similar. It's incredibly frustrating.Essentially what I'm trying to automate is if I post something to my Facebook page, it will take the link, click "Share" and automatically share it to another page that I select. However, Facebook's randomized selectors makes this next to impossible.I've tried searching for a solution, but I cannot find a single thing that will help me with this that will apply to async code.I just need something that will click the "Share" button, type in a phrase, and click "Share post to page."The usage for this is that if I post something to FB while mobile, it will automatically share it for me so that way I won't have to do it manually on mobile, which takes forever. Additionally, if I schedule posts, I want it to be able to be shared automatically. It's only shared in three locations on FB, so I do not plan on spamming.My backup ideas include:-try/catch. If there's an error finding selector 1, then try selector 2, etc.-clicking specific coordinates on the page-somehow figuring out how to search the text and click it, but ensuring that it matches the specific text I'm looking forAny help would be appreciated, thanks!
Submitted September 20, 2018 at 08:17AM by Lark_vi_Britannia
Submitted September 20, 2018 at 08:17AM by Lark_vi_Britannia
How do I pass data to a handlebars partial template?
So, I'm injecting the navbar into the main layout like this. Now, I wanna conditionally display the "Login" and "Logout" links in the navbar, depending on whether the use is logged in or not (obviously). In the app, I'm passing the user as req.user when rendering the "home" page, but I don't know how to utilise the user object in the navbar. Help!!! I'm a noob.
Submitted September 20, 2018 at 08:02AM by ncubez
Submitted September 20, 2018 at 08:02AM by ncubez
Wednesday, 19 September 2018
Proxy replacement tool for mac
https://ift.tt/2PMIBsT
Submitted September 19, 2018 at 09:27PM by indatawetrust
Submitted September 19, 2018 at 09:27PM by indatawetrust
How to Build a Smile Tracking Bot with Ziggeo and OpenCV for Node
https://www.youtube.com/watch?v=ArIXnKd3z5Y
Submitted September 19, 2018 at 07:20PM by darosati
Submitted September 19, 2018 at 07:20PM by darosati
Руководство по Node.js, часть 3: хостинг, REPL, работа с консолью, модули / Блог компании RUVDS.com / Хабр
https://ift.tt/2PO6pMZ
Submitted September 19, 2018 at 06:49PM by ICYMI_email
Submitted September 19, 2018 at 06:49PM by ICYMI_email
Why we're ditching Ruby on Rails for JavaScript & Node.js
https://ift.tt/2D8XcgO
Submitted September 19, 2018 at 06:14PM by sandrobfc
Submitted September 19, 2018 at 06:14PM by sandrobfc
Developing Modern APIs with Hapi.js, Node.js, and Redis
https://ift.tt/2Dc2ZlR
Submitted September 19, 2018 at 04:56PM by Ramirond
Submitted September 19, 2018 at 04:56PM by Ramirond
How should I handle unhandled promises node.js?
Should I do:Todo.find().then((todos)=>{ res.render('home', {todos}); },(e)=>{ res.status(400).send(e); }); Which means passing an arrow function to catch an error, or:Todo.find().then((todos)=>{ res.render('home', {todos}); }).catch((e)=>{ res.status(400).send(e); }); Remove the arrow function to catch an error and use a catch promise?
Submitted September 19, 2018 at 03:17PM by its_joao
Submitted September 19, 2018 at 03:17PM by its_joao
Last couple of weeks I've been working on Node.js and metrics using Open Source projects
https://www.youtube.com/watch?v=zswWV5bbhGo
Submitted September 19, 2018 at 02:34PM by a0viedo
Submitted September 19, 2018 at 02:34PM by a0viedo
Passport failure redirect, react
Hi, I use axios to send a post request to my node js server. Then I use passport to authenticate the user. If the username and password are correct everything works fine. Unfortunately when one of them is incorrect my front end shows an error. I guess that happens because the passport.authenticate() middleware doesn't allow to access that route. I know that passport has something like a failure redirect but it doesn't work with react. Thanks for any help :)
Submitted September 19, 2018 at 02:45PM by everek123
Submitted September 19, 2018 at 02:45PM by everek123
How implement nwjc to express application?
I am developing a desktop application with nwjs, I used nw-create-react-app boilerplate and added express.js for server side code, the problem is that I am trying to protect the source code of my server side, nwjs has the nwjc tool to compile js but can not find a way to implement it to my express.js application. I would appreciate any help
Submitted September 19, 2018 at 02:58PM by jd0m
Submitted September 19, 2018 at 02:58PM by jd0m
CSS and JS not loading - node.js and Express
404my server side fileapp.use(express.static(__dirname + '/pub')); my client side file my project structurestructureI have tried with and without the forward slash in both the script and link tags (src="pub/js/index.js") but nothing is working.It works if hard coded inside the home.hbs.What do you think this is?
Submitted September 19, 2018 at 02:09PM by its_joao
Submitted September 19, 2018 at 02:09PM by its_joao
diff between http request and http connect?
I want to know about https ,in net module there is net.connect(). And in http there is http.request() or get(), what is the difference between these two?
Submitted September 19, 2018 at 01:13PM by mohamedimy
Submitted September 19, 2018 at 01:13PM by mohamedimy
How to boilerplate/bootstrap a REST API on NodeJS
Hi.I'm about to start a new NodeJS project for building a REST API. Which boilerplate/bootstrap code do you recommend me looking into for setting the project up?I need something like Swagger/OpenAPI, and I need to be able to implement a test driven development workflow so testing (with database mocking etc) will be important. Also, I'll be building the API on top of a PostreSQL server. The API will be run in Docker.
Submitted September 19, 2018 at 12:28PM by kenneho
Submitted September 19, 2018 at 12:28PM by kenneho
Subscribe to:
Posts (Atom)