Your Choice JavaScript News

Node News Wednesday, February 14

Node News TLDR / Table of Contents

  • dthree/vorpal
    • vorpal – Node’s framework for interactive CLIs
    • Vorpal, Vorpal commands, immersive CLI, immersive CLI environments, CLI applications
  • Using Node.js require vs. ES6 import/export
    • Are there any performance benefits to using one over the other? Is there anything else that we should know if we were to use ES6 modules over Node ones?
    • Felix Kling Jul, es6 modules, module loader, ,
  • jeffijoe/yenv
    • yenv – Environment management for Node using YAML.
    • too. const env, base config development, Declare additional settings, yenv, base config.. base
  • Writing fast and safe native Node.js modules with Rust | @RisingStack
    • In this Rust tutorial, I’m going to walk you through the steps of writing a modern, fast and safe native Node.js module.
    • Rust, Rust code, Rust FFI, working Rust code, previous Rust blogpost
  • pimterry/mockttp
    • mockttp – :globe_with_meridians: Powerful friendly HTTP mock server for integration tests
    • requests, Safely mock HTTP, fake HTTP responses, real HTTP requests, HTTP mocking proxy
  • How to Mock an Express session? – Node.js Collection –
    • Are you using an Express app and need to add unit testing? Here’s what I discovered when I was trying to do this for a project that I worked on. This article covers the background around the…
    • express app, test case, session, Express session, unit testing
  • YouTube
    • 발표자: 변정훈 (닉네임: outsider) 발표일: 2018.1. Node.js로 작성한 API 서버의 성능을 개선하는 과정을 설명합니다. Node.js 성능 튜닝 팁을 정리하는 내용이라기 보다는 실제 애플리케이션에서 성능을 측정하고 개선점을 찾기 위해서 과정을 설명합니다. St…
    • upload original content, YouTube, , ,
  • Vorpal is Node’s first framework for building interactive CLI applications.
  • With a simple and powerful API, Vorpal opens the door to a new breed of rich, immersive CLI environments like cash and wat.
  • Inspired by and based on commander.js, Vorpal is a framework for building immersive CLI applications built on an interactive prompt provided by inquirer.js.
  • Vorpal launches Node into an isolated CLI environment and provides a suite of API commands and functionality including: – – Vorpal supports community extensions, which empower it to do awesome things such as piping commands to less, importing commands live or supporting a built-in REPL.
  • Create a file and add the following: – – This creates an instance of Vorpal, adds a command which logs bar, sets the prompt delimiter to say myapp$, and shows the prompt.

Tags: Vorpal, Vorpal commands, immersive CLI, immersive CLI environments, CLI applications

  • The current answer is no, because none of the current browser engines implements from the ES6 standard.
  • keyword from ES6 hasn’t been taken into account.
  • In other words, current browser engines including V8 cannot import new JavaScript file from the main JavaScript file via any JavaScript directive.
  • And the ES6 standard said that the module dependencies should be there before we read the module like in the programming language C, where we had (headers) files.
  • This is a good and well-tested structure, and I am sure the experts that created the ES6 standard had that in mind.

Tags: Felix Kling Jul, es6 modules, module loader, ,

  • Sensitive configuration should always be defined in the actual environment variables and not committed to source control!
  • Strict Mode will throw an error when accessing unknown keys.
  • This example shows the possible ways to configure Strict Mode: – – supports composing sections together.
  • : : : : : : – – supports importing files recursively, with the importer winning in case of duplicate variables.
  • Example: printing the environment in as , sorted alphabetically ( = sort), and excluding the actual user environment ( = file only): – – Example: same as above, but in mode ( ) – – Example: same as above, but in format – – Please see for info.

Tags: too. const env, base config development, Declare additional settings, yenv, base config.. base

  • The reason for writing this story/tutorial is that just a few weeks ago I realized that we could have optimized URL parsing in an other way – by writing a native library with Rust.
  • While that implementation can be easily called from Node.js using the N-API, I have a few reasons not to do so: – – So I’d much prefer a more approachable language, with an easy to use update mechanism and modern tooling: Rust!
  • The crate is a Rust library with native bindings to the types and functions commonly found on various systems, including libc.
  • This allows us to use C types from our Rust code, which we will have to do if we’d like to accept or return anything from our Rust functions.
  • Neon allows us to use JavaScript types in our Rust code.

Tags: Rust, Rust code, Rust FFI, working Rust code, previous Rust blogpost

  • Mockttp lets you quickly & reliably fake HTTP responses for testing, and assert on the requests made by your code.
  • Mockttp allows you to do accurate true integration testing, writing one set of tests that works out of the box in node or browsers, with support for transparent proxying & HTTPS, strong typing & promises throughout, fast & safe parallel testing, and helpful built-in debuggability support all the way down….
  • To run an HTTP integration test, you need to: – – Here’s a simple minimal example of all that using plain promises, Mocha, Chai & Superagent, which works out of the box in Node and modern browsers: – – That is pretty easy, but we can make this simpler &…
  • ( ); }); ( lets you verify the request details the mockttp server receives , () { endpointMock .
  • ; }); }); – – These examples uses Mocha, Chai and Superagent, but none of those are required: Mockttp will work with any testing tools that can handle promises (and with minor tweaks, many that can’t), and can mock requests from any library, tool or device you might care to…

Tags: requests, Safely mock HTTP, fake HTTP responses, real HTTP requests, HTTP mocking proxy

  • This article covers the background around the challenge that I faced when trying to add a unit test for an Express App, and a simple way to solve this.Hopefully, this helps those that might be facing the same problem.BackgroundI was tasked with working on a project where I was uploading…
  • Recently, however, I started adding test cases for different routes using mocha.
  • First route (create) set req.session value and redirect to the second one (submit).1) api/image/create2) api/image/submit (need to add a test case for this one)I just want to test second route (api/image/submit).
  • With mocha you can only check response from one route, you cant wait for the result from redirect call.Fixes that Seem Smart, but Pose More ChallengesThe easy solution to fix this issue is to send a req-param from the test case, and check it in method if that param is…
  • key is used to sign cookie value using Keygrip.I thought that I could fix this by setting req.session.count value in the test case, before calling the route.

Tags: express app, test case, session, Express session, unit testing

    Tags: upload original content, YouTube, , ,

    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.