Learning web development: Authenticating users with plain Node.js
Briefly

Learning web development: Authenticating users with plain Node.js
"To make importing more flexible, JavaScript also lets us dynamically import modules via import() (an operator that is used like a function). It works like a namespace import and returns a Promise for an object whose properties are the exports of the imported module: const {getHashForText} = await import('./server/crypto-tools.js'); 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' crypto-tools.js is a utility library in our current project. We use object destructuring to access its export getHashForText. It's an asynchronous function - which is why we use await to retrieve its result."
"Parameter default values # A parameter default value is an assignment we make to a parameter. It is performed whenever the parameter is missing: Normal import statements are called static imports: They can only exist at the top level of a module. Their module specifiers are fixed strings. Base64: encoding binary data as strings # Base64 is a way to encode binary data as text. That enables us to store binary data in formats that only support text (such as HTML or JSON). The 64 in "Base64" means t"
The project builds a web server that protects pages with passwords using HTTP authentication. JavaScript parameter default values provide fallback assignments when parameters are missing. Normal import statements are static imports that must appear at the top level and use fixed string specifiers. Dynamic import() allows runtime-determined module specifiers, returns a Promise, and can be awaited to retrieve exported members. The example uses await import('./server/crypto-tools.js') and object destructuring to obtain an async getHashForText function for hashing. Base64 encodes binary data as text so it can be stored in text-only formats like HTML or JSON.
Read at 2ality
Unable to calculate read time
[
|
]