From the course: Node.js: Design Patterns

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Implementing a proxy

Implementing a proxy

- [Instructor] In the last lesson, we defined the proxy pattern, as well as we introduced some code where we might be able to use a proxy. So, currently we're looking at the files within our exercise files, under chapter three, lesson four, within the start folder, and we're taking a look at the index.js file, which is allowing us to read both text and Markdown files. Now, a proxy is an object that controls access to another object. There are a number of wonderful things that you can do with a proxy, and one of those is restricting access to the actual object. So that's what we're going to do. We're going to create a file system proxy that only allows us to read Markdown files, it won't let us read any files of any other types. So, when we create our proxy, what I'm going to do inside of the index.js file, is use it. So, we're going to create something called a FS_Proxy, and now I'm going to go ahead and use the FS_Proxy…

Contents