随笔分类 - Node.js
摘要:We have express app: As you can see, we wrap Express App into a function 'startServer' and export it as default export. The return value of this funct
阅读全文
摘要:Stateful session management: Store session which associate with user, and store in the menory on server. Sign Up: Password validation: Random bytes ge
阅读全文
摘要:In this lesson we will find out how to serve static assets (images, css, stylesheets, etc.) with Express. We will go over writing initial boilerplate
阅读全文
摘要:Since Node.js V8.0+, it introduces a 'util' libaray, which has a 'promisfy' function. It can conver a callback based function to promise based functio
阅读全文
摘要:Learn how to setup an Nginx proxy server that sits in front of a Node.js app. You can use a proxy to control the flow of frontend requests hitting you
阅读全文
摘要:In the past, you've needed to either write a package.json script or use the node_modules/.bin directory to access binaries installed in your node_modu
阅读全文
摘要:As node projects evolve, new features are added all the time. This results in different errors or results as you're migrating from one version to anot
阅读全文
摘要:When we try to do MongoDB opration, mongoose return Promise, we can use async/await to simply the code: The problme here is no error handling, we can
阅读全文
摘要:Mixin works as a function. Here, we use include keyword to inlcude a mixin file. Exec a mixin function we can use '+': Define a mixin: Here we use som
阅读全文
摘要:Mongoose has some hooks, for example: Before 'save' action, will trigger the function to generate the 'slug' JIT.
阅读全文
摘要:In this lesson we'll show how to use yarn to alias the names of same npm libraries but install different versions. This could allow for easy migrating
阅读全文
摘要:We can create Template Helpers, which can contains some common reuseable data and libs. Then you can define a locals data in middleware: Require helpe
阅读全文
摘要:Looking at the follow code: 1. .wapper: div with wrapper class By defualt it consider as div class if you don't wirte div, just give a class name. 2.
阅读全文
摘要:In this lesson we'll use cjs-to-es6 to convert CommonJS requires to ES6 imports. We'll also show how to convert over a exported default object to take
阅读全文
摘要:Install: For example, we can store the sensitive information or env related information in a 'veriables.env' file: Then we can use dotenv to load thos
阅读全文
摘要:In this lesson we'll show how to setup a .babelrc file with presets and plugins. Then create npm scripts that use babel-node and babel. With babel-pre
阅读全文
摘要:In this lesson you will learn what a LoopBack model is, you will create a Product model using the LoopbBack CLI. The product model will be based off t
阅读全文
摘要:In this lesson, we will use Chai's request method to test our Node application's API responses.By the end of this lesson, you will know how to:- insta
阅读全文
摘要:When developing responsive websites, you will constantly be resizing your browser to make sure your site is properly responding to all of the resizes.
阅读全文
摘要:LoopBack is a framework built on top of Express for creating APIs. It allows you to create end-to-end REST APIs that can access data from many data so
阅读全文