Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Let’s build something that might be useful to us—an app server. Our spec for our server is going to be pretty simple. It’s going to look at the requests that come in and then do one of three things. If the file requested is a JavaScript file, it is going to look in the src directory for the corresponding CoffeeScript file, compile that file into JavaScript, and return that. If the requested file or path is not JavaScript, the server will find the corresponding file in the public directory and serve up that file. Finally, if there is no matching CoffeeScript in the src directory or no matching file in the public directory, the server should respond with a simple 404 page.
We know what we want to build, but before we build it, you should know that the code we will build in this section is going to get a bit big, and we’re going to be iterating over it. Because of this, I am not going to show you the compiled JavaScript until we have finished writing our server. Trust me, you will thank me for it. Now, let’s get building.