r.dbCreate('mydb')
- Passwords will contain at least 1 upper case letter
- Passwords will contain at least 1 lower case letter
- Passwords will contain at least 1 number or special character
- There is no length validation (min, max) in this regex!
Regular expression for JavaScript:
/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/
This gist will walk you through configuring your Node.js Project so that you can write your code in TypeScript using Visual Studio Code. These isntructions were written for attendees at Microsoft Build doing a super secret thing I can't talk about (ooo, the suspense!), but they also will work for any Node.js project written in TypeScript.
Before we get started configuring TypeScript, we need to initialize a new Node.js project. If you have not already installed Node.js, please head over to nodejs.org and install the latest LTS version of Node.js. Once this is done, create a folder for your Node.js project and open a terminal in this folder. In the terminal, run the command:
npm init
This command will ask you a series of questions. You can use the defaults for each question here because they don't really matter. These only matter if you intend to publish your module to [npmjs.com](htt
You should almost never actually use this. The same applies to fs.stat (when used for checking existence).
Checking whether a file exists before doing something with it, can lead to race conditions in your application. Race conditions are extremely hard to debug and, depending on where they occur, they can lead to data loss or security holes. Using the synchronous versions will not fix this.
Generally, just do what you want to do, and handle the error if it doesn't work. This is much safer.
- If you want to check whether a file exists, before reading it: just try to open the file, and handle the
ENOENTerror when it doesn't exist. - If you want to make sure a file doesn't exist, before writing to it: open the file using an exclusive mode, eg.
wxorax, and handle the error when the file already exists.