GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix some links and tilde · kimi21/fullstack-javascript@ae61fa3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • chapter6
    • chapter6.md
  • chapter7
    • chapter7.md
  • chapter8
    • chapter8.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎chapter6/chapter6.md‎

Copy file name to clipboardExpand all lines: chapter6/chapter6.md
+55-55Lines changed: 55 additions & 55 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ latest version at [nodejs.org/\#download](http://nodejs.org/#download).
4848
You can use one of these tools for version management (i.e., switching
4949
between Node.js versions):
5050

51-
- [n](https://github.com/tj/n) (https://github.com/tj/n)
51+
- [n](https://github.com/tj/n) (<https://github.com/tj/n>)
5252

53-
- [nave](https://github.com/isaacs/nave) (https://github.com/isaacs/nave)
53+
- [nave](https://github.com/isaacs/nave) (<https://github.com/isaacs/nave>)
5454

55-
- [nvm](https://github.com/creationix/nvm) (https://github.com/creationix/nvm)
55+
- [nvm](https://github.com/creationix/nvm) (<https://github.com/creationix/nvm>)
5656

5757
As usual, you could copy example code at
5858
https://github.com/azat-co/fullstack-javascript/tree/master/07-hello, or
@@ -114,23 +114,23 @@ standard library. The core modules of node.js are a bare minimum and the
114114
rest can be cherry-picked via the Node Package Manager (NPM) registry.
115115
The main core modules, classes, methods, and events include:
116116

117-
- [http](http://nodejs.org/api/http.html#http_http)
118-
(https://nodejs.org/api/http.html\#http\_http): Module for working
117+
- [http](http://nodejs.org/api/http.html)
118+
(<https://nodejs.org/api/http.html>): Module for working
119119
with HTTP protocol
120120

121121
- [util](http://nodejs.org/api/util.html)
122-
(https://nodejs.org/api/util.html): Module with various helpers
122+
(<https://nodejs.org/api/util.html>): Module with various helpers
123123

124124
- [querystring](http://nodejs.org/api/querystring.html)
125-
(https://nodejs.org/api/querystring.html): Module for parsing query
125+
(<https://nodejs.org/api/querystring.html>): Module for parsing query
126126
string from the URI
127127

128128
- [url](http://nodejs.org/api/url.html)
129-
(https://nodejs.org/api/url.html): Module for parsing URI
129+
(<https://nodejs.org/api/url.html>): Module for parsing URI
130130
information
131131

132132
- [fs](http://nodejs.org/api/fs.html)
133-
(https://nodejs.org/api/fs.html): Module for working with the file
133+
(<https://nodejs.org/api/fs.html>): Module for working with the file
134134
system
135135

136136
These are the most important core modules. Let's cover each of them.
@@ -141,52 +141,52 @@ These are the most important core modules. Let's cover each of them.
141141
This is the main module responsible for Node.js HTTP server. Here are
142142
the main methods:
143143

144-
- `http.createServer``()`: returns a new web server object
144+
- `http.createServer()`: returns a new web server object
145145

146-
- `http.listen``()`: begins accepting connections on the specified
146+
- `http.listen()`: begins accepting connections on the specified
147147
port and hostname
148148

149-
- `http.createClient``()`: node app can be a client and make requests
149+
- `http.createClient()`: node app can be a client and make requests
150150
to other servers
151151

152-
- `http.ServerRequest``()`: incoming requests are passed to request
152+
- `http.ServerRequest()`: incoming requests are passed to request
153153
handlers
154154

155155
- `data`: emitted when a piece of the message body is received
156156

157157
- `end`: emitted exactly once for each request
158158

159-
- `request.method``()`: the request method as a string
159+
- `request.method()`: the request method as a string
160160

161161
- `request.url()`: request URL string
162162

163-
- `http.ServerResponse``()`: this object is created internally by an
163+
- `http.ServerResponse()`: this object is created internally by an
164164
HTTP server—not by the user, and used as an output of request
165165
handlers
166166

167-
- `response.writeHead``()`: sends a response header to the request
167+
- `response.writeHead()`: sends a response header to the request
168168

169-
- `response.write``()`: sends a response body
169+
- `response.write()`: sends a response body
170170

171-
- `response.end``()`: sends and ends a response body
171+
- `response.end()`: sends and ends a response body
172172

173173
###util
174174

175175

176176
This module provides utilities for debugging. Some of the methods
177177
include:
178178

179-
- `util.inspect``()`: Return a string representation of an object,
179+
- `util.inspect()`: Return a string representation of an object,
180180
which is useful for debugging
181181

182182
###querystring
183183

184184
This module provides utilities for dealing with query strings. Some of
185185
the methods include:
186186

187-
- `querystring.stringify``()`: Serialize an object to a query string
187+
- `querystring.stringify()`: Serialize an object to a query string
188188

189-
- `querystring.parse``()`: Deserialize a query string to an object
189+
- `querystring.parse()`: Deserialize a query string to an object
190190

191191
###url
192192

@@ -201,9 +201,9 @@ fs handles file system operations such as reading and writing to/from
201201
files. There are synchronous and asynchronous methods in the library.
202202
Some of the methods include:
203203

204-
- `fs.readFile``()`: reads file asynchronously
204+
- `fs.readFile()`: reads file asynchronously
205205

206-
- `fs.writeFile``()`: writes data to file asynchronously
206+
- `fs.writeFile()`: writes data to file asynchronously
207207

208208
There is no need to install or download core modules. To include them in
209209
your application, all you need is to follow the syntax:
@@ -425,10 +425,10 @@ Unit Testing Node.js
425425
We should have two methods:
426426

427427
1. Get all of the messages as an array of JSON objects for the GET
428-
`/message` endpoint using the `getMessages``()` method
428+
`/message` endpoint using the `getMessages()` method
429429

430430
2. Add a new message with properties `name` and `message` for POST
431-
`/messages` route via the `addMessage``()` function
431+
`/messages` route via the `addMessage()` function
432432

433433
We'll start by creating an empty `mb-server.js` file. After it's there,
434434
let's switch to tests and create the `test.js` file with the following
@@ -457,47 +457,47 @@ object with:
457457

458458
For testing our assumptions, we use core the Node.js module
459459
[assert](http://nodejs.org/api/assert.html). It provides a bunch of
460-
useful methods like `equal(``)`, `deepEqual``()`, etc.
460+
useful methods like `equal()`, `deepEqual()`, etc.
461461

462462
More advanced libraries include alternative interfaces with TDD and/or
463463
BDD approaches:
464464

465465
- [Expect](https://github.com/LearnBoost/expect.js): Minimalistic
466466
BDD-style assertion library:, for example,
467-
`expect(user.name).``to.eql``('azat')`
467+
`expect(user.name).to.eql('azat')`
468468

469469
- [Should](https://github.com/shouldjs/should.js)
470-
(https://github.com/shouldjs/should.js): BDD-style assertion library
470+
(<https://github.com/shouldjs/should.js>): BDD-style assertion library
471471
that works by modifying `Object.prototype`: for example,
472472
`user.name.should.be.eql``('azat')`
473473

474474
For more Test-Driven Development and cutting-edge automated testing, you
475475
could use the following libraries and modules:
476476

477-
- [Mocha](https://mochajs.org) (https://mochajs.org/): Feature-rich
477+
- [Mocha](https://mochajs.org) (<https://mochajs.org>): Feature-rich
478478
testing framework (my default choice)
479479

480480
- [NodeUnit](https://github.com/caolan/nodeunit)
481-
(https://github.com/caolan/nodeunit): Simple assert-style unit
481+
(<https://github.com/caolan/nodeunit>): Simple assert-style unit
482482
testing library
483483

484484
- [Jasmine](https://github.com/jasmine/jasmine)
485-
(https://github.com/jasmine/jasmine): BDD testing framework with
485+
(<https://github.com/jasmine/jasmine>): BDD testing framework with
486486
built-in assertion and spy (for mocking) libraries
487487

488-
- [Vows](http://vowsjs.org) (http://vowsjs.org/): BDD framework for
488+
- [Vows](http://vowsjs.org) (<http://vowsjs.org>): BDD framework for
489489
Node.js tailored to testing asynchronous code
490490

491-
- [Chai](http://chaijs.com) (http://chaijs.com/): BDD/TDD assertion
491+
- [Chai](http://chaijs.com) (<http://chaijs.com>): BDD/TDD assertion
492492
library that can be paired with a testing framework and has its own
493493
versions of Should, Expect, and Assert
494494

495495
- [Tape](https://github.com/substack/tape)
496-
(https://github.com/substack/tape): A minimalistic TAP (Test
496+
(<https://github.com/substack/tape>): A minimalistic TAP (Test
497497
Anything Protocol) library
498498

499499
- [Jest](https://facebook.github.io/jest)
500-
(http://facebook.github.io/jest/): Jasmine-and-Expect-like testing
500+
(<http://facebook.github.io/jest>): Jasmine-and-Expect-like testing
501501
library with automatic mocks
502502

503503
You could copy the "Hello World" script into the `mb-server.js` file for
@@ -509,7 +509,7 @@ We should see an error. Probably something like this one:
509509

510510
TypeError: Object #<Object> has no method 'getMessages'
511511

512-
That's totally fine, because we haven't written `getMessages``()`
512+
That's totally fine, because we haven't written `getMessages()`
513513
method yet. So let's do it and make our application more useful by
514514
adding two new methods: to get the list of the messages for Chat and to
515515
add a new message to the collection.
@@ -558,7 +558,7 @@ not to the main application code base.
558558
Our server code will look slightly more interesting. For getting the
559559
list of messages, according to REST methodology, we need to make a GET
560560
request. For creating/adding a new message, it should be a POST request.
561-
So in our createServer object, we should add `req.method``()` and
561+
So in our createServer object, we should add `req.method()` and
562562
`req.url()` to check for an HTTP request type and a URL path.
563563

564564
Let's load the http module:
@@ -579,7 +579,7 @@ To create a server and expose it to outside modules (i.e., `test.js`):
579579
// Creates server
580580

581581
Inside of the request handler callback, we should check if the request
582-
method is POST and the URL is `messages/``create.json`:
582+
method is POST and the URL is `messages/create.json`:
583583

584584
if (req.method == 'POST' && req.url == '/messages/create.json') {
585585
// If method is POST and URL is messages/ add message to the array
@@ -614,7 +614,7 @@ We output a message with a newly created object ID:
614614
// Out put message, should add object id
615615
})
616616

617-
If the method is GET and the URL is `/messages/``list.json` output a
617+
If the method is GET and the URL is `/messages/list.json` output a
618618
list of messages:
619619

620620
} else
@@ -664,7 +664,7 @@ and this function returns an array of messages as a string/text:
664664
return JSON.stringify(messages)
665665
}
666666

667-
`addMessage``()` converts a string into a JavaScript object with the
667+
`addMessage()` converts a string into a JavaScript object with the
668668
parse/deserializer method from querystring:
669669

670670
exports.addMessage = function (data){
@@ -770,46 +770,46 @@ Your application might grow bigger with more methods, URL paths to parse
770770
and conditions. That is where frameworks come in handy. They provide
771771
helpers to process requests and other nice things like static file
772772
support, sessions, etc. In this example, we intentionally didn't use any
773-
frameworks like Express (<http://expressjs.com/>) or Restify
774-
(<http://mcavage.github.com/node-restify/>). Other notable Node.js
773+
frameworks like Express (<http://expressjs.com>) or Restify
774+
(<http://mcavage.github.com/node-restify>). Other notable Node.js
775775
frameworks:
776776

777-
- [Derby](http://derbyjs.com/) (http://derbyjs.com/):MVC framework
777+
- [Derby](http://derbyjs.com) (<http://derbyjs.com>):MVC framework
778778
making it easy to write real-time, collaborative applications that
779779
run in both Node.js and browsers
780780

781781
- [Express.js](http://expressjs.com)
782-
(http://expressjs.com/en/index.html): the most robust, tested and
782+
(<http://expressjs.com/en/index.html>): the most robust, tested and
783783
used Node.js framework
784784

785-
- [Restify](http://mcavage.github.com/node-restify/)
786-
(http://restify.com/): lightweight framework for REST API servers
785+
- [Restify](http://mcavage.github.com/node-restify)
786+
(<http://restify.com>): lightweight framework for REST API servers
787787

788-
- [Sails.js](http://sailsjs.org/) (http://sailsjs.org/): MVC Node.js
788+
- [Sails.js](http://sailsjs.org) (<http://sailsjs.org>): MVC Node.js
789789
framework
790790

791-
- [hapi](http://spumko.github.io/) (http://spumko.github.io/): Node.js
791+
- [hapi](http://spumko.github.io) (<http://spumko.github.io>): Node.js
792792
framework built on top of Express.js
793793

794-
- [Connect](http://www.senchalabs.org/connect/)
795-
(https://github.com/senchalabs/connect\#readme): a middleware
794+
- [Connect](http://www.senchalabs.org/connect)
795+
(<https://github.com/senchalabs/connect#readme>): a middleware
796796
framework for node, shipping with over 18 bundled middlewares and a
797797
rich selection of third-party middleware
798798

799-
- [GeddyJS](http://geddyjs.org) (http://geddyjs.org/): a simple,
799+
- [GeddyJS](http://geddyjs.org) (<http://geddyjs.org>): a simple,
800800
structured MVC web framework for Node
801801

802-
- [CompoundJS](http://compoundjs.com/) (http://compoundjs.com/)
802+
- [CompoundJS](http://compoundjs.com) (<http://compoundjs.com>)
803803
(ex-RailswayJS): Node.JS MVC framework based on ExpressJS
804804

805-
- [Tower.js](http://towerjs.org) (http://tower.github.io/): a full
805+
- [Tower.js](http://towerjs.org) (<http://tower.github.io>): a full
806806
stack web framework for Node.js and the browser
807807

808-
- [Meteor](http://meteor.com) (https://www.meteor.com/): open-source
808+
- [Meteor](http://meteor.com) (<https://www.meteor.com>): open-source
809809
platform for building top-quality web apps in a fraction of the time
810810

811811
For a list of hand-picked frameworks, take a look at
812-
(http://nodeframeworks.com). Ways to improve the application:
812+
(<http://nodeframeworks.com>). Ways to improve the application:
813813

814814
- Improve existing test cases by adding object comparison instead of a
815815
string one
Collapse file

‎chapter7/chapter7.md‎

Copy file name to clipboardExpand all lines: chapter7/chapter7.md
+5-5Lines changed: 5 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ More detailed step-by-step instructions are available in the
6969
Database:MongoDB section of Chapter 2.
7070

7171
Some other useful MongoDB shell commands from MongoDB and Mongoose
72-
cheatsheet (https://gum.co/mongodb/git-874e6fb4):
72+
cheatsheet (<https://gum.co/mongodb/git-874e6fb4>):
7373

7474
- `> show dbs`: show databases on the server
7575

@@ -188,18 +188,18 @@ Alternatively, for your own development you could use other mappers,
188188
which are available as an extension of the Native Driver:
189189

190190
- [Mongoskin](https://github.com/guileen/node-mongoskin)
191-
(https://github.com/guileen/node-mongoskin): a future layer for
191+
(<https://github.com/guileen/node-mongoskin>): a future layer for
192192
node-mongodb-native
193193

194194
- [Mongoose](http://mongoosejs.com/) (http://mongoosejs.com/): an
195195
asynchronous JavaScript driver with optional support for modeling
196196

197197
- [Mongolia](https://github.com/masylum/mongolia)
198-
(https://github.com/masylum/mongolia): a lightweight MongoDB
198+
(<https://github.com/masylum/mongolia>): a lightweight MongoDB
199199
ORM/driver wrapper
200200

201201
- [Monk](https://github.com/LearnBoost/monk)
202-
(https://github.com/Automattic/monk): a tiny layer that provides
202+
(<https://github.com/Automattic/monk>): a tiny layer that provides
203203
simple yet substantial usability improvements for MongoDB usage
204204
within Node.js
205205

@@ -375,7 +375,7 @@ per app basis), use:
375375

376376
`$ heroku addons:create mongolab:sandbox`
377377

378-
Or log on to Heroku (https://elements.heroku.com/addons/mongolab) with
378+
Or log on to Heroku (<https://elements.heroku.com/addons/mongolab>) with
379379
your Heroku credentials and choose MongoLab Free for that particular
380380
Heroku app, if you know the name of that app.
381381

Collapse file

‎chapter8/chapter8.md‎

Copy file name to clipboardExpand all lines: chapter8/chapter8.md
+9-9Lines changed: 9 additions & 9 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -835,21 +835,21 @@ To install npm, run:
835835
More information on using yum can be found at the following locations:
836836

837837
- [Managing Software with
838-
yum](https://www.centos.org/docs/5/html/yum/)
839-
(https://www.centos.org/docs/5/html/yum/)
838+
yum](https://www.centos.org/docs/5/html/yum)
839+
(<https://www.centos.org/docs/5/html/yum>)
840840

841841
- [Installing Node.js via package
842842
managers](https://github.com/nodejs/node-v0.x-archive/wiki/Installing-Node.js-via-package-manager)
843-
(https://github.com/nodejs/node-v0.x-archive/wiki/Installing-Node.js-via-package-manager)
843+
(<https://github.com/nodejs/node-v0.x-archive/wiki/Installing-Node.js-via-package-manager>)
844844

845845
- [Tips on securing your EC2
846846
instance](http://aws.amazon.com/articles/1233)
847-
(http://aws.amazon.com/articles/1233)
847+
(<http://aws.amazon.com/articles/1233>)
848848

849849
Once you have Git and npm and Node, you are good to deploy your code
850850
(manually). Pull the code from the repository. You might need to provide
851851
credentials or upload your SSH keys to the AWS. Then start the Node
852-
server with [pm2](https://github.com/Unitech/pm2) (https://github.com/Unitech/pm2) or similar process manager (Figure 8-1). `pm2` is good because it has a lot of features not only to keep
852+
server with [pm2](https://github.com/Unitech/pm2) (<https://github.com/Unitech/pm2>) or similar process manager (Figure 8-1). `pm2` is good because it has a lot of features not only to keep
853853
the process running but also to scale it; it even has load balancing.
854854

855855
To install pm2:
@@ -904,12 +904,12 @@ instance’s description. For example,
904904
$ curl XXX.XXX.XXX.XXX –v
905905

906906
It’s worth mentioning that AWS supports many other operating systems via
907-
its AWS Marketplace (https://aws.amazon.com/marketplace). Although AWS
907+
its AWS Marketplace (<https://aws.amazon.com/marketplace>). Although AWS
908908
EC2 is a very popular and affordable choice, there other alternatives as
909-
well: [Joyent](http://www.joyent.com) (https://www.joyent.com/),
910-
[Windows Azure](https://azure.microsoft.com/en-us/)
909+
well: [Joyent](http://www.joyent.com) (<https://www.joyent.com>),
910+
[Windows Azure](https://azure.microsoft.com/en-us)
911911
(https://azure.microsoft.com/en-us/), [Rackspace Open
912-
Cloud](http://www.rackspace.com/cloud) (http://www.rackspace.com/cloud),
912+
Cloud](http://www.rackspace.com/cloud) (<http://www.rackspace.com/cloud>),
913913
and others.
914914

915915
Summary

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.