Authentication
- Explain what a “Singleton” is (in Computer Science terms)
- It is a class that allows only a single instance of itself to be created and gives access to that created instance
- Explain how the Singleton pattern can be used with Node modules, specifically with classes
- A singleton represents a single instance of an object. Only one can be created, no matter how many times the object is instantiated. If there’s already an instance, the singleton will create a new one.
- If you were tasked with building a middleware system like Express uses, what approach might you take to construct/operate it?
- use Singleton to prevent other objects from instantiating their own copies of the Singleton object, ensuring that all objects access the single instance
Document the following Vocabulary Terms
-
Router Middleware: a piece of code that comes in the middle of request and response
-
Dynamic Module Loading: a mechanism by which a computer program can, at run time, load a library (or other binary) into memory
-
Singleton Pattern: it restricts the instantiation of a class to one single instance
-
CRUD -> REST Method Matches
- create–POST
- read–GET
- update–PUT
- delete–DELETE
-
Mock Testing
- creating a fake version of an external or internal service that can stand in for the real one, helping your tests run more quickly and more reliably