随笔分类 - Node.js
摘要:Sometimes you are one or two lines short from finding the cause of the error in the stack trace but you can't because Nodejs displays only a handful o
阅读全文
摘要:Sometimes, you might want to convert a JavaScript function that accepts a callback to one that returns a Promiseobject. This lesson shows how to manua
阅读全文
摘要:Downloading and saving a file is a common scenario when building out your web application. Using Express, you can either trigger a download from an ex
阅读全文
摘要:Given a epxress application and an svg template, we want to draw some text, date onto it and convert it to pdf as output. Code: Github
阅读全文
摘要:Npm by default uses global values when initializing a new package.json file. Learn how to set your own global default values by command line or editin
阅读全文
摘要:We'll read a csv file in node.js both synchronously, and asynchronously. The file we're reading is a plain text, utf8 file - but you can also use fs.r
阅读全文
摘要:In node.js, you can require fs, and then call fs.writeFile with the filename, and data to write to that file (as a string or a buffer). That will over
阅读全文
摘要:Winston is a popular logging library for NodeJS which allows you to customise the output, as well as different logging targets. This lesson covers con
阅读全文
摘要:Github To stop having to change configuration settings in production code and to stop secure information like usernames and password being stored in s
阅读全文
摘要:Use can use colour and styles to make it easy to spot errors and group common functionality into blocks when viewing a NodeJS console. This lesson wil
阅读全文
摘要:High availability apps require that no distinction be made between local and remote services. Attached resources should be accessed by environment var
阅读全文
摘要:Storing configuration in files instead of the environment has many downsides, including mistakenly checking in the wrong configuration in the wrong en
阅读全文
摘要:In this lesson we create a new Express web server app for handling file uploads and persisting them to the filesystem. We will walk through using the
阅读全文
摘要:When we want to update our package we need to do a few things: pull latest from our git remote, bump the npm version and git tag, push to our remote,
阅读全文
摘要:In this lesson we will publish our package. We will first add a prepublish script that runs our buildscript; this will ensure the built folder gets ad
阅读全文
摘要:We will import our newly published package into a new project locally to make sure everything is working as expected. We can do this locally before pu
阅读全文
摘要:For intergration tests, always remember when you create a 'mass' you should aslo clean up the 'mass'. For example when you start the server, you need
阅读全文
摘要: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
阅读全文