Your Choice JavaScript News

Node News Thursday, April 26 Data, Query language, Function & more…


What’s new?

  • Essentially, were going to issue every GraphQL query to that single endpoint and it will respond with the correct data based on our schema and resolvers.
  • Now that we have the application foundation in place, lets figure out a schema and the resolvers for actually linking the data to potential queries and data types.
  • The data models for GraphQL are already in place, but we havent defined the possible queries or mutations.
  • Lets modify the schema in our application to look like the following: – – For both the queries and mutations, special resolver functions will be called which do the heavy lifting.
  • After weve filled our database with data, we could do a more sophisticated GraphQL query like the following: – – For the above query youd pass in a valid account and it would return the account information as well as the blog information that that account had written.

Tags: data, GraphQL, query language, NoSQL data layer, API endpoint


  • Lets explore a simple example of a typical asynchronous Node function thats written with a callback style: – const readFileAsArray = function(file, cb) { – fs.readFile(file, function(err, data) { – if (err) { – return cb(err); – } const lines = cb(null, lines); – }); – };readFileAsArray takes a file…
  • Assuming that we have the file numbers.txt in the same directory with content like this: – 10 – 11 – 12 – 13 – 14 – 15If we have a task to count the odd numbers in that file, we can use readFileAsArray to simplify the (err, lines) = {…
  • Heres the readFileAsArray function modified to support a promise interface in addition to the callback interface it already supports: – const readFileAsArray = function(file, cb = () = {}) { – return new Promise((resolve, reject) = { – fs.readFile(file, function(err, data) { – if (err) { – reject(err); – return…
  • Heres how we can consume the readFileAsArray function with async/await: – async function countOdd () { – try { – const lines = await readFileAsArray(‘.
  • class MyEmitter extends EventEmitter { – – }Emitter objects are what we instantiate from the EventEmitter-based classes: – const myEmitter = new MyEmitter();At any point in the lifecycle of those emitter objects, we can use the emit function to emit any named event we an event is the signal that…

Tags: function, err, async/await feature, events, data


  • –UPLOAD– – form #f=ngForm enctype=multipart/form-data novalidate – *ngIf=currentStatus === STATUS_INITIAL || currentStatus === STATUS_SAVING – h1Upload images/h1 – div class=dropbox – input type=file multiple – [name]=uploadFieldName $event.target.files) – [disabled]=currentStatus === STATUS_SAVING accept=image/* #photos – p *ngIf=currentStatus === STATUS_INITIAL – Drag your file(s) here to beginbr – or click to browse…
  • dropbox:hover { – background: lightblue; /* when mouse over to the drop zone, change color */ – } – – input[type=file] { – opacity: 0; /* invisible but it’s there!
  • @Component({ – selector: ‘page-file-upload’, – templateUrl: styleUrls: class PageFileUploadComponent { – – uploadedFiles = []; – uploadError; – currentStatus: number; – uploadFieldName = ‘photos’; – – readonly STATUS_INITIAL = 0; – readonly STATUS_SAVING = 1; – readonly STATUS_SUCCESS = 2; – readonly STATUS_FAILED = 3; – – constructor(private _svc: FileUploadService)…
  • concat(x); – this.currentStatus = this.STATUS_SUCCESS; – }, err = { – this.uploadError = err; – this.currentStatus = this.STATUS_FAILED; – }) – } – } – – Notes:- – – – Later on, we will call the Hapi.js file upload API to upload images, the API accept a field call photos….
  • service.ts – – import { Injectable } from ‘@angular/core’; – import { Http, RequestOptionsArgs, Headers } from class FileUploadService { – – baseUrl = ‘http://localhost:3001’; // our local Hapi Js API – – constructor(private _http: Http) { } – – upload(formData) { – const url = return this.

Tags: file upload, file upload component, file upload service, Angular file upload, upload file type


  • SDK Platform: Node.js Active Channels: Web Chat Deployment Environment: Azure Bot Service Can we create persistent menu button in the typing bar of bot in Node.js?
  • enter image description here Please refer image: I want to add a menu button in typing bar of bot.

Tags: Azure Bot Service, persistent menu button, Web Chat Deployment, Node.js Active Channels, enter image description


  • Node.js 10.0.0 has been released, and will become the platforms Long Term Support (LTS) line in October 2018.
  • x line will be upgraded to NPM Version 6 later on; NPM 6 will offer performance, stability, and security improvements.
  • In addition to OpenSSL 1.1.0 support, other features in the Node.js 10.0.0 release include: – – Later versions of the Node.js 10.
  • x line are expected to offer: – – The following features are expected to arrive in Node.js 11.
  • x: – – Other efforts in the Node.js project, not directly tied to the Node.js 10 or Node.js 11 release lines, include: – – You can download Node.js from the project website.

Tags: Long Term Support, LTS line, incremental improvements, Node.js, add supports


Top Node Courses

The Complete Node.js Developer Course (2nd Edition) (60,232 students enrolled)

By Andrew Mead
  • Build, test, and launch Node apps
  • Create Express web servers and APIs
  • Store data with Mongoose and MongoDB
  • Use cutting-edge ES6/ES7 JavaScript
  • Deploy your Node apps to production
  • Create real-time web apps with SocketIO

Learn more.


Angular (Angular 2+) & NodeJS - The MEAN Stack Guide (26,806 students enrolled)

By Maximilian Schwarzmüller
  • Build real Angular + NodeJS applications
  • Understand how Angular works and how it interacts with Backends
  • Connect any Angular Frontend with a NodeJS Backend
  • Use MongoDB with Mongoose to interact with Data on the Backend
  • Use ExpressJS as a NodeJS Framework
  • Provide a great user experience by using Optimistic Updating on the Frontend
  • Improve any Angular (+ NodeJS) application by adding Error Handling

Learn more.