100% found this document useful (2 votes)
24 views

Modern Full-Stack Development: Using TypeScript, React, Node.js, Webpack, and Docker Zammetti pdf download

The document is a comprehensive guide on modern full-stack development using technologies such as TypeScript, React, Node.js, Webpack, and Docker, authored by Frank Zammetti. It covers various topics including server-side action with Node, client-side development with React, and advanced concepts in TypeScript and Webpack. Additionally, it provides links to other related resources and books for further learning in full-stack development.

Uploaded by

smidtrenze4n
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
24 views

Modern Full-Stack Development: Using TypeScript, React, Node.js, Webpack, and Docker Zammetti pdf download

The document is a comprehensive guide on modern full-stack development using technologies such as TypeScript, React, Node.js, Webpack, and Docker, authored by Frank Zammetti. It covers various topics including server-side action with Node, client-side development with React, and advanced concepts in TypeScript and Webpack. Additionally, it provides links to other related resources and books for further learning in full-stack development.

Uploaded by

smidtrenze4n
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Modern Full-Stack Development: Using TypeScript,

React, Node.js, Webpack, and Docker Zammetti


download

https://textbookfull.com/product/modern-full-stack-development-
using-typescript-react-node-js-webpack-and-docker-zammetti/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/

Full Stack React Projects Modern web development using


React 16 Node Express and MongoDB 2nd Edition Shama
Hoque

https://textbookfull.com/product/full-stack-react-projects-
modern-web-development-using-react-16-node-express-and-
mongodb-2nd-edition-shama-hoque/

The Complete Developer: Master the Full Stack With


TypeScript, React, Next.js, MongoDB, and Docker 1st
Edition Martin Krause

https://textbookfull.com/product/the-complete-developer-master-
the-full-stack-with-typescript-react-next-js-mongodb-and-
docker-1st-edition-martin-krause/

Practical React Native: Build Two Full Projects and One


Full Game using React Native 1st Edition Frank Zammetti

https://textbookfull.com/product/practical-react-native-build-
two-full-projects-and-one-full-game-using-react-native-1st-
edition-frank-zammetti/
React Architect Full Stack React App Development and
Serverless Deployment Frank Zickert

https://textbookfull.com/product/react-architect-full-stack-
react-app-development-and-serverless-deployment-frank-zickert/

Mastering Full Stack React Web Development 1st Edition


Tomasz Dyl

https://textbookfull.com/product/mastering-full-stack-react-web-
development-1st-edition-tomasz-dyl/

Pro MERN Stack: Full Stack Web App Development with


Mongo, Express, React, and Node Vasan Subramanian

https://textbookfull.com/product/pro-mern-stack-full-stack-web-
app-development-with-mongo-express-react-and-node-vasan-
subramanian/

Pro MERN Stack: Full Stack Web App Development with


Mongo, Express, React, and Node 2nd Edition Vasan
Subramanian

https://textbookfull.com/product/pro-mern-stack-full-stack-web-
app-development-with-mongo-express-react-and-node-2nd-edition-
vasan-subramanian/

Pro MERN Stack: Full Stack Web App Development with


Mongo, Express, React, and Node 1st Edition Vasan
Subramanian (Auth.)

https://textbookfull.com/product/pro-mern-stack-full-stack-web-
app-development-with-mongo-express-react-and-node-1st-edition-
vasan-subramanian-auth/
Modern Full-Stack
Development
Using TypeScript, React, Node.js,
Webpack, and Docker

Frank Zammetti
Modern Full-Stack Development
Frank Zammetti
Pottstown, PA, USA

ISBN-13 (pbk): 978-1-4842-5737-1 ISBN-13 (electronic): 978-1-4842-5738-8


https://doi.org/10.1007/978-1-4842-5738-8

Copyright © 2020 by Frank Zammetti


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Louise Corrigan
Development Editor: James Markham
Coordinating Editor: Nancy Chen
Cover designed by eStudioCalamar
Cover image designed by Ekrulila from Pexels
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza,
New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or
visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is
Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware
corporation.
For information on translations, please e-mail rights@apress.com, or visit http://www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484257371. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
Dedicated to Traci, Andrew, and
Ashley – the only people I want to share
a shed in the woods with when the zombies come!
(Okay, maybe not the “only” ones…
but they get the good canned beans.)
Table of Contents
About the Author�����������������������������������������������������������������������������������������������������xv

About the Technical Reviewer�������������������������������������������������������������������������������xvii

Acknowledgments��������������������������������������������������������������������������������������������������xix

Introduction������������������������������������������������������������������������������������������������������������xxi

Chapter 1: Server-Side Action: Node and NPM��������������������������������������������������������� 1


Of JavaScript Runtimes and Building (Mostly) Servers���������������������������������������������������� 2
First Baby Steps with Node: Installation���������������������������������������������������������������������� 5
More Useful: Executing JavaScript Source Files��������������������������������������������������������� 7
Node’s Partner in Crime: NPM������������������������������������������������������������������������������������������ 8
A Few More NPM Commands������������������������������������������������������������������������������������ 10
Initializing a New NPM/Node Project������������������������������������������������������������������������� 11
Adding Dependencies����������������������������������������������������������������������������������������������� 13
A Quick Aside: Semantic Versioning�������������������������������������������������������������������������� 14
Fisher Price’s “My First Node Web Server”�������������������������������������������������������������������� 15
Bonus Example���������������������������������������������������������������������������������������������������������� 18
Summary������������������������������������������������������������������������������������������������������������������������ 20

Chapter 2: A Few More Words: Advanced Node and NPM�������������������������������������� 21


NPM: More on package.json������������������������������������������������������������������������������������������� 21
NPM: Other Commands�������������������������������������������������������������������������������������������������� 25
Auditing Package Security���������������������������������������������������������������������������������������� 26
Deduplication and Pruning���������������������������������������������������������������������������������������� 26
Finding/Searching for Packages sans Browser�������������������������������������������������������� 27

v
Table of Contents

Updating Packages��������������������������������������������������������������������������������������������������� 28
Publishing/Unpublishing Packages��������������������������������������������������������������������������� 28
Node: Standard Modules������������������������������������������������������������������������������������������������ 29
File System (fs)��������������������������������������������������������������������������������������������������������� 30
HTTP and HTTPS (http and https)������������������������������������������������������������������������������ 32
OS (os)����������������������������������������������������������������������������������������������������������������������� 34
Path (path)����������������������������������������������������������������������������������������������������������������� 35
Process���������������������������������������������������������������������������������������������������������������������� 36
Query Strings (querystring)��������������������������������������������������������������������������������������� 37
URL (url)�������������������������������������������������������������������������������������������������������������������� 38
Utilities (util)�������������������������������������������������������������������������������������������������������������� 39
The Rest of the Cast�������������������������������������������������������������������������������������������������� 40
Summary������������������������������������������������������������������������������������������������������������������������ 42

Chapter 3: Client-Side Adventures: React�������������������������������������������������������������� 43


A Brief History of React�������������������������������������������������������������������������������������������������� 43
Yeah, Okay, History Nerd, That’s All Great, but What IS React?!������������������������������������� 46
The Real Star of the Show: Components������������������������������������������������������������������� 48
Components Need Info: Props����������������������������������������������������������������������������������� 55
Components (Sometimes) Need Memory: State�������������������������������������������������������� 57
Making Them Look Good: Style��������������������������������������������������������������������������������� 60
In the End, Why React?��������������������������������������������������������������������������������������������������� 62
Summary������������������������������������������������������������������������������������������������������������������������ 63

Chapter 4: A Few More Words: Advanced React���������������������������������������������������� 65


A Better Way to Write React Code: JSX�������������������������������������������������������������������������� 65
Yeah, Okay, So What Does It LOOK LIKE?!����������������������������������������������������������������� 66
A Slight Detour into Babel Land�������������������������������������������������������������������������������� 68
Compile JSX�������������������������������������������������������������������������������������������������������������� 71
And Now, Put It All Together�������������������������������������������������������������������������������������� 72

vi
Table of Contents

Whither Props?��������������������������������������������������������������������������������������������������������������� 76
Default Props������������������������������������������������������������������������������������������������������������� 77
Typing Props�������������������������������������������������������������������������������������������������������������� 80
Component Lifecycle������������������������������������������������������������������������������������������������������ 83
Summary������������������������������������������������������������������������������������������������������������������������ 86

Chapter 5: Building a Strong Foundation: TypeScript��������������������������������������������� 87


What Is TypeScript?�������������������������������������������������������������������������������������������������������� 87
Jumping into the Deep End�������������������������������������������������������������������������������������������� 89
Beyond the Playground��������������������������������������������������������������������������������������������� 91
Configuring TypeScript Compilation�������������������������������������������������������������������������� 92
The Nitty Gritty: Types����������������������������������������������������������������������������������������������������� 93
String������������������������������������������������������������������������������������������������������������������������� 94
Number��������������������������������������������������������������������������������������������������������������������� 94
Boolean��������������������������������������������������������������������������������������������������������������������� 95
Any���������������������������������������������������������������������������������������������������������������������������� 95
Arrays������������������������������������������������������������������������������������������������������������������������ 95
Tuples������������������������������������������������������������������������������������������������������������������������ 96
Enums����������������������������������������������������������������������������������������������������������������������� 97
Function�������������������������������������������������������������������������������������������������������������������� 98
Object������������������������������������������������������������������������������������������������������������������������ 99
Null, Void, and Undefined������������������������������������������������������������������������������������������ 99
Custom Type Aliases������������������������������������������������������������������������������������������������ 101
Union Types������������������������������������������������������������������������������������������������������������� 102
TypeScript == ES6 Features for “Free”!���������������������������������������������������������������������� 103
The let and const Keywords������������������������������������������������������������������������������������ 103
Block Scope������������������������������������������������������������������������������������������������������������ 103
Arrow Functions������������������������������������������������������������������������������������������������������ 104
Template Literals����������������������������������������������������������������������������������������������������� 105
Default Parameters������������������������������������������������������������������������������������������������� 105

vii
Table of Contents

Spread and Rest (and as an Added Bonus: Optional Arguments)���������������������������� 106


Destructuring���������������������������������������������������������������������������������������������������������� 107
Classes�������������������������������������������������������������������������������������������������������������������� 109
Summary���������������������������������������������������������������������������������������������������������������������� 116

Chapter 6: A Few More Words: Advanced TypeScript������������������������������������������� 119


Interfaces��������������������������������������������������������������������������������������������������������������������� 119
Argument/Object Interfaces������������������������������������������������������������������������������������ 120
Methods in Interfaces��������������������������������������������������������������������������������������������� 122
Interfaces and Classes�������������������������������������������������������������������������������������������� 123
Extending Interfaces����������������������������������������������������������������������������������������������� 124
Namespaces and Modules������������������������������������������������������������������������������������������� 125
Namespaces������������������������������������������������������������������������������������������������������������ 125
Modules������������������������������������������������������������������������������������������������������������������� 129
Decorators�������������������������������������������������������������������������������������������������������������������� 131
Decorator Factories������������������������������������������������������������������������������������������������� 134
Third-Party Libraries���������������������������������������������������������������������������������������������������� 135
Debugging TypeScript Apps������������������������������������������������������������������������������������������ 136
Source Maps����������������������������������������������������������������������������������������������������������� 137
Summary���������������������������������������������������������������������������������������������������������������������� 140
Chapter 7: Tying It Up in a Bow: Webpack������������������������������������������������������������ 141
What’s a Bundle, and How Do I Make One?������������������������������������������������������������������ 142
What’s Webpack All About?������������������������������������������������������������������������������������������ 143
Dependency Graph�������������������������������������������������������������������������������������������������� 143
Entry������������������������������������������������������������������������������������������������������������������������ 144
Output���������������������������������������������������������������������������������������������������������������������� 144
Loaders������������������������������������������������������������������������������������������������������������������� 145
Plugins�������������������������������������������������������������������������������������������������������������������� 146
Modes���������������������������������������������������������������������������������������������������������������������� 147
Browser Compatibility��������������������������������������������������������������������������������������������� 148

viii
Table of Contents

Getting Started with Webpack�������������������������������������������������������������������������������������� 148


Getting More Complex��������������������������������������������������������������������������������������������� 150
Configuration����������������������������������������������������������������������������������������������������������� 153
Using Modules�������������������������������������������������������������������������������������������������������������� 156
Wither TypeScript?������������������������������������������������������������������������������������������������������� 157
Summary���������������������������������������������������������������������������������������������������������������������� 159

Chapter 8: Delivering the Goods: MailBag, the Server������������������������������������������ 161


What Are We Building?������������������������������������������������������������������������������������������������� 161
Basic Requirements������������������������������������������������������������������������������������������������ 162
Setting Up the Project�������������������������������������������������������������������������������������������������� 163
Source File Rundown���������������������������������������������������������������������������������������������� 164
Adding Node Modules��������������������������������������������������������������������������������������������� 165
Adding Types����������������������������������������������������������������������������������������������������������� 166
A More Convenient Development Environment������������������������������������������������������� 168
The Starting Point: main.ts������������������������������������������������������������������������������������������� 170
A Quick Detour: Time to Take a REST���������������������������������������������������������������������� 170
Another Quick Detour: Express, for Fun and Profit�������������������������������������������������� 176
Back to the Code!���������������������������������������������������������������������������������������������������� 177
Gotta Know What We’re Talking to: ServerInfo.ts��������������������������������������������������������� 187
Time to Send the Mail: smtp.ts������������������������������������������������������������������������������������� 189
A Quick Detour: Nodemailer������������������������������������������������������������������������������������ 190
Another Quick Detour: Generics������������������������������������������������������������������������������ 190
Back to the Code!���������������������������������������������������������������������������������������������������� 193
Time to Get the Mail (and Other Stuff): imap.ts������������������������������������������������������������ 195
A Quick Detour: emailjs-imap-client and mailparser���������������������������������������������� 195
Back to the Code!���������������������������������������������������������������������������������������������������� 196
Reach Out and Touch Someone: contacts.ts���������������������������������������������������������������� 204
A Quick Detour: NoSQL�������������������������������������������������������������������������������������������� 204
Another Quick Detour: NeDB����������������������������������������������������������������������������������� 207

ix
Table of Contents

Back to the Code!���������������������������������������������������������������������������������������������������� 209


Testing It All������������������������������������������������������������������������������������������������������������������ 212
Optional Tooling������������������������������������������������������������������������������������������������������� 215
Suggested Exercises���������������������������������������������������������������������������������������������������� 216
Summary���������������������������������������������������������������������������������������������������������������������� 217

Chapter 9: Delivering the Goods: MailBag, the Client������������������������������������������� 219


What Are We Building?������������������������������������������������������������������������������������������������� 219
Basic Requirements������������������������������������������������������������������������������������������������ 223
Setting Up the Project�������������������������������������������������������������������������������������������������� 224
Source File Rundown���������������������������������������������������������������������������������������������� 228
The Starting Point: index.html�������������������������������������������������������������������������������������� 230
The Starting Point, Redux: main.tsx����������������������������������������������������������������������������� 230
A Quick Detour: State’ing the Obvious�������������������������������������������������������������������� 231
Back to the Code!���������������������������������������������������������������������������������������������������� 234
A Bit of Configuration: config.ts������������������������������������������������������������������������������������ 237
A Worker for All Seasons���������������������������������������������������������������������������������������������� 237
A Quick Detour: AJAX���������������������������������������������������������������������������������������������� 238
Mirroring the Server Part 1: Contacts.ts������������������������������������������������������������������ 242
Mirroring the Server Part 2: IMAP.ts������������������������������������������������������������������������ 244
Mirroring the Server Part 3: SMTP.ts����������������������������������������������������������������������� 247
A Cavalcade of Components����������������������������������������������������������������������������������������� 247
A Quick Detour: Material-UI������������������������������������������������������������������������������������� 248
BaseLayout.tsx�������������������������������������������������������������������������������������������������������� 253
A Quick Detour: Functional Components����������������������������������������������������������������� 260
Toolbar.tsx��������������������������������������������������������������������������������������������������������������� 261
MailboxList.tsx�������������������������������������������������������������������������������������������������������� 264
ContactList.tsx��������������������������������������������������������������������������������������������������������� 266
ContactView.tsx������������������������������������������������������������������������������������������������������� 268
MessageList.tsx������������������������������������������������������������������������������������������������������ 273

x
Table of Contents

MessageView.tsx����������������������������������������������������������������������������������������������������� 275
WelcomeView.tsx���������������������������������������������������������������������������������������������������� 280
Suggested Exercises���������������������������������������������������������������������������������������������������� 280
Summary���������������������������������������������������������������������������������������������������������������������� 281

Chapter 10: Time for Fun: BattleJong, the Server������������������������������������������������ 283


What Are We Building?������������������������������������������������������������������������������������������������� 284
Basic Requirements����������������������������������������������������������������������������������������������������� 285
Setting Up the Project�������������������������������������������������������������������������������������������������� 286
Some tsconfig.json Changes���������������������������������������������������������������������������������������� 287
Adding Node Modules�������������������������������������������������������������������������������������������������� 289
Adding Types���������������������������������������������������������������������������������������������������������������� 289
Source File Rundown��������������������������������������������������������������������������������������������������� 289
The Starting Point (the ONLY Point, in Fact!): server.ts������������������������������������������������� 289
A Quick Detour: WebSockets����������������������������������������������������������������������������������� 290
Back to the Code!���������������������������������������������������������������������������������������������������� 293
Serving the Client: The Express Server������������������������������������������������������������������� 294
Handling Messages: The WebSocket Server and Overall Game Design������������������ 294
Finishing Up the WebSocket Server������������������������������������������������������������������������ 299
Of Tiles and Board Layouts�������������������������������������������������������������������������������������� 300
Suggested Exercises���������������������������������������������������������������������������������������������������� 303
Summary���������������������������������������������������������������������������������������������������������������������� 304

Chapter 11: Time for Fun: BattleJong, the Client�������������������������������������������������� 305


What Are We Building?������������������������������������������������������������������������������������������������� 305
Basic Requirements����������������������������������������������������������������������������������������������������� 306
Setting Up the Project�������������������������������������������������������������������������������������������������� 307
Some tsconfig.json Changes����������������������������������������������������������������������������������� 308
Some webpack.config.js Changes�������������������������������������������������������������������������� 309
Adding Libraries����������������������������������������������������������������������������������������������������������� 311

xi
Table of Contents

Adding Types���������������������������������������������������������������������������������������������������������������� 311


Source File Rundown��������������������������������������������������������������������������������������������������� 311
The Starting Point: index.html�������������������������������������������������������������������������������������� 312
The REAL Starting Point: main.tsx�������������������������������������������������������������������������������� 313
The Basic Layout: BaseLayout.tsx�������������������������������������������������������������������������������� 313
Feedback and Status: ControlArea.tsx������������������������������������������������������������������������� 316
Scores��������������������������������������������������������������������������������������������������������������������� 317
Game State Messages��������������������������������������������������������������������������������������������� 318
Where the Action Is: PlayerBoard.tsx��������������������������������������������������������������������������� 319
A Quick Detour: Custom-Type Definitions���������������������������������������������������������������� 320
Back to the Code!��������������������������������������������������������������������������������������������������������� 321
The Render Process������������������������������������������������������������������������������������������������ 322
Talking to the Server: socketComm.ts�������������������������������������������������������������������������� 326
Handling Server-Sent Messages����������������������������������������������������������������������������� 327
Sending Messages to the Server���������������������������������������������������������������������������� 329
The Main Code: state.ts������������������������������������������������������������������������������������������������ 329
A Few Interface for Good Measure�������������������������������������������������������������������������� 330
The Beginning of the State Object��������������������������������������������������������������������������� 330
Back to the Code!���������������������������������������������������������������������������������������������������� 332
Message Handler Methods�������������������������������������������������������������������������������������� 334
The Big Kahuna: tileClick()�������������������������������������������������������������������������������������� 335
Suggested Exercises���������������������������������������������������������������������������������������������������� 344
Summary���������������������������������������������������������������������������������������������������������������������� 345

Chapter 12: Bringing the Dev Ship into Harbor: Docker��������������������������������������� 347
An Introduction to Containers and Containerization����������������������������������������������������� 347
The Star of the Show: Docker��������������������������������������������������������������������������������������� 349
Installing Docker���������������������������������������������������������������������������������������������������������� 350
Your First Container: “Hello, World!” of Course!����������������������������������������������������������� 352

xii
Table of Contents

A Quick Rundown of Key Docker Commands��������������������������������������������������������������� 353


Listing Images��������������������������������������������������������������������������������������������������������� 353
Listing Containers��������������������������������������������������������������������������������������������������� 353
Starting (and Stopping) Containers������������������������������������������������������������������������� 354
Remove Containers and Images������������������������������������������������������������������������������ 355
Pulling Images��������������������������������������������������������������������������������������������������������� 355
Searching for Images���������������������������������������������������������������������������������������������� 355
Attaching to a Container������������������������������������������������������������������������������������������ 356
Viewing Container Logs������������������������������������������������������������������������������������������� 356
Creating Your Own Image��������������������������������������������������������������������������������������������� 357
Deploying to Docker Hub���������������������������������������������������������������������������������������������� 362
Wrapping Up MailBag and BattleJong�������������������������������������������������������������������������� 363
Suggested Exercises���������������������������������������������������������������������������������������������������� 365
Summary���������������������������������������������������������������������������������������������������������������������� 365

Index��������������������������������������������������������������������������������������������������������������������� 367

xiii
About the Author
Frank Zammetti is an application architect for a major financial firm with nearly 25
years of professional experience (plus almost 15 years of nonprofessional experience
before that). He is an author of, including this one, 12 technical books for Apress.
Frank has also authored over two dozen certification exams for SHL as well as several
independent articles for various publications. He is also a fiction author (shameless plug:
look him up on Amazon if you like sci-fi) and a musician of some renown (and here,
“some” should be taken to mean very little). Frank has been married for 25 years (to the
same woman even!) and they have two children together.

xv
About the Technical Reviewer
Kenneth Fukizi is a software engineer, architect, and consultant with experience in
coding on different platforms internationally. Prior to dedicated software development,
he worked as a lecturer for a year and was then head of IT in different organizations.
He has domain experience working with technology for companies in a wide variety
of sectors. When he’s not working, he likes reading up on emerging technologies and
strives to be an active member of the software community.

xvii
Acknowledgments
I’d like to acknowledge the exceptional team at Apress for allowing me to write not one
but twelve books for them over the last decade or so. I’ve worked with so many great
people, and it’s virtually impossible not to forget someone in a list like this, but among
the crew for sure are Ami Knox, Arockia Rajan Dhurai, Beth Christmas, Dulcy Nirmala
Chellappa, Chris Mills, Christine Ricketts, Dominic Shakeshaft, Douglas Pundick, Frank
Parnell, Frank Pohlmann, Gary Cornell, Jill Balzano, Julie Miller, Katie Stence, Kelly
Gunther, Kelly Winquist, Kevin Shea, Kim Wimpsett, Kimberly van der Elst, Krishnan
Sathyamurthy, Laura Cheu, Laura Esterman, Leah Weissburg, Leonard Cuellar, Liz
Welch, Louise Corrigan, Marilyn Smith, Michelle Lowman, Nancy Chen, Nicole Faraclas,
Nirmal Selvaraj, Richard Dal Porto, Sharon Wilkey, Sofia Marchant, Stephanie Parker,
Steve Anglin, Tina Nielsen, and Tracy Brown Collins.
As I said, I’m sure I’ve forgotten someone, but rest assured it was not on purpose!
Thank you all for giving me a shot and allowing me to continue this journey. I most
definitely could not have done it alone and I thank you all, unreservedly!

xix
Introduction
You know, when I started learning how to program, it was a piece of cake!
You’d turn on the computer and be greeted by a nice little “Ready” prompt. You’d
start typing in some code (BASIC), and eventually, you’d type run, hit Enter, and watch
whatever it was you put in there spit back something (my first program was a man drawn
with various keyboard characters doing jumping jacks). You might save that program to a
cassette – yes, kids, a cassette! – and hand it to your friends if you wanted to share.
But that was it. It was just that easy.
Nowadays, though, the story is very different.
Writing even a trivial application now involves layers upon layers of abstractions and
complexities that you must mix together, like baking the world’s most complicated cake,
hoping it all works in the end. Then, should you want to distribute the technological
terror you’ve constructed (sorry, Aldearan), you’ve got even more challenges to
overcome.
How anyone learns to program from scratch these days, I’m not sure!
But I’m hoping to help there!
With this book, I’m going to look at the ingredients that go into baking a cake – err,
building an application – these days. To be sure, it won’t cover everything. And no one
recipe is necessarily the same anyway – there are lots of choices available to a developer
now. But I believe I’ve chosen the ones most commonly used to build modern full-stack
applications.
What exactly is a full-stack application anyway? Well, simply put, it’s an application
that includes both a front-end “client,” like a web site, and a back-end “server,” like, well,
a server! We’re talking about building an application that combines those two halves
into a coherent whole. Most application development these days is web-based in some
way (where “web” doesn’t have to mean something available on the public Internet, but
something built with web technologies like HTML, JavaScript, and CSS), so that’s what
we’re going to be doing in this book.
To do this, we’re going to use React, which is one of the most popular libraries for
building clients out there today. And we’ll use Node.js, which is a popular choice for
back-end development. We’re also going to use TypeScript, a language that enhances

xxi
Introduction

JavaScript on both sides of the fence to make our coding lives better. We’re going to
touch on several other tools that relate to all of this including Babel and Webpack. We’ll
talk about some strategies for connecting the client to the server including REST and
WebSockets. Finally, you’ll learn about packaging up applications using the very popular
Docker.
All this will be combined to build two full, real applications. This way, it’s not just
simple, contrived examples. No, it’ll be real code, practical solutions to real problems
encountered in building them, and real techniques for putting all these pieces together
and making sense of all this complexity.
In the end, you’ll have a solid foundation for building modern full-stack applications
that you can go forward with on your own to create greatness.
I mean it’ll never be as great as my guy doing jumping jacks written in BASIC and
loaded off a cassette, but you gotta have goals.
So let’s get to it. There’s work to be done, learning to be accomplished, and, I hope,
fun to be had!

xxii
CHAPTER 1

Server-Side Action: Node


and NPM
Welcome to the book! I hope you’ve got a comfy chair under you, a tasty drink on
the table next to you and perhaps a light snack (may I suggest some dark chocolate
biscotti?), and your brain ready to soak up a ton of knowledge on modern web
development, ‘cause that’s what the show is all about and the curtains are about to be
drawn!
In this book, we’ll be building two full apps that will demonstrate all the concepts
that we’ll be discussing along the way in a practical manner. Far from being just simple,
contrived bits of code, these are two full apps which are functional and useful (and
even fun, given that one of them is a game, which will provide you a whole new way of
looking at coding). As we do so, you’ll get insight into the thinking that went into them,
their design and architecture, so you get a holistic picture of what’s involved in building
something like these two apps. You will even, here and there, get some notes about
issues I faced and how I resolved them, things that will almost certainly help you achieve
your goals as you charge onward into your own projects.
To start, we’ll look at what is most usually (though not exclusively, as you’ll learn!)
the purview of the server side. Remember that we’re talking “full-stack” development
here, which means you’ll be learning about coding clients as well as the server code they
make use of in order to form a cohesive, whole application. In this chapter, we’ll begin by
looking at two extremely popular tools for developing servers: Node.js and NPM.

1
© Frank Zammetti 2020
F. Zammetti, Modern Full-Stack Development, https://doi.org/10.1007/978-1-4842-5738-8_1
Chapter 1 Server-Side Action: Node and NPM

 f JavaScript Runtimes and Building (Mostly)


O
Servers
Ryan Dahl – that cat has some talent, I tell ya!
Ryan is the creator of a fantastic piece of software called Node.js (or just plain Node,
as it is often written, and as I’ll write it from here on out). Ryan first presented Node at
the European JSConf in 2009, and it was quickly recognized as a potential game-changer,
as evidenced by the standing ovation his presentation received (I presume Ryan is an
excellent presenter generally as well).
Node is a platform for running primarily, though not exclusively, server-side
code that has high performance and is capable of handling large request loads with
ease. It is based on the most widely used language on the planet today: JavaScript. It’s
straightforward to get started with and understand, yet it puts tremendous power in the
hands of developers, in large part thanks to its asynchronous and event-driven model
of programming. In Node, almost everything you do is nonblocking, meaning code
won’t hold up the processing of other request threads. Most types of I/O, which is where
blocking comes into play most, are asynchronous in Node, whether it’s network calls
or file system calls or database calls. This, plus the fact that to execute code, Node uses
Google’s popular and highly tuned V8 JavaScript engine, the same engine that powers its
Chrome browser, makes it very high performance and able to handle a large request load
(assuming that you as the developer don’t botch things of course!).
It’s also worth noting that, as weird as it may sound, Node is single-threaded. It at
first seems like this would be a performance bottleneck, but in fact, it’s a net benefit
because it avoids context-switching. However, this is a little bit of a misnomer in that
it’s more correct to say that Node is event-driven and single-threaded with background
workers. When you fire off some type of I/O request, Node will generally spawn a new
thread for that. But, while it’s doing its work, that single event-driven thread continues
executing your code. All of this is managed with an event queue mechanism so that
the callbacks for those I/O operations are fired, back on that single thread, when the
responses come back. All of this means that there is no (or at least minimal) context-­
switching between threads but also that the single thread is never sitting idle (unless
there is literally no work to do of course), so you wind up with that net positive benefit I
mentioned.

2
Chapter 1 Server-Side Action: Node and NPM

Note In later chapters, you’ll see that Node isn’t specific to the server side of
the equation, and in fact, you don’t always build apps with Node; sometimes you
use it to install and execute tools for various purposes on your own development
machine. Hold on to that thought; we’ll be coming back to before long a few
chapters from now.

None of these technical details are especially important to use as a Node developer,
but the performance it yields is what makes it no wonder that so many significant players
and sites have adopted Node to one degree or another. These aren’t minor outfits we’re
talking about, we’re talking names you doubtless know, including DuckDuckGo, eBay,
LinkedIn, Microsoft, Netflix, PayPal, Walmart, and Yahoo, to name just a few examples.
These are large businesses that require top-tier performance, and Node can deliver on
that promise (again, with the caveat that you as the developer don’t mess things up,
because that’s always possible).
Node is a first-class runtime environment, meaning that you can do such things as
interacting with the local file system, access relational databases, call remote systems,
and much more. In the past, you’d have to use a “proper” runtime, such as Java or .Net
to do all this; JavaScript wasn’t a player in that space. With Node, this is no longer true. It
can compete not only on performance but also in terms of what capabilities it provides
to developers. If you can think of it, chances are you can do it with Node, and that wasn’t
always the case with JavaScript.
To be clear, Node isn’t in and of itself a server. You can’t just start up Node and
make HTTP requests to it from a web browser. It won’t do anything in response to your
requests by default. No, to use Node as a server, you must write some (straightforward
and concise, as you’ll see) code that then runs on the Node “runtime.” Yes, you effectively
write your own web server and app server, if you want to split hairs (or potentially FTP,
Telnet, or any other type of server you might wish to). That’s a very odd thing to do as
a developer – we usually apply the “don’t reinvent the wheel” mantra for stuff like that
and pull one of the hundreds of existing options off the shelf. Plus, writing such servers
sounds (and probably actually is) daunting to most developers, and for good reason! To
be sure, it absolutely would be if you tried to write a web server from scratch in many
other languages, especially if you want it to do more than just serve static content files.
But not with Node!

3
Chapter 1 Server-Side Action: Node and NPM

But remember, acting as a server is just one capability that Node provides as a
JavaScript runtime, and it can provide this functionality only if you, as a developer, feed it
the code it needs to do so! In fact, a great many developer tools, and other types of apps,
use Node as their runtime nowadays. Node really is all over the place!

Note As you’ll see, React, Webpack, and TypeScript, three things that are primary
focuses of this book (Docker being the outlier), use Node to run and/or to be
installed (well, NPM is used to install them if we’re being accurate, but we’ll get to
NPM in just a moment). These are tools, not servers, which is the main point: Node
is useful for much more than just creating servers!

Node allows you to use the same language and knowledge on both client and server,
something that was difficult to accomplish before. In fact, aside from Java and some
Microsoft technologies (see project Blazor, which seeks to do the same thing with C#,
if you’re curious), there never has really been an opportunity to do so until Node came
along. It’s a pretty compelling opportunity.
Another critical aspect of Node is a driving design goal of the project, which
is keeping its core functionality to an absolute minimum and providing extended
functionality by way of APIs (in the form of JavaScript modules) that you can pick and
choose from as needed. Node gets out of your way as much as possible and allows you
only to introduce the complexity you really need, when you need it. Node ships with an
extensive library of such modules, but each must be imported into your code, and then
there are literally thousands of other modules that you can bring in as needed, some of
which you’ll see as we progress throughout this book.
In addition to all of this, getting, installing, and running Node are trivial exercises,
regardless of your operating system preference. There are no complicated installs with
all sorts of dependencies to manage, nor is there a vast set of configuration files to mess
with before you can bring up a server and handle requests. It’s a five-minute exercise,
depending on the speed of your Internet connection and how fast you can type! There
is also no required tooling to work with Node. In fact, a simple text editor is enough, in
simplest terms (though that isn’t to say you won’t want a robust IDE with Node support
later, but at least for this book I won’t be assuming anything other than Notepad or some
equivalent text editor).

4
Chapter 1 Server-Side Action: Node and NPM

All of this makes working with Node so much more straightforward than many
competing options while providing you with top-notch performance and load handling
capabilities. Moreover, it does so with a consistent technological underpinning as that
which you develop your client applications.
That’s Node in a nutshell!
Next, let’s see about getting it onto your machine so that you can start playing with
some code together and we can look at Node in a little more depth.

Note If you aren’t a JavaScript expert, don’t worry, we won’t be getting too fancy.
Even when we get to the apps, I’ll consciously keep things as simple as possible. It
is expected that you have some experience with JavaScript though, but you don’t
need to be Brendan Eich or Doug Crockford (but if you have no experience with
TypeScript, that’s fine; we’ll start from square one with it later).

First Baby Steps with Node: Installation


To get started, there’s only one address to remember:

http://nodejs.org

That’s your one-stop shop for all things Node, beginning, right from the front page,
with downloading it, as you can see in Figure 1-1.

5
Chapter 1 Server-Side Action: Node and NPM

Figure 1-1. Node has a simple web site, but it gets the job done!

Usually, I would tell you to install the latest version available, but in this case, it might
be better to choose a long-term support (LTS) version, because they tend to be more
stable. However, it shouldn’t (he said, with fingers crossed) matter which you choose, for
the purposes of this book. For the record, however, I developed all the code using version
10.16.3, so if you encounter any problems, I would suggest choosing that version, which
you can get from the Other Downloads link and then the Previous Releases link (you’ll
be able to download any past version you like from there).
The download will install in whatever fashion is appropriate for your system, and
I leave this as an exercise for the reader. For example, on Windows, Node provides a
perfectly ordinary and straightforward installer that will walk you through the necessary
(and extremely simple) steps. On macOS X, a typical install wizard will do the same.

6
Chapter 1 Server-Side Action: Node and NPM

Once the install completes, you will be ready to play with Node. The installer should
have added the Node directory to your path. So, as a first simple test, go to a command
prompt or console prompt, type node, and press Enter. You should be greeted with a
> prompt. Node is now listening for your commands in interactive mode. To confirm,
type the following:

console.log("Hello, you ugly bad of mostly water!");

Press Enter, and you should be greeted with something like what you see in Figure 1-­2
(platform differences excepted, I’m a Windows guy myself, unashamedly, so that’s where
the screenshots throughout this book will be from, perhaps with a few exceptions later).

Figure 1-2. The rather uppity (though technically accurate) first greeting, proving
Node is alive

If you find that this doesn’t work, please take a moment and ensure that Node is
indeed in your path. It will make things a lot easier going forward.

More Useful: Executing JavaScript Source Files


Interacting with Node in CLI (Command-Line Interface) mode like this is fine and dandy,
but it’s limited. What you really want to do is execute a saved JavaScript file using Node. As it
happens, that’s easy to do. Create a text file named test.js (it could be anything, but that’s a
pretty good choice at this point), and type the following code into it (and, of course, save it):

let a = 5;
let b = 3;
let c = a * b;
console.log(`${a} * ${b} = ${c}`);
7
Chapter 1 Server-Side Action: Node and NPM

To execute this file, assuming you are in the directory in which the file is located, you
simply must type this:

node test.js

Press Enter after that, and you should be greeted with an execution, such as the one
you see in Figure 1-3.

Figure 1-3. It ain’t much, but it’s a real program running with Node!

Clearly, this little bit of code is unexceptional, but it does demonstrate that Node can
execute plain old JavaScript just fine. It demonstrates that we’re dealing with at least the
ES2015 specification as well, being more specific, thanks to the use of let and template
literals (or string interpolation if you prefer). You can experiment a bit if you like, and you
will see that Node should run any basic JavaScript that you care to throw at it like this.

Node’s Partner in Crime: NPM


NPM, which stands for Node Package Manager, is a companion app that installs
alongside Node (though it is developed separately and can be updated on a different
schedule than Node). With it, you can download packages, which are reusable JavaScript
modules (and any supporting stuff they might need) from a central package registry (or a
private repository if you have one). The central repository you can find at

www.npmjs.com

You can visit it through a web browser and look through all the packages available,
which makes finding exactly what you need easy.

8
Chapter 1 Server-Side Action: Node and NPM

Using NPM is simple: it’s merely another command to run from a command
prompt, just like Node is. For example, let’s say you create a directory named
MyFirstNodeProject. In it, you execute the following:

npm install express

Here, npm is the CLI program that is NPM itself, and install is one command you
can issue to it. Then, express is an argument to that command, and this is the general
form that most of your interactions with NPM will take.

Note Most NPM commands have a shorter form as well. For example, rather than
type install, you can just type i, and it will do the same thing. Consult the NPM
docs for these shortcuts, or be pedantic like your favorite author and always type it
long-form, err, for clarity or something!

If you execute that, you’ll find that a directory called node-modules has been created,
and inside it will be a lot of…well, a lot of stuff you typically don’t need to worry about
too much! In short, though, it’s all the code that makes up the Express module (which
doesn’t matter right now, but is a JavaScript module, or package if you prefer, which we’ll
be using in the MailBag app a few chapters hence… but we’ll get to that app in due time,
we’ve got a fair bit of ground to cover before then, so for now suffice it to say it’s one of
the two apps we’re going to be building with the technologies discussed over the first six
chapters), plus whatever modules Express itself depends on (and whatever they might
depend on, and so on). NPM takes care of fetching all those dependencies for you. You’ll
also notice a file named package-lock.json has been created, and for our purposes
here, you don’t need to worry about that except to know not to delete it as NPM needs it
to do its job.
When you use the install command like this, the modules you name are installed
in the current directory, and this is referred to as the local cache, or project cache. You
can also install the module into what’s called the global cache by adding an argument to
the command:

npm install -g express

9
Chapter 1 Server-Side Action: Node and NPM

Now, Express will be installed in a location outside the current directory and will
be shared by all Node projects (or, more precisely, it will be available to all projects,
because, of course, a project won’t use a globally installed module unless you tell it to).
Most usually, you will want to install dependencies in the project cache so that different
projects can use different version of a given module than other projects (there is always a
single version of a given module in the global cache, if any are present at all).

A Few More NPM Commands


Aside from install, there are many other NPM commands, but you’ll probably only use
a subset most of the time. For example, to find out what modules are installed in your
project, you can issue this command:

npm ls

Like on a *nix system, ls is short for list, and that’s what it does: lists the installed
modules. What you’ll see is a textual tree that shows the modules and then the modules
they depend on. In other words, more will likely be shown than just the modules you
explicitly installed (some modules don’t have dependencies, but in the NPM ecosystem,
those tend to be the exception rather than the rule).

Tip One very helpful tip I can give is that if you want to see just the top-level
modules, whether in the global or local cache, you can add --depth=0 to the ls
command.

If you want to see what’s installed in global cache instead, you can do

npm -g ls

In fact, keep that -g option in mind because you can add that to most NPM
commands to differentiate between the local and global caches.
You can also update a given module:

npm update express

Just provide the name of the module to update, and NPM will take care of it, updating
to the latest available version. If you don’t provide a package name, then NPM will dutifully
update all packages. And yes, you can drop a -g on it either way to target the global cache.

10
Chapter 1 Server-Side Action: Node and NPM

You can, of course, uninstall packages too:

npm uninstall express

Execute that and NPM will wipe Express from the local cache, along with its transient
dependencies (so long as nothing else that remains that depends on them).
These few commands represent likely the majority of what you’ll need to interact
with NPM. I refer you to the NPM docs for other commands (and note that just typing
npm and hitting Enter at a command prompt will show you a list of available commands,
and you can then type npm help <command> to get information about each).

Initializing a New NPM/Node Project


Now, in all of this, I did skip one step that clearly is optional but is, in fact, typical, and
that’s initializing a new project. With most Node/NPM projects, you’ll also have a file
named package.json in the root directory of the project. This file is the project manifest
file, and it provides metadata information to NPM (and Node, at least indirectly) about
your project that it needs to do certain things. It will tell NPM what modules to install if
they haven’t been installed yet for one thing (which makes giving a project to another
developer very easy!). It will also contain information like the name and version of the
project, its main entry point, and lots of other information (most of which is optional, but
we’ll look at that a bit more in the next chapter).
While you can write this file by hand or even go entirely without it, it’s a good idea to
have it, and it’s a good idea to let NPM create it for you, which you can do by executing
this command:

npm init

If you are following along, please make sure the directory you run this from is empty
(delete node_modules and package-lock.json if present, both of which will be described
later). This will trigger an interactive process that walks you through the creation of the
package.json file, something like you see in Figure 1-4.

11
Random documents with unrelated
content Scribd suggests to you:
occasionally with me. I have been doing—I am doing—all I can for
you."

"What do you mean?"

Berwick's steady, angry gaze disconcerted his sister, but she was
mentally adroit, and determined not to fear him in his present mood.

"You know best what I ought to mean!" she cried. "You


apparently take pleasure in Mrs. Rebell's company, and it was to
please you that I asked her to come here. I mean nothing else. But I
should like to add that, now I know her, I have grown to like, and
even to respect her." Berwick's face softened, but again he looked at
her in the way she dreaded as she added, "I do not think you should
act so as to make those about you aware that you so greatly prefer
her company to that of our other guests. I am sure Mr. O'Flaherty
has noticed it. Perhaps I ought to add that I am speaking entirely for
her sake."

On leaving Miss Berwick and her brother, Mrs. Rebell went up to


her room. There she sat down and fulfilled a neglected duty,—the
writing of a long letter to Grace Johnstone. She did not find the task
an easy one. She knew that her friend would expect to be told much
of the occupants of Chancton Cottage, and especially of Oliver. The
writer was well aware how letters were treasured at Santa Maria,
and, till the last fortnight she had written to the woman who had
been so good a friend to her by every mail. Suddenly she bethought
herself of the ball. Why, here was a subject all ready to her pen! But
Barbara was no polite letter-writer, and she found the description
difficult; especially did her references to Oliver and to his mother
seem hypocritical. During those hours at Halnakeham Castle she had
been scarcely aware of the young man's existence, while Mrs.
Boringdon she actually disliked.
One reason why Barbara had been glad to come to Fletchings had
been that it meant escape from Boringdon's constant presence at
the Priory, and the daily morning walk with him to the home farm.
She had come to resent Oliver's assumption of—was it brotherly?—
interest in what she did and left undone. The thought that in three
days she would again be subject to his well-meant criticism and
eager, intimate advice certainly added another and a curiously acute
touch of discomfort to her return to Chancton.

For the first time since Mrs. Rebell's stay at Fletchings, dinner,
served in a blue and white octagon room which seemed to have
been designed to serve as background to Miss Berwick's fair, delicate
type of beauty, passed almost silently and rather dully. Berwick and
O'Flaherty, tired after their long day in the open air, scarcely spoke;
Mr. Daman alone seemed entirely at ease, and he babbled away
happily, trying to extract material for his recollections from Lord
Bosworth's better garnished memory.

And so it was with a sense of relief that Barbara followed her


hostess out of the room. During the last few days the two women
had become, in a sense, intimate. Each liked the other better than
either would have thought possible a week before. They had one
subject in common of which neither ever tired, and yet how
surprised they both would have been to learn how constantly their
talk drifted to the political past, the uneventful present, the brilliant
nebulous future, of James Berwick!

Arabella led the way up to the music gallery, and there, very
soon, the two younger men joined them.

Miss Berwick was sitting at an inlaid spinet, playing an old-


fashioned, jingling selection of Irish melodies, and O'Flaherty, taking
up his stand by the fire-place, was able to look down at the player
without seeming to do so.

Listening to the woman he had loved making music for him,


Daniel O'Flaherty's mind went back, setting out on a sentimental
excursion, dolorous as such are apt to be, into the past. No other
woman's lips had touched his since their last interview, thirteen
years before; and yet, standing there, his arm on the mantel-piece,
his right hand concealing his large rather stern mouth, he told
himself that his love for Arabella Berwick had burned itself out, and
that he could now look at her quite dispassionately.

Still, love may go, and interest,—even a certain kind of sentiment,


—may remain. What else had brought him to Fletchings? Above all,
what else had made him stay on there, as he was now doing?
O'Flaherty still felt an odd closeness of heart,—aye, even of body,—

Miss Berwick, to this woman whom others found so


unapproachable. The years which had gone by, the long separation,
had not made them strangers. After she had left him, as he thought
so cruelly, he had made up his mind to put away all thought of her.
He had believed it certain that she would marry—indeed, during that
last interview she had told him that she intended to do so—and
thinking of this, to a man so callous and incredible a statement, his
heart had hardened, not only to her, but in a sense to all women.

Then time had gone on, and Lord Bosworth's niece had remained
unmarried—wholly devoted, so said rumour, to her brother, but living
with her uncle instead of with James Berwick because of her filial
affection and gratitude to the older man. That O'Flaherty had known
not to be true, for no special tie bound Arabella to her uncle. The
arrangement was probably one of convenience on either side.

And now, during these last few days? O'Flaherty acknowledged


that Miss Berwick's manner to him had been perfect—courteous and
kind, nay, even deferential, and then sometimes a look, a word,
would subtly acknowledge his claim on her special attention, while
putting forward none of her own. How could he help being flattered?
From where he now sat, he could see, without seeming to observe
too closely, the delicate, cameo-like profile, the masses of flaxen
hair, less bright in tint than when he had first admired what was still
Arabella's greatest beauty.

The barrister was under no illusion as to why he had received this


invitation to Lord Bosworth's country house. His present host, and of
course his hostess, wished him not merely to be on James Berwick's
side in the coming political struggle, for that he was already, but to
ally himself in a special sense with this future Cabinet-Minister, and
to join the inner circle of his friends and supporters. Neither of them
yet understood that in politics all O'Flaherty cared for supremely was
his own country, in spite of the fact that he had always sat for an
English constituency, and had never identified himself, in any direct
sense, with the Irish party. Whatever his future relations to Miss
Berwick might be, his attitude to her brother must be influenced by
Berwick's attitude to Ireland and Irish affairs. Perhaps it would be
more honest, so he told himself to-night, to let Arabella know this
fact, for during the last few days he had avoided any political
discussion with his host or his hostess.

Daniel O'Flaherty had watched James Berwick's career with


painful interest. During his brief, passionate intimacy with the sister,
the young Irishman had disliked the brother intensely. He had
despised him for squandering,—as for a while Berwick had seemed
to do,—his many brilliant gifts. Perhaps O'Flaherty had also been
jealous of those advantages which came to the younger man by the
mere fact of his name, and of his relationship to Lord Bosworth.

Then, with the passing of years, the barrister had become, as the
successful are apt to do, more indulgent, perhaps more
understanding, in his view of the other's character and ambitions.
Also nothing succeeds like success, and James Berwick had himself
by no means lagged behind. To O'Flaherty there had been nothing
untoward in Berwick's marriage. He had regarded it as one of those
strokes of amazing luck which seem to pursue certain men; and
though a trifling circumstance had made the barrister vividly aware
of the young politician's conditional tenure of his dead wife's fortune,
the man who had fought his way to eminence naturally regarded the
other as belonging to that class which seems in this country
sufficiently wealthy, with the garnered wealth of the past, to
consider the possession of a larger or of a lesser income as of
comparatively small account.

Daniel O'Flaherty was an Irishman, a lonely man, and a Roman


Catholic—thus traditionally interested in romance. And so, during
these days at Fletchings, he had become aware, almost in spite of
himself, of Berwick's evident attraction to Mrs. Rebell—to the gentle,
intelligent woman whom he, O'Flaherty, naturally regarded as
Arabella's widowed friend. It amused him to see the course of true
love running smooth. What amazing good fortune seemed to pursue
James Berwick!

True, the shrewder half of O'Flaherty's mind warned him that Miss
Berwick's action in deliberately throwing her brother with so
charming a woman as Barbara was an odd, an almost unaccountable
move on her part. But there was no getting over the fact that she
was doing this, and most deliberately.

Well, all that money could do for Berwick had surely been
accomplished. The barrister, watching the two—this man and woman
wandering in a paradise of their own making—felt that Berwick was
indeed to be envied, even if he was on the eve of forfeiting the huge
income which had for so many years given him an almost unfair
prestige and power among his fellows. Still, now and again,—to-
night for instance, when he became aware that Berwick and Mrs.
Rebell had retreated together to the further end of the long, bare
room,—he wondered if Arabella was acting sentiently, if she really
wished her brother to marry again.
Mrs. Rebell and the man she called her friend stood together, half
concealed by the organ which gave the gallery its name. They were
practically alone, for the long room was only lighted by the candles
which threw a wavering light on Arabella's music-book. For the first
time since she had arrived at Fletchings, Barbara felt ill at ease with
her companion. Twice during dinner she had looked up and seen
Berwick's eyes fixed on her, or so she thought, coldly and accusingly.
What had she done? For what must she ask forgiveness?

"Where were you before dinner?" he said at last, in a low voice. "I
looked for you everywhere. I found you, and then you disappeared—
utterly! We were close to the Priory to-day, and I went in for a
moment, thinking you would like to have news of Madame
Sampiero. By the way, McGregor gave me some letters for you."

He put two envelopes down on the ledge of a prie-dieu behind


which Barbara was standing, and which formed a slight barrier
between them. She took the letters in her hand, and then, partly
because of the dim light, put them back again on the prie-dieu. One
note, unstamped, was from Oliver Boringdon,—she knew the
handwriting, and so did Berwick. Barbara was to have gone back to-
day; doubtless this note concerned some village matter which the
writer was unwilling to mention to Doctor McKirdy. The other
envelope bore the peculiar blue West Indian stamp. Why had not
McGregor kept these letters till Tuesday? For the moment Barbara
wanted to forget Boringdon and his rather morbid susceptibilities—to
forget, till her next letter to the Johnstones, Santa Maria.

"Won't you read your letters?" Berwick was looking straight across
at her with a singular expression—was it of appeal or of command?
—in his eyes.

"Why should I—now?" But a moment later she changed her mind,
"Yes, of course I will; Mr. Boringdon may have sent some message
to my god-mother which ought to be seen to at once——" She
opened the note, glanced through it, then put it down on the ledge
of the prie-dieu.

Berwick had turned away while she read Boringdon's note, but
now he was again staring at her with those strange, appealing eyes
which seemed to shine in the dim light.

Reluctantly, as if in spite of herself, Barbara stretched out her


hand and took up the other letter. Yes, it was, as she thought, from
Andrew Johnstone—a bare word of kindly acknowledgment for the
return of the fifty pounds which he had lent her.

She looked round, still holding the letter in her hand, but they
were far from the fire—

Berwick's face became set. Ah! no, that should not be.

"Mrs. Rebell—?"

He had not called her so, to herself, since the drive back from
Halnakeham Castle, and she had not noticed his avoidance of her
name; but now, the formal mode of address fell strangely on her
ears.

"Yes?"

"May I read these two letters?" He added, almost inaudibly, "You


cannot think more ill of me than I do of myself."

Barbara suddenly felt as if she were taking part in an unreal


scene, a dream colloquy, and yet she knew this was no dream. What
had happened, what evil magic had so transformed her friend? That
maternal instinct which slumbers lightly in the depths of every
woman's heart, woke into life; she did not stay to diagnose the
disease of which this strange request was a symptom: "Do read
them," she said, and tried to speak indifferently, "I do not think ill of
you—far from it, as Doctor McKirdy would say."
She put Johnstone's letter down by the other, but Berwick left
them lying there; he still looked at her with a probing, suspicious
look, and she began to be desperately afraid. At Santa Maria she
had once met a miserable white man, the overseer of a
neighbouring plantation, who was said to have suddenly gone
"fantee"—so had that man looked at her, as Berwick was doing now,
dumbly. Was this what he had meant when he had spoken to her in
the carriage of ungovernable impulses—of actions of which he had
afterwards felt bitterly ashamed?

Very slowly, still looking at her, he at last took up the two letters.
Then, with a sudden movement, and without having looked at it, he
put Boringdon's back on the ledge of the prie-dieu. "No," he said
roughly, "not that one—I do not think he ought to write to you, but
no matter!" Barbara felt herself trembling. She was beginning to
understand. Berwick's hands fingered nervously the West Indian
letter; at last he held it out to her, still folded, in his hand. "Here it is
—take it—I won't read it!"

"Oh! but do," she said. "It is from Mr. Johnstone, saying that he
has received the money you so kindly arranged to send back for
me."

But Barbara's words came too late.

"Mr. Johnstone?" Berwick repeated the name, then laughed


harshly. "Fool that I was not to think of him! But all to-day, since
McGregor gave me that letter, I have been in hell. Of course you
know what I believed"—Barbara's lips quivered, and her look of
suffering ought to have disarmed the man who was staring at her so
insistently, but he was still possessed by a jealous devil. "Tell me"—
and, leaning over the prie-dieu, he grasped her hands—"We may as
well have it out now. Do you hear from him—from your husband, I
mean? Do you write to him—sometimes?"

She shook her head, and Berwick, at last free to see the agony
and surrender in the face into which he was looking down, and to
which he suddenly felt his lips so near, was swept by an irresistible
rush and mingling of feelings—remorse and fierce relief, shame and
exultant joy.

"I think we ought to go downstairs,"—Arabella's clear voice broke


into and echoed through the silent room.

Berwick straightened himself slowly. Before releasing Barbara's


hands he kissed first one and then the other. As he did so, passion
seemed to melt into tenderness. How fragile, how childish he had
thought the fingers resting on his arm that first evening of their
acquaintance! He remembered also the fluttering, the trembling of
her ringless left hand when for a moment he had covered it with his
own during that drive from Halnakeham to Chillingworth, when he
had made so much—or was it so little?—of his opportunity.

The two walked down the gallery, towards O'Flaherty, who was
still standing by the wood fire, and Arabella, who was putting out
the candles with the rather disdainful thoroughness and care she
gave to small household matters. Lord Bosworth's servants were old,
like himself, and grew unmindful of their duties.

Berwick suddenly left Mrs. Rebell's side, but not till he had
reached the door did he turn round and say, "I am not coming
down, for I have work to do, so good-night!" A moment after, he
was gone, with no more formal leave-taking.

That night Barbara cried herself to sleep, but to her tears brought
no relief—rather an added shame for the weakness which made
them flow so bitterly. She felt overwhelmed by a great calamity—
face to face with a situation out of which she must herself, unaided,
find an issue.
She had asked so little of the shattered broken life which
remained to her—only quietude and the placid enjoyment of a
friendship which had come to her unsought, and in which there
could be no danger, whatever Madame Sampiero or Mrs. Turke
might think. Did not the feeling which bound her to James Berwick
enjoy the tacit approval of such a woman as was Arabella Berwick?
What else had made Miss Berwick say to her, as she had done, that
her brother could never marry? Surely the words had been uttered
with intention, to show Mrs. Rebell how desirable it was that he
should have—friends?

Till to-night, love, to Barbara Rebell, had borne but two faces.
The one, that of the radiant shadow-like figure, half cupid half angel,
of her childhood and girlhood, was he who had played his happy
part in the love affair of her father and mother, binding them the one
to the other as she, Barbara, had seen them bound. It was this love
—noble, selfless, unmaterial in its essence, or so she had thought—
that lighted up Madame Sampiero's face when she spoke, as she
sometimes did speak, in the same quivering breath, of Lord
Bosworth and her little Julia.

Love's other face, that which she shuddered to know existed, had
been revealed to her by Pedro Rebell. It was base, sensual, cunning,
volatile, inconstant in its very essence, and yet, as Barbara knew,
love after all—capable, for a fleeting moment, of ennobling those
under its influence. Such, for instance, was love as understood by
the coloured people, among whom she had spent these last years of
her life, and with whose elementary joys and sorrows she had
perforce sympathised.

Now, to-night, she realised that love could come in yet a third
guise—nay, for the first time she saw that perhaps this was the only
true love of them all, and that her first vision of the passion had
been but its shadow. Some such feeling as that which now, she felt
with terror, possessed her body as well as her soul, must have made
her mother cling as she had clung, in no joyless way, to sombre,
disgraced Richard Rebell.

Love again—warm, tender, passionate love—had linked together


Lord Bosworth and Barbara Sampiero for so many years, and had
found expression in their child. Thinking of those last two, Barbara
lay and trembled. Bitter words of condemnation uttered by her
father leapt from the storehouse of memory, as did the fact that her
mother had once implied to her that but for Madame Sampiero, but
for something—was it something wrong, or merely selfish and
unwise which she had done?—Barbara's father might have returned
in time to England and made some attempt to rehabilitate himself.

The maid who brought in her cup of tea in the morning laid a
parcel down on Barbara's bed. It was a book wrapped in brown
paper, and fully addressed to her with the superscription:—

"Dear Mrs. Rebell,—Here is the book I promised to send you.

"Yours truly,

"James Berwick."

Some instinct made her wait till she was alone. Then, opening the
parcel, she saw that, with the volume of Jacobite songs Berwick had
indeed promised to give her, was a large envelope marked "private."
From it she drew out slowly some twenty sheets or more, closely
covered with the as yet unfamiliar writing of the man she loved. To
the end of her life Barbara could have repeated portions of this, her
first love letter, by heart, and yet, before going downstairs, she burnt
each separate sheet.

Over the last she hesitated. Indeed, she cut out the three words,
"my heart's darling." But the little gilt scissors had belonged to her
mother—how would her mother have judged what she was now
doing?—and the slip of paper went into the fire with the rest.
"He smarteth most who hides his smart
And sues for no compassion."

Raleigh.

"Would you mind taking me with you to church this morning? Miss
Berwick tells me that her uncle won't be shocked."

When Mrs. Rebell made her request, Daniel O'Flaherty was


walking up and down the small hall, waiting for the carriage in which
he was to drive that Sunday morning to the nearest Roman Catholic
chapel. He had shared with the two ladies a comparatively early
breakfast, for the service he was to attend took place at ten.

"Yes, of course," he said, rather awkwardly, "I shall be very glad


of your company, but I'm afraid you won't be comfortable, for Mass
is said, it seems, in a little mission room." O'Flaherty had a vividly
unpleasant recollection of the last time he had taken "a smart lady"
to church. She had apparently expected to find a Notre Dame or
Sistine Chapel in the wilds of Herefordshire, and she had been very
much annoyed with the inartistic furnishings of the iron chapel. So it
was that Mrs. Rebell's request fell disagreeably on his ear.

Barbara's whole soul was possessed with the desire of putting off
the meeting with Berwick. How could she greet him before his
sister? how could she behave as if last night—as if his soul-stirring,
ardent letter, had not been? Berwick had written, among a hundred
other contradictory things, "Everything shall go on as before. I will
school myself to be content with the least you can give me." But
even she knew that that was impossible, and she blessed the chance
which had now come to her of escaping for a few hours the
necessity of playing a part before Lord Bosworth and Arabella.
So absorbed was Barbara in her thoughts that she scarcely
noticed Mr. Daman, when she crossed him on the broad staircase on
her way to her room to get ready for her expedition. The old man,
however, had seen the light from a large window beat straight on
her absorbed face. For the first time Barbara reminded him of her
father, of Richard Rebell, and the reminiscence was not pleasing.
Pretty women, he said to himself rather crossly, should study their
looks; they owed it to those about them. They ought not to get up
too early in the morning and go racing upstairs! Why, it was now
only half-past nine, and Mrs. Rebell had evidently already
breakfasted. He himself was up at this unwonted hour because it
was Sunday, and on Sunday everything should be done to spare the
servants in a country house. Septimus Daman lived up to his own
moral code much more completely than many of those who
regarded him as a selfish old worldling could pretend to do. Still, he
did not like to be baulked of innocent pleasures, and not least
among them was that of having his tea poured out for him on
Sunday morning by a pretty woman.

"Then you've breakfasted too?" Failing Barbara, Mr. Daman would


have liked the company of Daniel O'Flaherty. "Oh, I forgot! of course
you're going to your church"—a note of commiseration crept into the
thin voice; the old Queen's Messenger belonged to a generation
when an Irishman's religion was still the greatest of his disabilities.

"Yes, and I'm taking Mrs. Rebell with me." Septimus Daman's
vested interest in Barbara amused the barrister.

"Are you indeed?" Old Septimus always went to church on


Sunday, but he liked to have the duty sweetened by the presence of
youth and beauty in the pew. "You never saw her mother, did you?"

"No. The Rebell Case took place some years before I came to
London." It was not the first time Mr. Daman had asked the
question, but O'Flaherty answered very patiently, and even added—
also not for the first time—"She must have been an exceptionally
beautiful and charming woman."

"Perfection, absolute perfection! Her daughter isn't a patch on her


as to looks. I remember now the first time I saw Mrs. Richard Rebell
I thought her the loveliest creature I'd ever set eyes upon. Her name
was Adela Oglander, and people expected her to do uncommonly
well for herself. Awful to think what she did do, eh? But Richard
Rebell was a very taking fellow in those days. When I was a young
man women were content to look—well, as Mrs. Richard Rebell
looked! One doesn't see such pretty women now," Mr. Daman
sighed, "I suppose our Mrs. Barbara lost her complexion in the West
Indies. Those climates, so I've always understood, are damnation to
the skin. Not that hers has roughened—eh, what? And she can still
blush—a great thing that, almost a lost art!" he chuckled. "From
what Bosworth tells me she had an awful time with the brute she
married."

"Was he in the Army?"

O'Flaherty was vaguely interested. He and Mrs. Rebell had had a


good deal of desultory talk, but she never alluded to her married life.
Those years—he roughly guessed them to be from twenty to seven-
and-twenty—seemed dropped out of her memory.

"Not that I ever heard of. He's always been a sugar planter, a
descendant of a Rebell younger son who went out to the West
Indies to make his fortune a hundred years ago. Poor Barbara
Sampiero told me about it at the time of the marriage."

"And how long has Mrs. Rebell been a widow?"

"She's not a widow. Whatever gave you such an idea?" The old
man shot a sudden shrewd look at the barrister; O'Flaherty's face
expressed surprise, yes, and profound annoyance. Dear, dear, this
was distinctly interesting!
Mr. Daman lowered his voice to a whisper, "Her husband's very
much alive, but he's signed, so Bosworth tells me, some kind of
document promising to leave her alone. Of course he keeps her
fortune, such as it is, for she was married before this act which
makes women, I understand, so very independent of their lords and
masters. But that's rather a good thing, for it takes away his only
reason for molesting her. Still, there'll be trouble with him, if, as I'm
told, Madame Sampiero intends to leave her well off. Good Lord,
what a business we all had with Napoleone Sampiero! He was a
regular leech. Strange, isn't it, that both these poor dear women—
each, observe, a Barbara Rebell—should make such a mess of their
lives? However, in this case there's no Bosworth to complicate
matters!"

O'Flaherty wheeled round, and looked hard at the old man, but
Septimus Daman had spoken with no after-thought in his mind. He
had come to the stage of life when old people are curiously
unobservant, or perhaps it should be said, no longer capable of
realising the proximity of passion.

Condemnation of James Berwick, who, it seemed to O'Flaherty,


should remember the fact that he was under his sister's roof, and a
certain pity for, and shrinking from Mrs. Rebell, the woman now
sitting so silently by his side in the victoria, filled the barrister's mind.
He was also aware of experiencing that species of bewilderment
which brings with it the mortifying conviction that one has been
excessively, inexcusably blind. O'Flaherty cast his mind back over the
last week. That which he in his simplicity had taken for love,—love
capable of inducing such a man as Berwick to make a great sacrifice,
—was doubtless but the preliminary to one of those brief intrigues of
which he heard so much in the world in which he now lived.
And Mrs. Rebell? He had really liked her—unconsciously thought
the better of Arabella for having such a woman, one so gentle,
kindly, unassuming, for her friend. He knew the tragic story of
Richard Rebell, of his banishment from the pleasant world in which
he had held so prominent a place; and Barbara had been the more
interesting, the more worthy of respect in his eyes because she was
in no sense ashamed of her parentage. Was it possible that she was
one of those women—he had sometimes heard of them—who are
said to possess every feminine virtue save that on which, as he, the
Irish farmer's son, absolutely believed, all the others really depend?

O'Flaherty had seen a great deal of Mrs. Rebell; they had had
more than one long talk together. Never had he met a woman who
seemed to him more pure-minded in the very essence of her. And
yet—well, the Irishman had seen—as indeed who could help seeing,
save that self-centred and naif egoist, Septimus Daman?—that
Barbara loved Berwick. The sight of these two, so absorbed in one
another, had deeply moved the one who looked on, and quickened
his own feeling for Arabella into life.

The barrister had envied Berwick the devotion of such a woman,


thinking a fabulous fortune well forfeited in the winning of Barbara
Rebell as companion on that mysterious, dangerous journey which
men call life. Realising the kind of intimate sympathy which seemed
to bind these two, O'Flaherty had recalled the phrase, "a marriage of
true minds," and he had thought of all it would mean to Berwick,
even as regarded his public career, to have so conciliatory, so
charming a creature by his side. Arabella Berwick, in spite of her
many fine qualities and intellectual gifts, possessed neither the tact
nor the self-effacement so essential to the fulfilment of the rôle of
statesman's wife or sister.

And now O'Flaherty learned that all the time he had been thinking
these things, Mrs. Rebell was well aware that there could be nothing
permanent or avowable in her tie with Berwick; while Berwick, on his
side, was playing the most delightful and absorbing of the great
human games with dice so loaded that, come what might, he was
bound to win. The barrister told himself that he had indeed been
simple-minded to suppose that such a man as Arabella's brother
would sacrifice to love the wealth which gave him an absolute and
preeminent position among those he wished to lead. "A marriage of
true minds?"—an ugly look came over the plain, strong face of the
man sitting by Mrs. Rebell, and she, catching that look, wondered
what hateful thought, or sudden physical discomfort, had brought it
there.

But, when once he found himself kneeling in the humble little iron
chapel, long habit acted on Daniel O'Flaherty's mind, cleared it of
sordid images, made him think more charitable thoughts of the
woman who crouched rather than knelt by his side, in what seemed
a position of almost painful abasement. Poor Barbara Rebell!
Mingling with the prayers he knew by heart, and which were, after
all, one long supplication for mercy and forgiveness, came the slow
conviction that she might not be deserving of so much
condemnation as he had at first assumed. Perhaps she had come
here, with him, to-day, to be out of the way of temptation, and not,
as he had unkindly suspected, to satisfy an idle and not very healthy
curiosity.

Busy as he had been last night in the music gallery with thoughts
of his own self and Arabella, O'Flaherty had yet been aware that an
eager colloquy was going on by the organ. He had heard Berwick's
voice become urgent and imperious, and he had put down the other
man's rather dramatic disappearance, and Mrs. Rebell's extreme
quietude during the rest of the evening, to some lovers' quarrel
between these two, who up to that time had required no such
artificial stimulus to their passion. Perhaps what had taken place
between them had been more tragic, for Mrs. Rebell looked to-day
very unlike her gentle, composed self.

Barbara had risen from her knees, and sat apparently listening to
the little sermon. The expression of her face suddenly recalled to
Daniel O'Flaherty an evening in his life—that which had followed his
parting from Arabella Berwick. He had been taken by friends to the
play, and on leaving the theatre had found that his mind had
retained absolutely nothing of what had gone on before him on the
stage. Not to save his life could he have recalled a single scene, or
even the most telling of the speeches to which he had been listening
the last three hours. Doubtless he had then looked as Barbara
looked now; and a feeling of great concern and infinite pity took the
place of that which had filled his mind during the drive from
Fletchings. But this new-born charity did not extend to Berwick; for
him, O'Flaherty still felt nothing but condemnation.

They waited till the small congregation had streamed out, and
then walked slowly down the little aisle. "You don't look fit to walk
back. I expect I can easily get a carriage if you will wait a little
while."

But Barbara answered with nervous decision, "I would much


rather walk, in fact, I was about to ask you if you would mind going
round by Chancton; it is scarcely out of our way, and I want to see
Madame Sampiero."

"I beg you to send for me—to-day—home again. I am tired of


being away from you! Oh! do not refuse, Marraine, to do as I ask
——"

Barbara was kneeling by Madame Sampiero's couch, holding the


stiff, trembling hands, gazing imploringly into the set face and the
wide open eyes, now fixed on her with rather sad speculation and
questioning.

"Why should I refuse? Have I not missed you? Ask McKirdy if we


have not all missed you, child?"
The muffled tones were even less clear than usual, but Barbara
gave a sigh, almost a sob, of relief. "You must insist on my coming
back, at once,—at once, Marraine—or they will want to keep me!
Some people are coming over to lunch to-morrow, and Miss Berwick
will wish me to be there."

"Why go back at all?"

"I must go back. Someone is waiting for me outside." Madame


Sampiero's eyelids flickered—"Oh, no, no! Marraine, not Mr. Berwick,
but a Mr. O'Flaherty. Besides, they would all be so surprised if I were
not to come back now. Send for me this afternoon."

She bent over and kissed her god-mother's hands. "How nice it is
to be home again!" and her voice trembled, "What, darling
Marraine? Was Lord Bosworth kind? Yes, indeed—more than good
and kind! I have been very happy—very, very happy!" and then she
turned away to hide the tears rushing to her eyes.

While waiting for Mrs. Rebell, Daniel O'Flaherty looked with great
interest at the splendid old house before which he was pacing up
and down. This, then, was Chancton Priory, the place belonging to
the woman who some said had made, and others said had marred,
Lord Bosworth's life.

The story had been widely known and discussed. Madame


Sampiero had made a desperate and an unsuccessful effort to break
her marriage to the Corsican adventurer whom she had married in a
moment of headstrong, girlish folly; and the world, hers and Lord
Bosworth's, had been loud in its sympathy. But for the fact that the
ceremony had been solemnised according to French law, she would
easily have obtained release.
For a while, all had gone fairly well. Each lived his and her own
life; Madame Sampiero had acted as hostess to Lord Bosworth's
friends, both at Chancton, and in her London house, for she was a
wealthy woman, and all, save the very strait-laced, had condoned a
situation which permitted the exercise of tolerant charity.

Then had come the sudden appearance on the scene of a child, of


the little Julia concerning whose parentage scarcely any mystery was
made, and the consequent withdrawal of that feminine countenance
and support without which social life and influence are impossible in
such a country as England.

O'Flaherty looked up at the mullioned windows sunk back in the


grey stone; behind which of them lay the paralysed woman, now
bereft of lover, of child, of the company of friends, of everything
which made life worth living to such as she? Septimus Daman had
talked of Madame Sampiero again and again during the last few
days, and had apparently rejoiced in the thought that Mrs. Rebell
was so devoted to the mistress of Chancton Priory. What a strange
life the two women must lead here! The barrister looked round him
consideringly. November is the sad month of our country year. Even
the great cedars added to the stately melancholy of the deserted
lawns, and leafless beeches.

Now, at last Mrs. Rebell was coming towards him from the porch;
he saw that she looked, if not happier, more at peace than she had
done before going into the Priory, yet her eyelids were swollen, and
if victorious she seemed one whose victory has cost her dear.

As she led the way down the broad grass drive, she began to talk
of indifferent matters, making what O'Flaherty felt was rather a
pitiful, and yet a gallant attempt to speak of things which might
interest him.

Suddenly they touched on politics, "My father," Barbara's face


softened, became less mask-like, "cared so much about English
politics. As a young man he actually stood for Parliament, for in
those days Halnakeham had a member, but he was defeated. I have
sometimes thought, since I have heard Mr. Berwick and Mr.
Boringdon talk—I don't know if you have met Mr. Boringdon—how
different everything might have been if my poor father had been
elected. He only lost the seat by thirty votes."

When she mentioned Berwick, the colour had flooded her face,
and O'Flaherty had looked away. "Oh yes, I've met Oliver
Boringdon," he said quickly, and to give her time to recover herself
he went on, "I remember him in the House. But I had the luck to get
in again, and he was thrown out, at the last General Election. The
two friends are an interesting contrast. I regard James Berwick as
the typical Parliament man; not so Mr. Boringdon, who is much more
the permanent official, the plodding civil servant—that was what he
was originally, you know—and Berwick did him a bad turn in taking
him away from that career and putting him into Parliament."

"But you do think well of Mr. Berwick? I mean, do you consider, as


does his sister, that he has a great future before him?"

She looked at her companion in undisguised anxiety, and


O'Flaherty felt rather touched by the confidence Barbara evidently
reposed in his judgment.

"I think," he said—and he offered up a mental prayer that he


might so speak as to help, not hinder, the woman by his side—"that
James Berwick's future will depend on the way he shapes his life. Do
not think me priggish—but the one thing that seems to me sure is
that character still tells more than ability in English public life.
Character and ability together are apt to prove irresistible."

"But what," asked Barbara in a low voice, "do you exactly mean
by character?"

"I mean something which Oliver Boringdon possesses to a


supreme degree—a number of qualities which together make it
positively more difficult for a man to go wrong than to go right,
especially in any matter affecting his honour or probity."

"Then—surely you regard Mr. Berwick as a man of character?"

O'Flaherty hesitated. The conversation was taking a strange turn,


but he made up his mind to tell her the truth as far as he saw it. "I
think," he said deliberately, "that it is very difficult for a man of great
ability to be also a man of flawless character. He is probably tempted
in a thousand ways which pass the less gifted nature by; on the
other hand, his fate is much more in his own control. Berwick has
come very well out of ordeals partly brought about by his own desire
to succeed. Take his rather singular marriage."—the speaker looked
straight before him—"Of course I well remember that episode in his
life. Men marry every day for money, but Berwick conducted himself
with propriety and dignity under extremely trying circumstances."

"Did you ever see her?"—there was a painful catch in Barbara's


voice—"she was a friend, was she not, of Miss Berwick?"

"Hardly a friend—rather a worshipping acquaintance. No, I never


saw Mrs. James Berwick. She was rather an invalid both before and
after the marriage. I think she did a very wrong thing by her
husband—one that may even yet have evil consequences. You are
doubtless aware that in the event of Berwick's making a second
marriage he loses the immense fortune his wife left to him."

"That, then, was what Miss Berwick meant when she said he
could never marry." Barbara seemed to be speaking to herself, but
the words fell on O'Flaherty's ear with an unpleasing significance. His
mind made a sudden leap. Could Arabella be planning—oh! what a
horrible suspicion concerning the woman he had once loved! But it
came back again and again during the hour which followed. Had he
not himself thought Miss Berwick was doing all in her power to
throw her brother and Mrs. Rebell together?
He went on speaking, as if impelled to say what he really thought.
"Well, such a thing as that is enough to test a man's character. From
being a poor man, practically dependent on his uncle, Berwick
became the owner of almost unlimited money, to the possession of
which, however, was attached a clause which meant that in his case
none of the normal conditions of a man's life could be fulfilled—no
wife, no child, friendship with women perpetually open, as I know
Berwick's more than once has been, to misconstruction."

"And yet other men—?" Barbara looked at him deprecatingly, "You


yourself, Mr. O'Flaherty"—then she cried, "Forgive me! I have no
right to say that to you!"

"Nay," he said, "I give you for the moment every right to say, to
ask, what you like! I have no wife, no child, no home, Mrs. Rebell,
because the woman I loved rejected me; and also because, though I
have tried to like other women, I have failed. You see, it was not
that I had made a mistake, such as men make every day, for she
loved me too—that makes all the difference. She was in a different
position to my own; I was very poor, and there was the further bar
of my religion, even of my nationality"—he spoke with a certain
difficulty. "At the time she acted as she thought best for both our
sakes. But, whatever my personal experiences or motives for
remaining unmarried may be, I have no doubt,—no doubt at all,—as
to the general question. To my mind, James Berwick's friends must
regret that he has never, apparently, been tempted to make the
great sacrifice; and for my part, I hope the day will come when he
will meet with a woman for whom he will think his fortune well lost,
whom he will long to make his wife in a sense that the poor creature
he married never was, and in whom he will see the future mother of
his children." He paused, then added in a low voice, "In no other tie
can such a man as he find permanent solace and satisfaction. If
report speaks truly, he has more than once tried an alternative
experiment."

He dared not look at her. They walked on in absolute silence.


At last she spoke, "Please say nothing of our walk round by
Chancton Priory." And when, some hours later, there came a letter
from Doctor McKirdy declaring that Madame Sampiero was not well,
and longed for Mrs. Rebell's presence, Daniel O'Flaherty thought he
understood. A pang of miserable self-reproach struck his heart and
conscience. What right had he to have put this woman to the torture
—to take on himself the part of Providence?

After they had all seen Barbara off, after he had noted her very
quiet but determined rejection of Berwick's company on the way to
Chancton Priory, Daniel O'Flaherty was in no mood to go for the walk
to which Miss Berwick had been looking forward all that afternoon.
CHAPTER XVII.
"Look in my face: my name is Might-have-been,
And I am also called No-more, Too-late, Farewell."

Dante Gabriel Rossetti.

The days following Barbara's return to Chancton Priory went


slowly by, and she received no sign, no word from Berwick. She had
felt quite sure that he would come—if not that same evening of her
leaving Fletchings, then the next morning; if not in the morning,
then in the afternoon.

During those days she went through every phase of feeling. She
learnt the lesson most human beings learn at some time of their
lives—how to listen without appearing to do so for the sounds
denoting arrival, how to hunger for the sound of a voice which to the
listener brings happiness, however indifferently these same accents
fall on the ears of others. She schooled herself not to flinch when
the days went by bringing no successor to that letter in which
Berwick had promised her so much more than she had ever asked of
him.

Even in the midst of her restless self-questioning and


unhappiness, she was touched and pleased at the gladness with
which she had been welcomed home again by Madame Sampiero,
and even by Doctor McKirdy. It seemed strange that neither of them
spoke of the man who now so wholly occupied her thoughts; no
one, with the exception perhaps of his old nurse, noted Berwick's
absence, or seemed to find it untoward. Barbara had at first been
nervously afraid that Madame Sampiero would make some allusion
to the few moments they had spent together that Sunday morning,
that she would perhaps ask her what had induced her eager wish to
leave Fletchings; but no such word was said, and Barbara could not
even discover whether Doctor McKirdy was aware that her sudden
return to the Priory had been entirely voluntary.

And then, as the short winter days seemed to drag themselves


along, Mrs. Rebell, almost in spite of herself, again began to see a
great deal of Oliver Boringdon. There was something in his matter-
of-fact eagerness for her society which soothed her sore heart; her
manner to him became very gracious, more what it had been before
Berwick had come into her life; and again she found herself taking
the young man's part with Madame Sampiero and the old
Scotchman. Boringdon soon felt as happy as it was in his nature to
be. He told himself he had been a jealous fool, for Barbara spoke
very little of her visit to Fletchings, and not at all of Berwick; perhaps
she had seen him when there at a disadvantage.

As Oliver happened to know, Berwick had left Sussex; he was


now in London, and doubtless they would none of them see
anything of him till Easter. The young man took the trouble to go
down to the Grange and tell Mrs. Kemp that he had been mistaken
in that matter of which he had spoken to her. He begged her, rather
shamefacedly, to forget what he had said. Lucy's mother heard him
in silence, but she did not repeat her call on Mrs. Rebell. So it was
that during those days which were so full of dull wretchedness and
suspense to Barbara Rebell, Oliver Boringdon also went through a
mental crisis of his own, the upshot of which was that he wrote a
long and explicit letter to Andrew Johnstone.

They were both men to whom ambiguous situations were utterly


alien. Boringdon told himself that Johnstone might not understand,
or might understand and not approve, his personal reason for
interference; but Johnstone would certainly agree that Mrs. Rebell's
present position was intolerable from every point of view, and that
some effort should be made to set her legally free from such a man
as was this Pedro Rebell. Once Barbara was free,—Oliver thrust back
the leaping rapture of the thought—
After much deliberation he had added, as a postscript: "I have no
objection to your showing this letter to Grace."

Doctor McKirdy watched Mrs. Rebell very narrowly during these


same early December days, and as he did so he became full of
wrath against James Berwick. He and Madame Sampiero had few
secrets from one another. The old Scotchman had heard of Barbara's
sudden Sunday morning appearance at the Priory, and of her appeal
—was it for protection against herself? He made up his mind that
she and Berwick must have had, if not a quarrel, then one of those
encounters which leave deeper marks on the combatants than mere
quarrels are apt to do.

More than once the rough old fellow was strongly tempted to say
to her: "If you wish to make yourself ill, you are just going the way
to do it!" but Mrs. Rebell's determination to go on as usual, to allow
no one to divine the state of her mind, aroused his unwilling
admiration, nay more, his sympathy. He had known, so he told
himself, what it was to feel as Barbara felt now, but in his case
jealousy, an agony of jealousy, had been added to his other
torments, and shame too for the futility of it all.

Nine days after Barbara had left Fletchings she received a letter
from Berwick. It bore the London postmark, but was dated the
evening of the day they had parted,—of that day when she had
successfully eluded his desire, his determination, to see her alone.

A certain savagery of anger, hurt pride, over-mastering passion


breathed in the few lines of the short note which began abruptly, "I
have no wish to force my presence on you," and ended "Under the
circumstances perhaps it were better that we should not meet for a
while." Something had been added, and then erased; most women
would have tried to find out what that hasty scrawl concealed, but if
it hid some kinder sentiment the writer, before despatching his
missive, had repented, and to Barbara the fact that he did not wish
her to read what he had added was enough to prevent her trying to
do so.

With deep trouble and self-reproach she told herself that perhaps
she had been wrong in taking to flight—nay, more, that she had
surely owed Berwick an explanation. No wonder he was hurt and
angry! And he would never know, that was the pity of it, that it was
of herself she had been afraid—

Then those about her suddenly began to tell Mrs. Rebell that
which would have made such a difference before the arrival of
Berwick's letter. "I suppose you know that James Berwick is in
London? He was sent for suddenly," and Boringdon mentioned the
name of the statesman who had been Prime Minister when Berwick
held office.

"Has he been gone long?"—Barbara's voice sounded indifferent.

"Yes, he seems to have had a wire on a Sunday, on the day you


came back from Fletchings."

And Boringdon had never told her this all-important fact! Barbara
felt a sudden secret resentment against the young man. So it had
lain with him to spare her those days of utter wretchedness; of
perpetually waiting for one whom she believed to be in the near
neighbourhood; nay more, those moments of sick anxiety, for at
times she had feared that Berwick might be ill, physically unable to
leave Fletchings or Chillingworth. But this most unreasonable
resentment against Oliver she kept in her own heart.

The next to speak to her of Berwick had been Mrs. Turke. "So our
Mr. Berwick's in London? But he'll be back soon, for he hasn't taken
Dean with him. Sometimes months go by without our seeing the
dear lad, and then all in a minute he's here again. That's the way
with gentlemen; you never know when you have 'em!" And she had
given Barbara a quick, meaning look, as if the remark had a double
application.

Then came a day, the 8th of December, which Mrs. Rebell became
aware was not like other days. For the first time since she had been
at the Priory Madame Sampiero inquired as to the day of the month.
Doctor McKirdy was more odd, more abrupt even than usual, and
she saw him turn Boringdon unceremoniously from the door with the
snarling intimation that Madame Sampiero did not wish to-day to be
troubled with business matters. Mrs. Turke also was more
mysterious, less talkative than usual; she went about her own
quarters sighing and muttering to herself.

A sudden suspicion came into Barbara's heart; could it be that


James Berwick was coming back, that they expected him to-day, and
that none of them liked to tell her? If so, how wise of McKirdy to
have sent away Oliver Boringdon! But then cold reason declared that
if such was indeed the case, to make so great a mystery of the
matter would be an insult to her, surely the last thing that any of
them, with the exception perhaps of the old housekeeper, would
dare to do?

Still, when at last, late in the morning, she was sent for by Doctor
McKirdy, and informed curtly that someone was waiting for her in
the grass walk, she made no doubt of who it could be. In her
passion of relief, in her desire to bear herself well, to return, if it
might be possible, to the old ideal terms on which she and Berwick
had been before he had been seized with what she to herself now
characterised as a passing madness, Barbara hardly noticed how
moved, how unlike himself the old Scotchman seemed to be, and
how, again and again, he opened his lips as if to tell her something
which native prudence thrust back into his heart.
So great, so overwhelming was Barbara's disappointment when
she saw that the man leaning on the iron gate leading to the now
leafless rosery was Lord Bosworth, and not James Berwick, that she
had much ado to prevent herself from bursting into tears. But she
saw the massive figure before she herself was seen, and so was able
to make a determined effort to conceal both her bitter deception,
and also her great surprise at finding him there.

"As you are doubtless aware," Lord Bosworth began abruptly, "I
come here three or four times a year, and McKirdy is good enough to
arrange that on those occasions I can visit my child's grave without
fear of interruption. I ventured to ask that you might be told that I
wished to see you here, because I have a request to make you—"

He hesitated, and with eyes cast down began tracing with the
heavy stick he bore in his hand imaginary geometrical patterns on
the turf.

"If my daughter Julia had lived, she would have been seventeen
to-day, and so it seemed to me—perhaps I was wrong—to be a good
opportunity to make another effort to soften Barbara's heart." He
put his hand on Mrs. Rebell's shoulder, and smiled rather strangely
as he quickly added, "You understand? I mean my own poor
Barbara's heart, not that of this kind young Barbara, who I am
hoping will intercede for me, on whom I am counting to help me in
this matter. I do not know how far I should be justified in letting her
know what is undoubtedly the truth, namely, that I have not very
long to live. McKirdy absolutely refuses to tell her; but perhaps, if
she knew this fact, it would alter her feeling, and make her more
willing to consider the question of—of—our marriage."

And then, as Barbara started and looked at him attentively, he


went on slowly, and with a quiet dignity which moved his listener
deeply: "Of course you know our story? Sometimes I think there is
no one in the whole world who does not know it. There were years,
especially after the birth of our little Julia, when I think I may say we
both had marriage on the brain. And then, when at last Barbara was
free, when Napoleone Sampiero"—his face contracted when he
uttered the name—"was dead, she would not hear of it. She seemed
to think—perhaps at the time it was natural she should do so—that
the death of our poor child had been a judgment on us both. But
now, after all these years, I think she might do as I ask. I even think
—perhaps you might put that to her—that she owes me something.
No husband was ever more devoted to a wife than I have been to
her. Now, and Heaven knows how many years it is since we last met,
I think of her constantly. She is there!—there!" He struck his breast,
then went on more calmly: "My niece knows my wishes, there would
be no trouble with her; and as for my nephew, James Berwick, you
know how attached he has always been to Barbara. Why, I'm told
he's much more here now than he is at Chillingworth!"

He turned abruptly, and they walked slowly, side by side, down


the broad grass path till there came a spot where it became merged
in the road under the beeches. Here he stopped her.

"You are surely not going to walk back all the way alone!" she
cried, for she saw with emotion that he looked older even in the few
days which had elapsed since he had bade her good-bye at
Fletchings.

"No, the carriage is waiting for me down there. I only walked up


through the park. Then I have your promise to speak to Madame
Sampiero?" he held her hand, and looked down with peculiar
earnestness into her face. As she bent her head, he added, "You'll
let me have word when you can? Of course, if she's still of the same
mind, I'll not trouble her." He walked on, and then turned suddenly
back and grasped Barbara's hand once more. "Better not use the
health argument," he said, "doctors do make mistakes—an old friend
of mine married his cook on, as he thought, his death-bed, and then
got quite well again!" He smiled at her rather deprecatingly, "I know
my cause is in good hands," and she watched him walk with heavy,
deliberate steps down the leaf-strewn way.
For the first time Barbara drew the parallel those about her had
so often drawn. Was James Berwick capable of such constancy, of
such long devotion as his uncle had shown? Something whispered
yes; but even if so, how would that affect her, how would that make
her conduct less reprehensible, were she ever to fall short of what
had been her own mother's standard?

Before her interview with Lord Bosworth, it had seemed to


Barbara that she constantly spent long hours alone with her god-
mother; but, after that memorable eighth of December, she felt as if
those about Madame Sampiero had entered into a conspiracy to
prevent her being ever left alone with her god-mother for more than
a very few moments at a time. Doctor McKirdy suddenly decided to
have his house repapered, and he accordingly moved himself bodily
over to the Priory, where Barbara could not complain of his constant
presence in "Madam's" room, for he always found something to
amuse or interest his patient.

Twice he spoke to Barbara of Lord Bosworth, each time with


strange bitterness and dislike. "No doubt his lordship was after
seeing Madam?" and, as Barbara hesitated: "Fine I knew it!—but he
might just as well go and kill her outright. I've had to tell him so
again and again"—

Barbara kept her own counsel, but she could not resist the
question, "Then he comes often?"

"Often?—that he does not! He's never been one to put himself


out, he's far too high! He just sends for me over to Fletchings, and I
just go, though I've felt more than once minded to tell him that I'm
not his servant. Madam's determined that he shall never see her as
she is now, and who can blame her? Not I, certainly! Besides, he
hasn't a bit of right to insist on such a thing." And he looked fiercely
at Barbara as he spoke, as if daring her to contradict him.

"I think he has a right," she said in a low tone—then with more
courage, "Of course he has a right, Doctor McKirdy! I'm sure if my
god-mother could see Lord Bosworth, could hear him——" her voice
broke, and she bit her lip, sorry at having said so much.

But the interview with Madame Sampiero's old friend, and the
little encounters with Doctor McKirdy, did Barbara good. They forced
her to think of something else than of herself, of another man than
James Berwick; and at last she made up her mind that she would
tell her god-mother she wished to speak to her without this dread of
constant, futile interruption. At once her wish was granted, for the
paralysed mistress of the Priory could always ensure privacy when
she chose.

But, alas for Barbara, the result of the painful talk was not what
she had perhaps been vain enough to think herself capable of
achieving on behalf of Lord Bosworth: indeed, for a moment she had
been really frightened, on the point of calling Doctor McKirdy, so
terrible, so physically injurious had been Madame Sampiero's
agitation.

"I cannot see him! He must not see me in this state—he should
not ask it of me." Such, Mrs. Rebell had divined, were the words her
god-mother struggled over and over again to utter. "Marriage?"—a
lightning flash of horror, revolt, bitter sarcasm, had illumined for a
moment the paralysed woman's face. Then, softening, she had
added words signifying that she was not angry, that she forgave—
Barbara!

Very sadly, with a heart full of pain at the disappointment she


knew she was about to inflict, Mrs. Rebell wrote to Lord Bosworth.
She softened the refusal she had to convey by telling, with
tenderness and simplicity, how much the man to whom she was
writing seemed to be ever in her god-mother's thoughts, how often
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like