From the course: Node.js: Design Patterns

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Implementing commands

Implementing commands - Node.js Tutorial

From the course: Node.js: Design Patterns

Start my 1-month free trial

Implementing commands

- [Instructor] In the last lesson we introduced the command pattern and we saw how we can incorporate that pattern into an already existing node app that implemented a read line interface. In this lesson, we're going to implement the conductor that we're importing, as well as each command class that we're importing online, too. So I'm in the exercise files, under chapter four lesson four, within the start folder. And I'm going to go ahead and create a new file called commands.js. And I'm going to go ahead and put all of my command classes within this file. So we're going to need to create a class for the exit command and we're also going to need to create one for create command. And then I'm just going to make sure that I export both of these. Great, so now we have both classes and we're ready to export them. Let's go ahead and write the code for our exit command. So I'm going to write a getter to get the name of this command. So we'll just go ahead and return a string. This is an…

Contents