@@ -35,17 +35,12 @@ Get the version 8 or higher. If you don't have Node.js installed, or if your ver |
35 | 35 | You can use one of these tools for version management (i.e., switching |
36 | 36 | between Node.js versions): |
37 | 37 |
|
38 | | -- [n](https://github.com/tj/n) (<https://github.com/tj/n>) |
| 38 | +- `n`: <https://npmjs.com/n> |
| 39 | +- `nave`: <https://npmjs.com/nave> |
| 40 | +- `nvm`: <https://npmjs.com/nvm> |
| 41 | +- `nvm-windows`: <https://github.com/coreybutler/nvm-windows> |
39 | 42 |
|
40 | | -- [nave](https://github.com/isaacs/nave) (<https://github.com/isaacs/nave>) |
41 | | - |
42 | | -- [nvm](https://github.com/creationix/nvm) (<https://github.com/creationix/nvm>) |
43 | | - |
44 | | -As usual, you could copy the example code at |
45 | | -https://github.com/azat-co/fullstack-javascript/tree/master/code/06-hello, TK or |
46 | | -write your own program from scratch. If you wish to do the latter, |
47 | | -create a folder `hello` for your "Hello World" Node.js application. Then |
48 | | -create a file `server.js` and line by line type the code below. |
| 43 | +As usual, you could copy the example code at <http://bit.ly/2Lbvxzr>, or write your own program from scratch. If you wish to do the latter, create a folder `hello` for your "Hello World" Node.js application. Then create a file `server.js` and line by line type the code below. |
49 | 44 |
|
50 | 45 | This line will load the core `http` module for the server (more on the |
51 | 46 | modules later): |
@@ -129,8 +124,6 @@ the main methods: |
129 | 124 | - `http.createServer()`: Returns a new web server object |
130 | 125 | - `http.listen()`: Begins accepting connections on the specified |
131 | 126 | port and hostname |
132 | | -- `http.createClient()`: Node.js app can be a client and make requests |
133 | | - to other servers TK |
134 | 127 | - `http.ServerRequest()`: Passes incoming requests to request |
135 | 128 | handlers |
136 | 129 | - `data`: Emitted when a piece of the message body is received |
@@ -336,15 +329,12 @@ To push changes, just execute: |
336 | 329 | $ git commit -m "changing to hello azure" |
337 | 330 | $ git push azure master |
338 | 331 |
|
339 | | -A more meticulous guide can be found in the tutorial <https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs>. TK |
| 332 | +A more meticulous guide can be found in the tutorial <http://bit.ly/2LbXQOi>. |
340 | 333 |
|
341 | 334 | Deploying to Heroku |
342 | 335 | =================== |
343 | 336 |
|
344 | | -For Heroku deployment, we need to create two extra files: `Procfile` and |
345 | | -`package.json`. You could get the source code from |
346 | | -<https://github.com/azat-co/fullstack-javascript/tree/master/code/06-hello> TK or |
347 | | -write your own one. |
| 337 | +For Heroku deployment, we need to create two extra files: `Procfile` and `package.json`. You could get the source code from <http://bit.ly/2Lbvxzr> or write your own one. |
348 | 338 |
|
349 | 339 | The structure of the "Hello World" application looks like this: |
350 | 340 |
|
@@ -713,40 +703,26 @@ frameworks like Express.js or Restify but there are many powerful and useful fra |
713 | 703 | - [Restify](http://mcavage.github.com/node-restify) (<http://restify.com>): Lightweight framework for REST API servers |
714 | 704 | - [Sails](http://sailsjs.org) (<http://sailsjs.org>): MVC Node.js framework with rich scaffolding |
715 | 705 | - [hapi](https://hapijs.com) (<https://hapijs.com>): Node.js framework built on top of Express.js |
716 | | -- [Connect](http://www.senchalabs.org/connect) (<https://github.com/senchalabs/connect#readme>): a middleware framework for Node.js, shipping with over 18 bundled middlewares and a rich selection of third-party middleware |
717 | | -- [GeddyJS](http://geddyjs.org) (<http://geddyjs.org>): a simple, structured MVC web framework for Node |
718 | | -- [CompoundJS](http://compoundjs.com) (<http://compoundjs.com>) (ex-RailswayJS): Node.JS MVC framework based on ExpressJS |
719 | | -- [Tower.js](http://towerjs.org) (<http://tower.github.io>): a full stack web framework for Node.js and the browser |
720 | | -- [Meteor](http://meteor.com) (<https://www.meteor.com>): open-source platform for building top-quality web apps in a fraction of the time |
| 706 | +- [Connect](http://www.senchalabs.org/connect) (<https://github.com/senchalabs/connect>): Middleware framework for Node.js, shipping with over 18 bundled middlewares and a rich selection of third-party middleware |
| 707 | +- [GeddyJS](http://geddyjs.org) (<http://geddyjs.org>): Simple, structured MVC web framework for Node |
| 708 | +- [CompoundJS](http://compoundjs.com) (<http://compoundjs.com>) (ex-RailswayJS): Node.js MVC framework based on Express.js |
| 709 | +- [Tower.js](http://towerjs.org) (<http://tower.github.io>): Full stack web framework for Node.js and the browser |
| 710 | +- [Meteor](http://meteor.com) (<https://www.meteor.com>): Open-source platform for building top-quality web apps in a fraction of the time |
721 | 711 |
|
722 | | -For a list of hand-picked frameworks, take a look at |
723 | | -(<http://nodeframeworks.com>). Ways to improve the application: |
| 712 | +For a list of hand-picked Node.js frameworks, take a look at <http://nodeframeworks.com>. |
724 | 713 |
|
725 | | -- Improve existing test cases by adding object comparison instead of a |
726 | | - string one |
| 714 | +Next, I will explain a few ways to improve the REST API application. These are your assignments to give you more practice and make the learning more effective: |
727 | 715 |
|
| 716 | +- Improve existing test cases by adding object comparison instead of a string one |
728 | 717 | - Move the seed data to `test.js` from `mb-server.js` |
| 718 | +- Add test cases to support your frontend (e.g., up vote, user login) |
| 719 | +- Add methods to support your frontend (e.g., up-vote, user login) |
| 720 | +- Generate unique IDs for each message and store them in a Hash instead of an Array |
| 721 | +- Install Mocha and re-factor `test.js` so it uses this library |
729 | 722 |
|
730 | | -- Add test cases to support your front-end (e.g., up-vote, user |
731 | | - log in) |
732 | | - |
733 | | -- Add methods to support your front-end (e.g., up-vote, user log in) |
734 | | - |
735 | | -- Generate unique IDs for each message and store them in a Hash |
736 | | - instead of an Array |
737 | | - |
738 | | -- Install Mocha and re-factor test.js so it uses this library |
739 | | - |
740 | | -So far we've been storing our messages in the application memory, so |
741 | | -each time the application is restarted, we lose it. To fix it, we need |
742 | | -to add a persistence, and one of the ways is to use a database like |
743 | | -MongoDB. |
| 723 | +So far we've been storing our messages in the application memory, so each time the application is restarted, we lose our messages. To fix it, we need to add persistence (more permanent store), and one of the best ways is to use a database like MongoDB, introduced in the next chapter. |
744 | 724 |
|
745 | 725 | Summary |
746 | 726 | ------- |
747 | 727 |
|
748 | | -In this chapter we've covered important topics that will lay the |
749 | | -foundation. They exhibit the "Hello World" application in Node.js, list |
750 | | -of some of its most important core modules, npm workflow, detailed |
751 | | -commands for deployment of Node.js apps to Heroku and Microsoft Azure; and |
752 | | -an example of a test-driven development practice. |
| 728 | +In this chapter we've covered important topics that will lay the foundation for all of your future Node.js development. This chapter taught the "Hello World" application in Node.js, listed of some of its most important Node.js core modules, explained the npm workflow, covered test-driven development practice, and provided detailed commands for deployment of Node.js apps to the Heroku and Microsoft Azure cloud services. |