Express in Action 1st Edition Evan Hahn All Chapters Instant Download
Express in Action 1st Edition Evan Hahn All Chapters Instant Download
com
https://ebookname.com/product/express-in-action-1st-edition-
evan-hahn/
OR CLICK BUTTON
DOWNLOAD EBOOK
https://ebookname.com/product/new-developments-in-polymers-
research-1st-edition-evan-o-bradley/
ebookname.com
https://ebookname.com/product/psychiatry-6th-edition-rhoda-k-hahn/
ebookname.com
https://ebookname.com/product/hahn-and-economic-methodology-1st-
edition-thomas-boylan/
ebookname.com
https://ebookname.com/product/the-maverick-and-his-machine-thomas-
watson-sr-and-the-making-of-ibm-1st-edition-kevin-maney/
ebookname.com
Process Improvement with CMMI v1 2 and ISO Standards 1st
Edition Boris Mutafelija
https://ebookname.com/product/process-improvement-with-cmmi-v1-2-and-
iso-standards-1st-edition-boris-mutafelija/
ebookname.com
https://ebookname.com/product/nonequilibrium-statistical-
mechanics-1st-edition-robert-zwanzig/
ebookname.com
https://ebookname.com/product/encyclopedia-of-attention-deficit-
hyperactivity-disorders-first-edition-evelyn-b-kelly/
ebookname.com
https://ebookname.com/product/inside-paradise-lost-reading-the-
designs-of-milton-s-epic-first-edition-john-milton/
ebookname.com
https://ebookname.com/product/sixty-trends-in-sixty-minutes-1st-
edition-sam-hill/
ebookname.com
The Victorian World 2012 ROUTLEDGE WORLDS 1st Edition
Martin Hewitt
https://ebookname.com/product/the-victorian-world-2012-routledge-
worlds-1st-edition-martin-hewitt/
ebookname.com
MANNING
IN ACTION
Writing, building, and testing
Node.js applications
Evan M. Hahn
Express in Action
Express in Action
Writing, building,
and testing Node.js
applications
EVAN M. HAHN
MANNING
SHELTER ISLAND
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964
Email: orders@manning.com
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books
are printed on paper that is at least 15 percent recycled and processed without the use of
elemental chlorine.
ISBN: 9781617292422
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – EBM – 21 20 19 18 17 16
brief contents
PART 1 INTRO ..........................................................................1
1 ■ What is Express? 3
2 ■ The basics of Node.js 18
3 ■ Foundations of Express 31
v
contents
preface xiii
acknowledgments xiv
about this book xvi
about the cover illustration xix
1 What is Express? 3
1.1 What is this Node.js business? 4
1.2 What is Express? 6
The functionality in Node.js 6 ■
What Express adds to Node.js 8
1.3 Express’s minimal philosophy 9
1.4 The core parts of Express 9
Middleware 10 Routing
■
11 ■
Subapplications 11
Conveniences 12
1.5 The ecosystem surrounding Express 12
Express vs. other web application frameworks 12 What Express is
■
vii
viii CONTENTS
3 Foundations of Express 31
3.1 Middleware 32
Hello World with Express 33 How middleware works at
■
3.6 Summary 49
4 Middleware 53
4.1 Middleware and the middleware stack 54
4.2 Example app: a static file server 55
Getting set up 56 Writing your first middleware function:
■
5 Routing 70
5.1 What is routing? 70
A simple routing example 71
5.2 The features of routing 71
Grabbing parameters to routes 72 Using regular expressions to
■
6 Building APIs 87
6.1 A basic JSON API example 88
6.2 A simple Express-powered JSON API 90
6.3 Create, read, update, delete APIs 92
HTTP verbs (also known as HTTP methods) 93
CRUD applications with HTTP methods 95
6.4 API versioning 96
6.5 Setting HTTP status codes 99
Setting HTTP status codes 100 The 100 range 101
■
The 200 range 101 The 300 range 102 The 400
■ ■
run your tests 152 Writing your first test with Mocha
■
10 Security 172
10.1 The security mindset 173
10.2 Keeping your code as bug-free as possible 173
Enforcing good JavaScript with JSHint 174 Halting after errors ■
xiii
acknowledgments
There were so many people who helped out with this book.
I’ll start with folks at Manning Publications:
Thanks to Nicole Butterfield for approaching me about writing this book—she’s
the first person I spoke to at Manning. Mike Stephens and Marjan Bace have been
keeping an eye on the book throughout the process and have helped steer it in a good
direction. Matt Merkes did the technical proofing and made sure that all the content
in here is as accurate as possible. Thanks to Linda Recktenwald for copyediting the
whole manuscript and to Mary Piergies and Kevin Sullivan for bringing this book into
final production. I’d also like to thank Sean Dennis for being my editor on the first few
chapters; he offered a ton of valuable feedback that formed the early stages of this book.
A slew of reviewers (some anonymous and some not) offered a lot of comments
that really shaped the book. Many of them have interacted with me on Manning’s
Author Online forum. In alphabetical order, the forum participants include bio-
springxyz, BobCochran, grovejc, jtlapp, kwils, Magnitus, Misa, pala, RichD, and stlcub-
sfan, and a few anonymous users. The following reviewers all read the manuscript in
its early stages and gave invaluable feedback: Blake Hall, Carlos Rubén Alfaro Díaz,
Chang Liu, David Torrubia, Hector Lee, Jeff Smith, John Larsen, Jonathan Sewell,
Koray Guclu, Nick McGinness, Nicolas Modrzyk, Paul Shipley, Rich Sturim, Ruben
Verborgh, Tim Couger, Trent Whiteley, and William E. Wheeler.
The last person from Manning I must thank is my fantastic editor, Dan Maharry.
His feedback and guidance cannot be overstated. He gave huge, book-wide sugges-
tions that steered the direction of the book. He gave small, sentence-level suggestions
xiv
ACKNOWLEDGMENTS xv
that made individual statements clearer. The book is largely what it is today because of
Dan’s help.
I should also thank everyone who created Express. Thanks to TJ Holowaychuk for
creating Express, and for Doug Wilson who continues to maintain it with the support
of StrongLoop.
Thanks to Sencha, Pixc, and Braintree for giving me Express-based projects to
work on, which gave me a ton of experience.
Thanks to EchoJS and the JavaScript Weekly newsletter for promoting my original
Express.js tutorial. Without that post being sent around the web, I’d never be writing
this book!
Finally, I should thank everyone in my personal life that supported me as I wrote
this book. For fear of getting overly sentimental in a technical book (before it’s even
started), I’ll just name them: Mom, Dad, Jeremy, Baba, Olivia, and Peaches. I only
gloss over your importance because it’s more difficult to quantify and because I’m not
an eloquent enough writer.
This book would be an absolute wreck without all these people. Thank you!
about this book
Welcome to Express in Action! This book aims to teach you everything about Express.js,
the web framework that makes the powerful Node.js easy to use.
This book assumes you have intermediate JavaScript knowledge. This includes
things like anonymous functions, closures, and callbacks.
Roadmap
This book is divided into three parts.
Part 1 is an introduction to Express and the shoulders it stands on. You might won-
der: what is Express? What is its relationship to Node.js (and what is Node.js)? What
can Express do? What can’t it do? All of these questions (and more) will be answered
in the first three chapters. Part 1 aims to give you a strong conceptual understanding
of the framework.
Armed with that strong knowledge, you’ll delve into part 2, which covers Express’s
features in detail. In Part 1, we mention that Express has a feature called “routing.” In
part 2, chapter 5 is dedicated to how routing, which allows you to map different
requests to different request handler, really works. You’ll learn the ins and outs of
routing and how to use Express with HTTPS. You’ll also explore Express 4’s new rout-
ers features, and build a couple of routing-centric applications. Another major feature
of Express is its middleware stack (the focus of chapter 4) which is effectively an
array of functions. In chapter 6, you use routing and middleware to build a web server
that deals purely in JSON. The other big feature of Express is Views (explored in chap-
ter 7). Views allow you to dynamically render HTML.
xvi
ABOUT THIS BOOK xvii
With a solid understanding of core Express from part 2, we’ll turn to part 3,
which integrates Express with companion tools. As we’ll see, Express can’t do every-
thing on its own—it needs to integrate with other tools in order to be truly useful
(chapter 8). We can’t possibly go through all of the possible permutations of
Express apps and their companions, but we’ll go through a number of common use
cases that you can use to build web applications with the framework. Chapter 9
shows how to make your Express applications as robust as possible by testing; chap-
ter 10 focuses on securing Express applications; chapter 11 shows how to deploy
applications into the real world, and chapter 12 shows you how a mature Express
application is put together.
And after that, you’ll close the book. You'll be able to make your colleagues look
like fools, at least when it comes to Express.js.
Code conventions
This book provides copious examples that show how you can make use of each of the
topics covered. Source code in listings or in text appears in a fixed-width font like
this to separate it from ordinary text. In addition, class and method names, object
properties, and other code-related terms and content in text are presented using
fixed-width font.
Author Online
Purchase of Express in Action includes free access to a private web forum run by Man-
ning Publications where you can make comments about the book, ask technical ques-
tions, and receive help from the author and from other users. To access the forum
and subscribe to it, point your web browser to www.manning.com/express-in-action.
This page provides information on how to get on the forum once you are registered,
what kind of help is available, and the rules of conduct on the forum. It also provides
links to the source code for the examples in the book, errata, and other downloads.
Manning’s commitment to our readers is to provide a venue where a meaningful
dialog between individual readers and between readers and the author can take place.
It is not a commitment to any specific amount of participation on the part of the
xviii ABOUT THIS BOOK
xix
xx ABOUT THE COVER ILLUSTRATION
At a time when it is hard to tell one computer book from another, Manning cele-
brates the inventiveness and initiative of the computer business with book covers
based on the rich diversity of regional life of two centuries ago, brought back to life by
Jeffreys’ pictures.
Part 1
Intro
W elcome to Express in Action. This is the first of three parts and, like many
openers, it introduces the players.
In chapter 1, I’ll identify the characters. Spoiler alert: they are Node.js and
Express. The former is a JavaScript runtime—a place where JavaScript code can
run—that’s attractive to a lot of developers. Node.js is powerful, but its APIs can,
at times, lack power and leave you writing a lot of boilerplate code; that’s where
Express struts onto the scene. It fits snugly into Node.js and makes it easier to
write web applications. You’ll learn all this and much more in chapter 1.
In chapter 2 you’ll learn what it means for Node.js to be a JavaScript runtime,
and you’ll be running JavaScript in Node.js. You’ll build a couple of simple mod-
ules and then see what it takes to build a website on the platform. You’ll also
learn how to include third-party modules from npm, Node.js’s third-party pack-
age registry.
The star of the show, Express, takes center stage in chapter 3. You’ll see how
Express sits on top of Node.js, and learn its major features. Express will show you
convenience after convenience. We’ll delve deeper into each of these features in
subsequent chapters, but by the end of chapter 3, you’ll have all of the core
Express knowledge you’ll need.
I hope you are as excited as I to get started!
What is Express?
3
4 CHAPTER 1 What is Express?
developers had no choice but to pick JavaScript. In addition to Ruby, Python, C#, Java,
and other languages, developers could now choose JavaScript when developing server-
side applications.
JavaScript might not be the perfect language for everyone, but Node.js has real
benefits. For one, the V8 JavaScript engine is fast, and Node.js encourages an asyn-
chronous coding style, making for faster code while avoiding multithreaded night-
mares. JavaScript also had a bevy of useful libraries because of its popularity. But the
biggest benefit of Node.js is the ability to share code between browser and server.
Developers don’t have to do any kind of context switch when going from client and
server. Now they can use the same code and the same coding paradigms between two
JavaScript runtimes: the browser and the server.
Node.js caught on—people thought it was pretty cool. Like browser-based JavaScript,
Node.js provides a bevy of low-level features you’d need to build an application. But
like browser-based JavaScript, its low-level offerings can be verbose and difficult to use.
Enter Express, a framework that acts as a light layer atop the Node.js web server,
making it more pleasant to develop Node.js web applications.
Express is philosophically similar to jQuery. People want to add dynamic content
to their web pages, but the vanilla browser APIs can be verbose, confusing, and limited
in features. Developers often have to write boilerplate code, and a lot of it. jQuery
exists to cut down on this boilerplate code by simplifying the APIs of the browser and
adding helpful new features. That’s basically it.
Express is exactly the same. People want to make web applications with Node.js,
but the vanilla Node.js APIs can be verbose, confusing, and limited in features. Devel-
opers often have to write a lot of boilerplate code. Express exists to cut down on this
boilerplate code by simplifying the APIs of Node.js and adding helpful new features.
That’s basically it!
Like jQuery, Express aims to be extensible. It’s hands-off about most parts of your
applications’ decisions and is easily extended with third-party libraries. Throughout this
book and your Express career, you’ll have to make decisions about your applications’
architectures, and you’ll extend Express with a bevy of powerful third-party modules.
You probably didn’t pick up this book for the “in short” definition, though. The
rest of this chapter (and book, really) will discuss Express in much more depth.
NOTE This book assumes that you’re proficient in JavaScript but not Node.js.
"I don't think your mamma would mind," said she; "but I'll tell you
what we'll do. We'll just put them into Miss Lina's little basket, and lay
it here on the table till the mistress comes home."
"Take me in your arms, Hetty, and carry me up and down, just for a
minute."
Hetty did so, and then the child consented to be read to. Generally,
she was very particular about Hetty's pronunciation, and corrected
her frequently, like the old-fashioned scrap she was. This evening,
however, she listened in silence; she was looking hard at the
cherries.
"There's the clock, Miss Flo. I must run and see after the cooking;
but I shall not be long."
She ran downstairs, and made what haste she could to return. But
while she was absent poor little Flo had contrived to reach the little
basket, and had eaten up every one of the cherries. She had been
gazing at them, and longing for them, and telling herself that mamma
would not let her have them, and that Hetty would give them to
Edgar and Lina; and I think it was the vision of the delicious cherries
disappearing down their throats, that finally conquered the poor
child. She meant to tell Hetty, but when she heard her coming, she
was ashamed; and putting the stalks and stones into the basket, she
dropped it between the back of her sofa and the wall. And poor
"Heedless Hetty," coming in just then, never missed the basket, nor
thought about the cherries again, until, when going to bed that night,
she took from her pocket four big brown pennies, and remembered
why she had "broken into her sixpence," as she said to herself.
But if Flo had been fretful before, it was nothing to her crossness
now. Nothing pleased her; the book was stupid, the room was too
hot, Hetty was unkind; she cried every minute, and finally burst into a
howl, declaring that "she was too miserable to be good." Her cries
awoke the baby, who promptly added his voice to the uproar, and
Hetty was fairly at her wits' end, when a knock at the door
announced the return of the expedition to B— and silenced Flo.
"Oh, ma'am, I am glad you are come, for I'm half afraid that Miss Flo
is ill. I never saw her like this before."
"No, ma'am; but she's very restless. She was crying out loud just
now, but when you knocked she stopped."
"'Twas both, ma'am; but when she left off, so did he."
"I'm afraid you've been frightened, Hetty. I hope there's nothing much
the matter. Flo has been rather cross all day. Run up, children, and
Hetty will take your things off."
She herself walked into the parlour, to see after Flo. The child was
very white, wearied out with crying. As soon as she saw her mother,
she said, "Don't kiss me, mamma, I've been bad."
"You would not kiss me if you knew how bad I've been."
"We will not talk of that yet. See, I have brought you something that
you like;" and she opened a paper bag and displayed half a dozen
Naples biscuits.
Mrs. Eyre was puzzled, but the child seemed so ill and feverish that
she judged it better to ask no questions. She began getting the room
ready for tea, and then took baby out of his cradle, wide awake now,
and as jolly as usual. Mr. Eyre came home, the other children came
downstairs, and they all sat down to tea. Hetty had set the tray on
the table, and was leaving the room, when Flo called to her.
"Hetty! Take me to bed. I want nothing to eat. I'm tired; please, may I
go to bed?"
"Oh, my child, just eat a little bit. Hetty, has she eaten anything since
we went out?"
"No, ma'am."
Hetty put her to bed; she was very silent, until she was tucked snugly
into her little white nest, when she said, "Good-night, Hetty. I am a
very unhappy person. After what has happened, no one will love
me."
Hetty laughed, and kissed her. "That's a funny notion, Miss Flo. Why,
here's Zelica. After being asleep the whole evening, she is wide
awake now; I had better take her back to the parlour."
"No, no; give her to me. Oh, Zelica, I'm so glad that you won't
understand. Go away, now, Hetty, I want to think, and see if I can do
it."
"Do what, dear?—go to sleep, I hope. I will run up presently and see
how you get on."
Lina and little Edgar slept in the nursery, Flo in her mother's room.
When the children were in bed, Hetty stole in softly to look at Flo.
The child had fallen asleep, with tears on her cheeks and her pretty
eyelashes all wet. She moved restlessly, and made a little moan
occasionally. Hetty ran down to tell her mistress.
"Did she tell you she would not, ma'am?" said Hetty quickly.
"I told her to-day that we could not manage to keep you, and that we
must manage as we did before you came; and she said it was only
fair to tell me that she could not help about the children; that she
would do her own work, and no more."
"I declare," said Mr. Eyre indignantly, "I should have given her
warning on the spot."
"She said much the same to me this morning, ma'am. And then I
thought—maybe if you let her go, and kept me. I went and asked
mother, and she's coming to-morrow to find out if Mrs. Goodenough
is in earnest. I know I'm not as good a servant, but I would do my
best—I would do anything, ma'am, to be with you and Miss Flo. I
know what has to be done, too—a stranger would give you more
trouble, and I should be here to carry Miss Flo, and all. Mother was
quite satisfied. Oh, do let me stay, ma'am!"
"Not it, ma'am. Not half as tiring as a day over mother's tubs! I'm
very strong—if you can overlook my heedless ways; and, oh! but I
would do my best."
"But, Mrs. Goodenough," began Mrs. Eyre, "she is old, and would
not easily get a place to suit her, and she has been with me a long
time, and—"
"Well, that's her own look-out. I'll see Mrs. Goodenough to-morrow
morning and tell her that she may go. In my opinion you'll be twice
as well off with Hetty. And I trust that this pinch is only for a time;
we'll get another Goodenough by-and-by."
"Well, Hetty, your master, you see, has made up his mind; and if I
find that your mother is content, you do not know how glad I shall be.
I really think it was making my poor little Flo ill, she was so sorry."
Hetty coloured and smiled, and looked so happy that one might have
thought she had just got great promotion.
Mr. Eyre said when she was gone, "That's a good girl, Celia. I never
liked Goodenough, selfish old cat! I hope she may end in the
poorhouse!"
Down came Hetty again, full speed. "Oh, ma'am, Miss Flo does look
so bad!"
They all ran upstairs. Flo was twisting and moaning as if in pain, her
cheeks flushed and her lips white. She woke up in a moment and
looked frightened.
"Flo, dear, are you feeling ill? You were crying out in your sleep."
Flo turned her face away. "I don't want anything," she said.
They thought she was asleep again; and as it was now late, Mrs.
Eyre sent Hetty to bed, and said that she would sit up for a little
while, just to see how the child slept.
Hetty went to the nursery and began to undress. Then came the
discovery about the sixpence—a sixpence no longer.
"The cherries!" said she to herself, "what has become of them? Sure,
they couldn't make the child ill, even if she ate them—and we put
them in the basket. But I'll just run down and look. I never thought a
few cherries could make a child ill; but if they have, the mistress
ought to know."
She went down to the parlour. But she could not find the basket—
that she did not find the cherries need scarcely be said.
While she was searching about, Mrs. Eyre came down. "I thought I
heard you moving about—what made you come down again?"
"Well, ma'am, I'm looking for some cherries that I bought for Miss
Flo, and she would not eat them until you were here to give her
leave. I put them into Miss Lina's basket, but I can't find them."
"Cherries! why, Hetty, you know I refused to get any for her, just as
you were going out! They always make her ill, and those the woman
had were neither ripe nor freshly gathered."
"Oh no, ma'am. You only said you could not give her any. I meant no
harm, but she told me she did not think she ought to eat them, so we
put them in the basket, but I do wonder where they are."
As she spoke, she stooped to look on the floor for the missing
treasure, and at once cried out, "There they are!" Pushing the sofa
out from the wall, she seized the basket. Alas! it was empty. Hetty
grew quite red.
"They may have fallen out," said Mrs. Eyre. "Look on the carpet."
Hetty went down on her knees, and searched about; but she was so
long, that at last Mrs. Eyre said, "What are you about, Hetty? Are the
cherries there, or not?"
Hetty got up. She held out on the palm of her hand thirteen cherry
stones and a little heap of stalks.
"Hetty, oh, Hetty, perhaps you ate them! When she would not, you
know. You do forget things, you see."
"No, ma'am."
"Oh, John, that is what ails poor little Flo. Hetty went and gave her a
lot of cherries, though she heard me refuse to buy them for her. And
now she tells me she put them in this basket, because Flo refused to
eat them—but the cherries are gone."
"Well, Hetty, you have always told me the truth—I am sure you are
right. Oh, my poor little Flo! John, what had I better do?"
"Come up to her; we'll just wake her up for a moment, and give her
some of the medicine Dr. Haddon left for her. Say nothing, for she
will tell you in the morning, and that will be much better. As to you,
Hetty, mind this—you are never to give the child anything to eat,
except what your mistress provides. It was a very wrong and very
careless thing to do, and if the poor child is ill for a week, it is your
doing. Go off now to bed. Come, Celia."
THE next morning Flo seemed poorly, but not really ill. Mrs. Eyre
kept her in bed, and the child lay there quietly, and looked very sad.
"I did think my little girl could be trusted," said Mrs. Eyre.
"So did I, mamma," was the unexpected reply, which very nearly
surprised Mrs. Eyre into a laugh. "But I did it. Will you never trust me
again, mamma?"
"Soon, I hope; but you will have to earn it, Flo. Do not cry, my dear, I
know you are sorry, and I am glad you told me yourself. You are not
strong, like Lina, so I shall not punish you, and I hope you will try to
be sorry quietly, for if you cry and fret you will make yourself ill. And
try, dear, to see where you began to do wrong. Eating the cherries
was not the beginning, was it now?"
"No; I was cross all day, and I murmured, mamma, nearly all day,
and never tried to stop; and then I kept wishing, wishing for the
cherries."
"And if you had tried to leave off being cross and fretful it would not
have been so hard, because, you know, you often have done that.
God would have helped you."
Mrs. Eyre knelt by the little crib, and prayed in simple, reverent
words, Flo listening with tears in her eyes.
I need hardly say that the kiss was given. Happy little Flo! To be so
taught, and so forgiven.
Mrs. Eyre then went down to the kitchen, and being rather a
cowardly little woman, I must confess that she dreaded the
impending interview with Mrs. Goodenough, who had been informed
by Mr. Eyre that after this week her services would be no longer
required, as he would not allow a servant to be kept who refused to
give Mrs. Eyre such help as she needed with the children.
Mrs. Goodenough's feelings had been so much hurt that she had
then and there demanded her week's wages, and another week,
instead of a week's warning, and Mr. Eyre, knowing how his wife
would rejoice to find her gone, paid her, and let her depart.
"I suppose," said she, standing in the hall, "the mistress means to
keep Hetty Hardy, which I wish her joy of it. But as to slaving on to
the end of the week, when you've dismissed me as if I hadn't been a
month in the house, that I will not do; my things are all in their
places, and the mistress knows that I'm honest—no need for
counting the half-dozen pots and pans, I suppose, so I'll just go at
once."
"You certainly shall," replied Mr. Eyre, opening the hall door, "and
without another word if you please."
"Oh, mother I'm sorry now that you had the trouble of coming, for
Mrs. Goodenough went away of herself. She told the mistress that
she would give no help with the children, and the master put her out;
and I think I'm to stay."
"You think! and what's wrong with you now, Hetty? I thought you'd be
delighted to have it settled—is it settled?"
"I hope so. Come down to the kitchen, mother, and I'll tell you all
about it."
"I declare!" said Mrs. Hardy, when she had heard the story, "I don't
know whether to laugh or cry. The notion! why, child, don't you see
that it was a very impertinent thing for you to do? To go buying a
penn'orth of cherries for the child because you fancied her mother
couldn't. I wonder when you're going to have a morsel of sense—I
do indeed! Well, I must find out if Mrs. Eyre is going to overlook it, for
I declare I don't expect it. Where is she?"
"The master bid me tell you, ma'am, she's gone. She wouldn't stay
even to wash up the things. He hadn't time to wait for you to come
down."
"Hetty did not mean it for impertinence. She is very thoughtless, but
she is very truthful. I am sure she will never do such a thing again. I
will see how we get on, if you are quite satisfied to have it so."
"Ma'am, that's just because you are too soft with her. If you gave her
a raking good scolding when she makes a fool of herself; she'd be all
the better of it."
Mrs. Hardy was so far right, that it was quite as well for Hetty that
she began her new undertaking in a slightly subdued spirit. Between
that, and the fact that she hardly ever had a spare minute, she got
on very well. Of course she made mistakes, and sometimes forgot to
do this or that; but on the whole she did well, and was a great
comfort to her busy little mistress. And Flo, who was taken out every
fine day, began to improve slowly, but perceptibly.
Mrs. Eyre, who did not expect too much from a girl of fifteen, was
satisfied with Hetty, and even Mrs. Hardy began to think that all her
"raking fine scoldings" were taking effect, and "making a woman of
the girl" at last.
The only person who felt disappointed was Mrs. Goodenough, who
had confidently expected to be recalled on account of Hetty's
blunders, and who had not found it easy to get a comfortable place.
However, no one can be very sorry for her, as she deserved to be
disappointed. Her mistress had always been most kind and
considerate, and I pronounce Mrs. Goodenough a selfish old
woman.
In about six months the Eyres had paid off the few debts incurred
during Mr. Eyre's illness, and, moreover, he got a very welcome and
unexpected rise in his salary. One of the partners in the great firm
died, and his son was a man of larger views and more generous
feelings than any of the other persons concerned. He was quite
shocked to find how hard and grasping the firm had always been to
their clerks and salesmen, and with much trouble he succeeded in
bringing about a better state of things.
The very first thing that Mr. Eyre insisted on was, that some one
should be hired in Mrs. Goodenough's place, for he thought that both
his wife and Hetty had rather too much to do. And who do you think
came begging to be engaged but the excellent Goodenough herself?
And in a very subdued and anxious state of mind, I assure you.
Mr. Eyre laughed when he heard that she was to come back, and
said that his wife was a silly little woman. Mrs. Goodenough was
very civil to Hetty, but she had by no means forgiven her for having
offered to remain in her place, and the girl had no friend in the old
woman from that time.
Only a little while ago, to keep Zelica in the basket would have been
one person's work; but her kitten days were over, and though she
could enjoy a game of play still, she no longer wanted to be playing
all day long. She lay contentedly in her basket, peeping out through
the wickerwork with a supercilious air, as is the manner of cats. Flo
lay on the cushions with her head on Hetty's lap, and Zelica's basket
held in her arms. Lina and Edgar danced about in great glee—Flo
had to tell them more than once that they were "childish."
At last they reached R—, and Hetty carried Flo to the pleasant
lodgings that Mr. Eyre had engaged. The child was too tired to care
even to see the sea; as Lina was wild to do. But next day she was
rested, and her delight was very great. When the tide was low, there
was a beautiful beach, where she could lie on a soft shawl, and
actually pick up pebbles and shells for herself. Then, when the tide
was high, there was a zigzag path up the low cliff, and near the top
there was a hut, with a broad seat all made of sods, green and fresh;
and here Hetty and Flo spent many happy hours, while the others
rambled about. Zelica condescended to go with them to the hut;
down on the beach she would not go, as her delicate paws got wet
with salt water. Poor Hetty! That wooden hut haunted her dreams for
many a night, for it was here that she got a lesson which went far
towards curing her of her thoughtlessness.
The days passed very happily. Mrs. Eyre and the three children
bathed and rambled about. Even Baby Johnnie could walk now; they
got sunburned and freckled, and loaves of bread disappeared before
them as if by magic. Mr. Eyre, too, began to look brown and strong,
and even Flo's little cheeks got a pale pink touch. As to the other
members of the family, Hetty and Zelica, they could hardly look
better than they always did.
Their pleasant stay was drawing to an end, when one day Mr. Eyre
announced that he was off for a long solitary walk, as he wished to
go farther and by rougher paths than any one else was equal to.
Before he went, he carried Flo up to the hut on the cliff, Hetty
following, laden with her workbasket, Flo's pillow and shawls and a
second basket, which contained the cat. Also Hetty brought a
charming story, which Flo had heard many times, but now wished to
hear again.
"There you are, little woman," said Mr. Eyre, laying the child down on
the scat, where Hetty proceeded to make her comfortable. "I declare,
Hetty, I think she is a little bit heavier, and she surely looks better."
"That she does, sir. We'll have her dancing country dances before
long."
"That's what you always say, Hetty. But I'm not sure that I want to
dance country dances. I would rather go out walking on the common
with the rest."
"That will be a pleasant day, little Flo. Now, good-bye. I shall be back
in time to help you down the path, Hetty, so you may wait for me if
the day does not change; and I don't think it will do that."
"I wonder is it always fine here?" said Flo, as she watched her father
going up the steep path.
"Oh, no, Miss Flo! They have their share of rain and storm, no doubt.
Don't you remember the old fisherman, who told you how his boat
was lost, and his grandson was—"
"Don't, Hetty! Oh, I dreamed of it! Do let me forget it. I hope it will be
fine all the time we're here. The sea is so nice. Does not that long
bright streak look as if we could walk on it? I want to think of it like
this always."
"So we will, Miss Flo. I don't suppose there are any storms in the
summer."
With such conversation, Hetty working all the time, they passed the
morning. Then Flo had some biscuits and milk, and Zelica, having
had her share of milk, got back into her snug basket, and went fast
asleep. Hetty began to read "Whiter than Snow," which I think she
must have known of by heart. And Flo listened until the murmur of
the sea mingled with the well-known words, and Hetty's voice
sounded far-off and indistinct. After that, Flo was asleep.
Hetty covered her more completely, and then stitched away at the
brown holland pinafore she was making. Presently a shrimp-girl,
whose acquaintance she had made on the beach, came up the path
with a sackful of these little creatures on her back. Hetty threw down
her work and went out to talk to her. The girl was glad to rest, and to
have a chat, and Flo slept peacefully, so that it did not matter.
"Well, I must be going," said the girl at last. "I have eight miles to
walk to sell my shrimps to-day. Such a take as we had! And Joe
Mallard gave up fishing early, and went and sold all his in the village;
so no one would look at mine. Here, miss, I'll give you some if you
have anything to put them in."
Hetty produced the paper bag in which Flo's biscuits had been
packed, and the shrimp-girl filled it generously.
"That's for yourself, mind. You must boil them till they're red. Good-
bye now; I must lose no more time."
"Good-bye, and thank you kindly," said Hetty, going back to her work.
But she did not work long. The pleasant shade of the hut—the wide
outlook over the deep blue sea, dotted all over with fishing boats,
tempted her to gaze. Laying down her work on her knees, she
gazed, and dreamed, and idled. How much time she passed in this
occupation she had no idea—if one can call it an occupation.
At last Flo stirred in her sleep, and Hetty roused herself. She
changed the position of the pillow a little, and the child was soon in a
deep sleep again.
But now Hetty perceived that Zelica was gone. The basket was
open, and empty. Hetty tried to remember when she saw her last.
She had been there when the shrimp-girl came—and Hetty thought
she had seen her when she returned to the hut.
"She'll have gone back to the lodgings—but I will take a look round;
the child won't wake this hour."
She went out and looked up and down the path. Coming back, she
perceived that Zelica, who was not a perfectly honest cat,—poor Flo
always thought it was because she had seen her mistress take the
cherries!—had been at the bag of shrimps. She had poked a hole in
the thin, wet paper, and Hetty concluded that she had stolen a
shrimp, and run off to try if she liked it.
"She can't be far-off," muttered Hetty, taking a look at Flo, who was
lying quite quiet. "I'll just run up the path a bit. She'll have gone that
way, the little thief! She won't go home with her stolen shrimp."
CHAPTER IX.
THE BIG BLACK DOG.
IT was about two o'clock when Hetty left the hut on the slope of the
cliff path, and it was a little past three when Mr. Eyre reached it on
his way home. He had had a most delightful walk, and his pockets
were full of spoils, brought home for little Flo: flowers, sea-weeds, a
deserted nest, feathers—every pretty thing that he had seen that
was likely to please his little sick girl. There was no sound of talking
as he drew near, so he entered quietly, thinking that the child was
asleep.
But Flo was not there. The hut was deserted. The shawls used for
covering her when she slept were on the ground—and there too was
Zelica's basket, all bent and frayed. Also a wet paper and a lot of
half-dead shrimps, some of them mashed up in a very unsightly
manner, and Hetty's work; all these things lay here and there, but
Flo, Hetty, and Zelica had vanished.
"The child must have been ill. Stay! there's the mark of a big dog's
paw on the shawl! They have been frightened, and Hetty has taken
her home to her mother."
But you may be sure that Mr. Eyre did not delay to decide the
question. Carrying the child steadily, he hurried on, the dog running
by his side, looking up with almost human anxiety in his face. He
followed to the door of the lodgings, saw Flo carried in, and then ran
off.
"Celia! Celia! come here. Oh, my dear, I can't take time to warn you
—something has happened to Flo—she has fallen."
"No, no,—not dead. Let me lay her on her bed. See! She is only
scratched—she moved then. Oh, Celia! The child is alive!"
Mrs. Eyre brought water, and opened the child's frock, which was all
twisted round and round her. Flo opened her eyes,—but, alas! she
did not seem to know them. She screamed, as if in terror, crying out,
—
"Oh, Hetty, Hetty! The dog—the big black dog! Oh, Hetty! Come
back, come back! Oh, Zelica, poor Zelica!"
Mr. Eyre ran to the Home, and was very fortunate, for the nurse
could easily be spared, as there were not many patients, and they
were all nearly well. So she came at once, and so did the doctor.
It seemed a long time before the doctor came downstairs to the room
where poor John Eyre waited for him, and where the three children
sat cowering in a corner, terrified by Flo's shrieks, and their father's
face of misery.
"Your wife, sir (I don't know your name yet), tells me that the doctor
who knows the child's case could be here in a few hours if you went
for him. There are no bones broken; but she is in a fearful state of
terror and excitement, and I should be very glad to have this Dr.
Haddon's help. You see, I don't know anything about the previous
injury. Mrs. Dooner, the nurse, can stay here, and I should advise
your taking these poor little things home, if possible. There will be
plenty to do, without having them here."
"I will take them home, and bring Haddon back. When is the next
train?"
"There is one in half an hour. If no one else sends for me, I will stay
here until you return. You may be able to get back by one which
stops here at nine, but to do that you must not lose a moment."
"You're very kind," John Eyre said, and began putting on the
children's hats, which lay on the window seat.
Just as they were ready, a flying step passed the window, and in
rushed Hetty, looking like a mad girl.
"You may hear her screams. She is here. I found her half-way down
the path. Where were you? Speak, girl!"
"Zelica ran away; I went after her. She—I saw her on the green place
at the top of the cliff. She ran off, and I after her. She got into a lane
that goes away from the sea, and when I saw that I couldn't catch
her, I turned back; but I had lost my way. Oh, I have run till I'm nearly
dead, and when I got to the hut—oh, sir!—"
"You left the child, and went away, far enough to lose yourself. I don't
know what happened to her, but I think she is dying. Go—go home!
Let me never see your face again."
"Oh, Mr. Eyre! I deserve it; but the mistress will have no one to help
her."
"I will see to that. Here is your money. Go at once! I cannot bear the
sight of you."
He took the three children, and left the house. He was but just in
time to catch the train.
Hetty sank upon the window seat and listened, her heart wrung
almost past endurance, to the sounds upstairs. Poor Flo! Had any
one thought of it, the sight of Hetty, for whom she called so pitifully,
would have quieted her better than anything. But Mrs. Eyre did not
know that Hetty was in the house, and no one else attended to the
meaning of the child's cry.
"Zelica! oh, Zelica! The big black dog has eaten Zelica! He'll kill me
too! Hetty! Hetty! come back!"
"If this can't be stopped, the child will be in convulsions," said the
nurse.