0% found this document useful (1 vote)
21 views

Nodejs The Comprehensive Guide To Serverside Javascript Programming Springer pdf download

The document provides information about the e-book 'Node.js: The Comprehensive Guide' by Sebastian Springer, detailing its content, structure, and contributors. It covers topics such as the history of Node.js, installation, application development, HTTP, Express, template engines, database connections, authentication, and REST servers. Additionally, it includes links to related Node.js resources and other recommended books on the subject.

Uploaded by

dejsisujadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
21 views

Nodejs The Comprehensive Guide To Serverside Javascript Programming Springer pdf download

The document provides information about the e-book 'Node.js: The Comprehensive Guide' by Sebastian Springer, detailing its content, structure, and contributors. It covers topics such as the history of Node.js, installation, application development, HTTP, Express, template engines, database connections, authentication, and REST servers. Additionally, it includes links to related Node.js resources and other recommended books on the subject.

Uploaded by

dejsisujadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 88

Nodejs The Comprehensive Guide To Serverside

Javascript Programming Springer download

https://ebookbell.com/product/nodejs-the-comprehensive-guide-to-
serverside-javascript-programming-springer-56848688

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Nodejs The Comprehensive Guide To Serverside Javascript Programming


Comprehensive Sebastian Springer

https://ebookbell.com/product/nodejs-the-comprehensive-guide-to-
serverside-javascript-programming-comprehensive-sebastian-
springer-46231558

Nodejs The Comprehensive Guide Springer Sebastian

https://ebookbell.com/product/nodejs-the-comprehensive-guide-springer-
sebastian-50742464

The Node Beginner Book A Comprehensive Nodejs Tutorial Manuel


Kiessling

https://ebookbell.com/product/the-node-beginner-book-a-comprehensive-
nodejs-tutorial-manuel-kiessling-4104638

Mastering Nodejs Web Development Go On A Comprehensive Journey From


The Fundamentals To Advanced Web Development With Nodejs Adam Freeman

https://ebookbell.com/product/mastering-nodejs-web-development-go-on-
a-comprehensive-journey-from-the-fundamentals-to-advanced-web-
development-with-nodejs-adam-freeman-58369470
Mastering Nodejs Web Development Go On A Comprehensive Journey From
The Fundamentals To Advanced Web Development With Nodejs 1st Edition
Adam Freeman

https://ebookbell.com/product/mastering-nodejs-web-development-go-on-
a-comprehensive-journey-from-the-fundamentals-to-advanced-web-
development-with-nodejs-1st-edition-adam-freeman-200671740

Nodejs The Right Way Practical Serverside Javascript That Scales 1st
Edition Jim R Wilson

https://ebookbell.com/product/nodejs-the-right-way-practical-
serverside-javascript-that-scales-1st-edition-jim-r-wilson-4946042

Nodejs The Collection James Hibbard Camilo Reyes Michael Wanyoike Mark
Brown Manjunath M Jay Raj Lukas White James Kolce Simon Holmes Paul
Orac Patrick Catanzariti Jani Hartikainen M David Green Craig Buckler
Olayinka Omole Ahmed Bouchefra Paul Sauve
https://ebookbell.com/product/nodejs-the-collection-james-hibbard-
camilo-reyes-michael-wanyoike-mark-brown-manjunath-m-jay-raj-lukas-
white-james-kolce-simon-holmes-paul-orac-patrick-catanzariti-jani-
hartikainen-m-david-green-craig-buckler-olayinka-omole-ahmed-
bouchefra-paul-sauve-11295854

Fullstack Nodejs The Complete Guide To Building Production Apps With


Nodejs Revision 2p 20191125 Davit Guttman Nate Murray Ed

https://ebookbell.com/product/fullstack-nodejs-the-complete-guide-to-
building-production-apps-with-nodejs-revision-2p-20191125-davit-
guttman-nate-murray-ed-11798290

Fullstack Nodejs The Complete Guide To Building Production Apps With


Nodejs Davit Guttman Nate Murray Ed

https://ebookbell.com/product/fullstack-nodejs-the-complete-guide-to-
building-production-apps-with-nodejs-davit-guttman-nate-murray-
ed-11380816
Sebastian Springer

Node.js
The Comprehensive Guide
Imprint

This e-book is a publication many contributed to, specifically:


Editor Megan Fuerst
Acquisitions Editor Hareem Shafi
German Edition Editor Patricia Schiewald
Translation Winema Language Services, Inc.
Copyeditor Julie McNamee
Cover Design Graham Geary
Photo Credit Shutterstock: 1940821471/© banjongseal956
Production E-Book Graham Geary
Typesetting E-Book III-satz, Germany
We hope that you liked this e-book. Please share your feedback with
us and read the Service Pages to find out how to contact us.

The Library of Congress has cataloged the printed edition as


follows:
Names: Springer, Sebastian, author.
Title: Node.js : the comprehensive guide / by Sebastian Springer.
Description: 1st edition. | Bonn ; Boston : Rheinwerk Publishing,
2022. |
Includes index.
Identifiers: LCCN 2022023980 | ISBN 9781493222926 (hardcover) |
ISBN
9781493222933 (ebook)
Subjects: LCSH: JavaScript (Computer program language) | Node.js.
|
Internet programming. | Web site development.
Classification: LCC QA76.73.J38 S74 2022 | DDC 005.13/3--
dc23/eng/20220724
LC record available at https://lccn.loc.gov/2022023980
ISBN 978-1-4932-2292-6 (print)
ISBN 978-1-4932-2293-3 (e-book)
ISBN 978-1-4932-2294-0 (print and e-book)

© 2022 by Rheinwerk Publishing Inc., Boston (MA)


1st edition 2022
4th German edition published 2021 by Rheinwerk Verlag, Bonn,
Germany
Dear Reader,

Fun fact about us: Rheinwerk Publishing has branches in both Bonn,
Germany, and Boston, Massachusetts. The benefit of this
international setup is that we can publish both German-language
books and English-language books—the challenge is translating
them.

When our colleagues at Rheinwerk Verlag in Bonn publish a book


that we would also like to provide to English-speaking readers, or
vice versa, the manuscript undergoes the translation process. This
means that either the author, or a third party, must translate every
sentence, diagram, and piece of code. However, receiving the
translated manuscript several months later isn’t the end of the story.
Both the author and the editor must review and fine-tune the
manuscript: the author ensures no errors have been introduced, and
the editor realigns any variations in our formatting standards. Then,
the copyeditor edits each chapter line-by-line to polish the grammar
and style in the book’s new language.

Node.js: The Comprehensive Guide is one of these translations,


brought to you from its fourth German edition. Ironically, the topic of
this book, Node.js, is the solution for this “translation” process in the
programming world. Node.js allows your client- and server-side
scripts to be written in a single language: JavaScript. In these pages,
you’ll find the instructions and practical examples you need to make
the most of the Node.js environment for unified web application
development.
What did you think about Node.js: The Comprehensive Guide? Your
comments and suggestions are the most useful tools to help us
make our books the best they can be. Please feel free to contact me
and share any praise or criticism you may have.

Thank you for purchasing a book from SAP PRESS!

Megan Fuerst
Editor, SAP PRESS
meganf@rheinwerk-publishing.com
www.rheinwerk-computing.com
Rheinwerk Publishing • Boston, MA
Notes on Usage

This e-book is protected by copyright. By purchasing this e-book,


you have agreed to accept and adhere to the copyrights. You are
entitled to use this e-book for personal purposes. You may print and
copy it, too, but also only for personal use. Sharing an electronic or
printed copy with others, however, is not permitted, neither as a
whole nor in parts. Of course, making them available on the internet
or in a company network is illegal as well.

For detailed and legally binding usage conditions, please refer to the
section Legal Notes.

This e-book copy contains a digital watermark, a signature that


indicates which person may use this copy:
Notes on the Screen Presentation

You are reading this e-book in a file format (EPUB or Mobi) that
makes the book content adaptable to the display options of your
reading device and to your personal needs. That’s a great thing; but
unfortunately not every device displays the content in the same way
and the rendering of features such as pictures and tables or
hyphenation can lead to difficulties. This e-book was optimized for
the presentation on as many common reading devices as possible.

If you want to zoom in on a figure (especially in iBooks on the iPad),


tap the respective figure once. By tapping once again, you return to
the previous screen. You can find more recommendations on the
customization of the screen layout on the Service Pages.
Table of Contents

Dear Reader
Notes on Usage
Table of Contents

Preface

1 Basic Principles

1.1 The Story of Node.js


1.1.1 Origins
1.1.2 Birth of Node.js
1.1.3 Breakthrough of Node.js
1.1.4 Node.js Conquers Windows
1.1.5 io.js: The Fork of Node.js
1.1.6 Node.js Reunited
1.1.7 Deno: A New Star in the JavaScript Sky
1.1.8 OpenJS Foundation
1.2 Organization of Node.js
1.2.1 Technical Steering Committee
1.2.2 Collaborators
1.2.3 Community Committee
1.2.4 Work Groups
1.2.5 OpenJS Foundation
1.3 Versioning of Node.js
1.3.1 Long-Term Support Releases
1.4 Benefits of Node.js
1.5 Areas of Use for Node.js
1.6 The Core: V8 Engine
1.6.1 Memory Model
1.6.2 Accessing Properties
1.6.3 Machine Code Generation
1.6.4 Garbage Collection
1.7 Libraries around the Engine
1.7.1 Event Loop
1.7.2 Input and Output
1.7.3 libuv
1.7.4 Domain Name System
1.7.5 Crypto
1.7.6 Zlib
1.7.7 HTTP Parser
1.8 Summary

2 Installation

2.1 Installing Packages


2.1.1 Linux
2.1.2 Windows
2.1.3 macOS
2.2 Compiling and Installing
2.3 Node Version Manager
2.4 Node and Docker
2.5 Summary

3 Developing Your First


Application

3.1 Interactive Mode


3.1.1 General Use
3.1.2 Other REPL Commands
3.1.3 Saving and Loading in the REPL
3.1.4 Context of the REPL
3.1.5 REPL History
3.1.6 REPL Mode
3.1.7 Searching in the REPL
3.1.8 Asynchronous Operations in the REPL
3.2 The First Application
3.2.1 Web Server in Node.js
3.2.2 Extending the Web Server
3.2.3 Creating an HTML Response
3.2.4 Generating Dynamic Responses
3.3 Debugging Node.js Applications
3.3.1 Navigating in the Debugger
3.3.2 Information in the Debugger
3.3.3 Breakpoints
3.3.4 Debugging with Chrome Developer Tools
3.3.5 Debugging in the Development Environment
3.4 nodemon Development Tool
3.5 Summary

4 Node.js Modules

4.1 Modular Structure


4.2 Core Modules
4.2.1 Stability
4.2.2 List of Core Modules
4.2.3 Loading Core Modules
4.2.4 Global Objects
4.3 JavaScript Module Systems
4.3.1 CommonJS
4.3.2 ECMAScript Modules
4.4 Creating and Using Your Own Modules
4.4.1 Modules in Node.js: CommonJS
4.4.2 Custom Node.js Modules
4.4.3 Modules in Node.js: ECMAScript
4.4.4 Exporting Different Types of Data
4.4.5 The modules Module
4.4.6 Module Loader
4.5 Summary

5 HTTP

5.1 Web Server


5.1.1 Server Object
5.1.2 Server Events
5.1.3 Request Object
5.1.4 Handling the Request Body (Update)
5.1.5 Delivering Static Content
5.1.6 File Upload
5.1.7 Fine-Tuning the Frontend
5.2 Node.js as HTTP Client
5.2.1 Requests with the http Module
5.2.2 The request Package
5.2.3 HTML Parser
5.3 Secure Communication with HTTPS
5.3.1 Creating Certificates
5.3.2 Using HTTPS in the Web Server
5.4 HTTP/2
5.4.1 HTTP/2 Server
5.4.2 HTTP/2 Client
5.5 Summary

6 Express
6.1 Structure
6.2 Installation
6.3 Basic Principles
6.3.1 Request
6.3.2 Response
6.4 Setup
6.4.1 Structure of an Application
6.5 Movie Database
6.5.1 Routing
6.5.2 Controller
6.5.3 Model
6.5.4 View
6.6 Middleware
6.6.1 Custom Middleware
6.6.2 Morgan: Logging Middleware for Express
6.6.3 Delivering Static Content
6.7 Extended Routing: Deleting Data Records
6.8 Creating and Editing Data Records: Body
Parser
6.8.1 Handling Form Input: Body Parser
6.9 Express 5
6.10 HTTPS and HTTP/2
6.10.1 HTTPS
6.10.2 HTTP/2
6.11 Summary
7 Template Engines

7.1 Custom Template Engine


7.2 Template Engines in Practice: Pug
7.2.1 Installation
7.2.2 Pug and Express: Integration
7.2.3 Variables in Pug
7.2.4 Specific Features of Pug
7.2.5 Conditions and Loops
7.2.6 Extends and Includes
7.2.7 Mixins
7.2.8 Using Pug without Express
7.2.9 Compiling
7.3 Handlebars
7.3.1 Installation
7.3.2 Integration with Express
7.3.3 Conditions and Loops
7.3.4 Partials
7.3.5 Custom Helpers
7.3.6 Handlebars without Express
7.4 Summary

8 Connecting Databases
8.1 Node.js and Relational Databases
8.1.1 MySQL
8.1.2 SQLite
8.1.3 Object-Relational Mapping
8.2 Node.js and Nonrelational Databases
8.2.1 Redis
8.2.2 MongoDB
8.3 Summary

9 Authentication and Session


Handling

9.1 Passport
9.2 Setup and Configuration
9.2.1 Installation
9.2.2 Configuration
9.2.3 Strategy Configuration
9.3 Logging In to the Application
9.3.1 Login Form
9.3.2 Securing Resources
9.3.3 Logging Out
9.3.4 Connecting to the Database
9.4 Accessing Resources
9.4.1 Access Restriction
9.4.2 Submitting Ratings
9.5 Summary

10 REST Server

10.1 Introduction to REST and Usage in Web


Applications
10.2 Accessing the Application
10.2.1 Postman
10.2.2 cURL
10.3 Adaptations to the Application Structure
10.4 Read Requests
10.4.1 Reading All Data Records of a Resource
10.4.2 Accessing a Data Record
10.4.3 Error Handling
10.4.4 Sorting the List
10.4.5 Controlling the Output Format
10.5 Write Requests
10.5.1 POST: Creating New Data Records
10.5.2 PUT: Modifying Existing Data Records
10.5.3 DELETE: Deleting Data Records
10.6 Authentication via JWTs
10.6.1 Login
10.6.2 Safeguarding Resources
10.6.3 Accessing User Information in the Token
10.7 OpenAPI Specification: Documentation
with Swagger
10.8 Validation
10.8.1 Installation and First Validation
10.8.2 Checking Requests with a Validation Schema
10.9 Summary

11 GraphQL

11.1 GraphQL Libraries


11.2 Integration with Express
11.3 GraphiQL
11.4 Reading Data via the Interface
11.4.1 Parameterizing Queries
11.5 Write Accesses to the GraphQL Interface
11.5.1 Creating New Data Records
11.5.2 Updating and Deleting Data Records
11.6 Authentication for the GraphQL Interface
11.7 Summary

12 Real-Time Web Applications

12.1 The Sample Application


12.2 Setup
12.3 WebSockets
12.3.1 The Server Side
12.3.2 The Client Side
12.3.3 User List
12.3.4 Logout
12.4 Socket.IO
12.4.1 Installation and Integration
12.4.2 Socket.IO API
12.5 Summary

13 Type-Safe Applications in
Node.js

13.1 Type Systems for Node.js


13.1.1 Flow
13.1.2 TypeScript
13.2 Tools and Configuration
13.2.1 Configuring the TypeScript Compiler
13.2.2 Integration into the Development Environment
13.2.3 ESLint
13.2.4 ts-node
13.3 Basic Principles
13.3.1 Data Types
13.3.2 Functions
13.3.3 Modules
13.4 Classes
13.4.1 Methods
13.4.2 Access Modifiers
13.4.3 Inheritance
13.5 Interfaces
13.6 Type Aliases in TypeScript
13.7 Generics
13.8 TypeScript in Use in a Node.js Application
13.8.1 Type Definitions
13.8.2 Creating Custom Type Definitions
13.8.3 Sample Express Application
13.9 Summary

14 Web Applications with Nest

14.1 Installation and Getting Started with Nest


14.2 Nest Command-Line Interface
14.2.1 Commands for Operating and Running the
Application
14.2.2 Creating Structures in the Application
14.3 Structure of the Application
14.3.1 Root Directory with the Configuration Files
14.3.2 src Directory: Core of the Application
14.3.3 Other Directories of the Application
14.4 Modules: Logical Units in the Source
Code
14.4.1 Creating Modules
14.4.2 Module Decorator
14.5 Controllers: Endpoints of an Application
14.5.1 Creating a Controller
14.5.2 Implementing a Controller
14.5.3 Integrating and Checking the Controller
14.6 Providers: Business Logic of the
Application
14.6.1 Creating and Including a Service
14.6.2 Implementing the Service
14.6.3 Integrating the Service via Nest’s Dependency
Injection
14.7 Accessing Databases
14.7.1 Setup and Installation
14.7.2 Accessing the Database
14.8 Documenting the Endpoints with OpenAPI
14.9 Authentication
14.9.1 Setup
14.9.2 Authentication Service
14.9.3 Login Controller: Endpoint for User Login
14.9.4 Protecting Routes
14.10 Outlook: Testing in Nest
14.11 Summary

15 Node on the Command Line


15.1 Basic Principles
15.1.1 Structure
15.1.2 Executability
15.2 Structure of a Command-Line Application
15.2.1 File and Directory Structure
15.2.2 Package Definition
15.2.3 Math Trainer Application
15.3 Accessing Input and Output
15.3.1 Output
15.3.2 Input
15.3.3 User Interaction with the readline Module
15.3.4 Options and Arguments
15.4 Tools
15.4.1 Commander
15.4.2 Chalk
15.4.3 node-emoji
15.5 Signals
15.6 Exit Codes
15.7 Summary

16 Asynchronous Programming

16.1 Basic Principles of Asynchronous


Programming
16.1.1 The child_process Module
16.2 Running External Commands
Asynchronously
16.2.1 The exec Method
16.2.2 The spawn Method
16.3 Creating Node.js Child Processes with
fork Method
16.4 The cluster Module
16.4.1 Main Process
16.4.2 Worker Processes
16.5 Worker Threads
16.5.1 Shared Memory in the worker_threads Module
16.6 Promises in Node.js
16.6.1 Using util.promisify to Use Promises Where None
Actually Exist
16.6.2 Concatenating Promises
16.6.3 Multiple Parallel Operations with Promise.all
16.6.4 Fastest Asynchronous Operation with
Promise.race
16.6.5 Overview of the Promise Functions
16.7 Async Functions
16.7.1 Top-Level Await
16.8 Summary

17 RxJS
17.1 Basic Principles
17.1.1 Installation and Integration
17.1.2 Observable
17.1.3 Observer
17.1.4 Operator
17.1.5 Example of RxJS in Node.js
17.2 Operators
17.2.1 Creation Operators
17.2.2 Transformation Operators
17.2.3 Filtering Operators
17.2.4 Join Operators
17.2.5 Error Handling Operators
17.2.6 Utility Operators
17.2.7 Conditional Operators
17.2.8 Connection Operators
17.2.9 Conversion Operators
17.3 Subjects
17.4 Schedulers
17.5 Summary

18 Streams

18.1 Introduction
18.1.1 What Is a Stream?
18.1.2 Stream Usages
18.1.3 Available Streams
18.1.4 Stream Versions in Node.js
18.1.5 Streams Are EventEmitters
18.2 Readable Streams
18.2.1 Creating a Readable Stream
18.2.2 Readable Stream Interface
18.2.3 Events of a Readable Stream
18.2.4 Error Handling in Readable Streams
18.2.5 Methods
18.2.6 Piping
18.2.7 Readable Stream Modes
18.2.8 Switching to Flowing Mode
18.2.9 Switching to the Paused Mode
18.2.10 Custom Readable Streams
18.2.11 Example of a Readable Stream
18.2.12 Readable Shortcut
18.3 Writable Streams
18.3.1 Creating a Writable Stream
18.3.2 Events
18.3.3 Error Handling in Writable Streams
18.3.4 Methods
18.3.5 Buffering Write Operations
18.3.6 Flow Control
18.3.7 Custom Writable Streams
18.3.8 Writable Shortcut
18.4 Duplex Streams
18.4.1 Duplex Streams in Use
18.4.2 Custom Duplex Streams
18.4.3 Duplex Shortcut
18.5 Transform Streams
18.5.1 Custom Transform Streams
18.5.2 Transform Shortcut
18.6 Gulp
18.6.1 Installation
18.6.2 Example of a Build Process with Gulp
18.7 Summary

19 Working with Files

19.1 Synchronous and Asynchronous


Functions
19.2 Existence of Files
19.3 Reading Files
19.3.1 Promise-Based API
19.4 Error Handling
19.5 Writing to Files
19.6 Directory Operations
19.7 Advanced Operations
19.7.1 The watch Method
19.7.2 Access Permissions
19.8 Summary

20 Socket Server
20.1 Unix Sockets
20.1.1 Accessing the Socket
20.1.2 Bidirectional Communication
20.2 Windows Pipes
20.3 TCP Sockets
20.3.1 Data Transfer
20.3.2 File Transfer
20.3.3 Flow Control
20.3.4 Duplex
20.3.5 Pipe
20.4 UDP Sockets
20.4.1 Basic Principles of a UDP Server
20.4.2 Example Illustrating the UDP Server
20.5 Summary

21 Package Manager

21.1 Most Common Operations


21.1.1 Searching Packages
21.1.2 Installing Packages
21.1.3 Viewing Installed Packages
21.1.4 Using Packages
21.1.5 Updating Packages
21.1.6 Removing Packages
21.1.7 Overview of the Most Important Commands
21.2 Advanced Operations
21.2.1 Structure of a Module
21.2.2 Creating Custom Packages
21.2.3 Node Package Manager Scripts
21.3 Tools for Node Package Manager
21.3.1 Node License Finder
21.3.2 Verdaccio
21.3.3 npm-check-updates
21.3.4 npx
21.4 Yarn
21.5 Summary

22 Quality Assurance

22.1 Style Guides


22.1.1 Airbnb Style Guide
22.2 Linter
22.2.1 ESLint
22.3 Prettier
22.3.1 Installation
22.3.2 Execution
22.4 Programming Mistake Detector:
Copy/Paste Detector
22.4.1 Installation
22.4.2 Execution
22.5 Husky
22.6 Summary

23 Testing

23.1 Unit Testing


23.1.1 Directory Structure
23.1.2 Unit Tests and Node.js
23.1.3 Arrange, Act, Assert
23.2 Assertion Testing
23.2.1 Exceptions
23.2.2 Testing Promises
23.3 Jasmine
23.3.1 Installation
23.3.2 Configuration
23.3.3 Tests in Jasmine
23.3.4 Assertions
23.3.5 Spies
23.3.6 beforeEach and afterEach
23.4 Jest
23.4.1 Installation
23.4.2 First Test
23.5 Practical Example of Unit Tests with Jest
23.5.1 The Test
23.5.2 Implementation
23.5.3 Triangulation: Second Test
23.5.4 Optimizing the Implementation
23.6 Dealing with Dependencies: Mocking
23.7 Summary

24 Security

24.1 Filter Input and Escape Output


24.1.1 Filter Input
24.1.2 Blacklisting and Whitelisting
24.1.3 Escape Output
24.2 Protecting the Server
24.2.1 User Permissions
24.2.2 Problems Caused by the Single-Threaded
Approach
24.2.3 Denial-of-Service Attacks
24.2.4 Regular Expressions
24.2.5 HTTP Header
24.2.6 Error Messages
24.2.7 SQL Injections
24.2.8 eval
24.2.9 Method Invocation
24.2.10 Overwriting Built-Ins
24.3 Node Package Manager Security
24.3.1 Permissions
24.3.2 Node Security Platform
24.3.3 Quality Aspect
24.3.4 Node Package Manager Scripts
24.4 Client Protection
24.4.1 Cross-Site Scripting
24.4.2 Cross-Site Request Forgery
24.5 Summary

25 Scalability and Deployment

25.1 Deployment
25.1.1 Simple Deployment
25.1.2 File Synchronization via rsync
25.1.3 Application as a Service
25.1.4 node_modules in Deployment
25.1.5 Installing Applications Using Node Package
Manager
25.1.6 Installing Packages Locally
25.2 Tool Support
25.2.1 Grunt
25.2.2 Gulp
25.2.3 Node Package Manager
25.3 Scaling
25.3.1 Child Processes
25.3.2 Load Balancer
25.3.3 Node in the Cloud
25.4 pm2: Process Management
25.5 Docker
25.5.1 Dockerfile
25.5.2 Starting the Container
25.6 Summary

26 Performance

26.1 You Aren’t Gonna Need It


26.2 CPU
26.2.1 CPU-Blocking Operations
26.2.2 Measuring the CPU Load
26.2.3 CPU Profiling with Chrome DevTools
26.2.4 Alternatives to the Profiler: console.time
26.2.5 Alternatives to the Profiler: Performance-Hooks
Interface
26.3 Memory
26.3.1 Memory Leaks
26.3.2 Memory Analysis in DevTools
26.3.3 Node.js Memory Statistics
26.4 Network
26.5 Summary

27 Microservices with Node.js

27.1 Basic Principles


27.1.1 Monolithic Architecture
27.1.2 Microservice Architecture
27.2 Architecture
27.2.1 Communication between Individual Services
27.3 Infrastructure
27.3.1 Docker Compose
27.4 Asynchronous Microservice with
RabbitMQ
27.4.1 Installation and Setup
27.4.2 Connecting to the RabbitMQ Server
27.4.3 Handling Incoming Messages
27.4.4 Database Connection
27.4.5 Docker Setup
27.5 API Gateway
27.5.1 Connecting the User Service
27.5.2 Asynchronous Communication with the User
Service
27.5.3 Docker Setup of the API Gateway
27.5.4 Authentication
27.6 Synchronous Microservice with Express
27.6.1 Setup
27.6.2 Controller
27.6.3 Model Implementation
27.6.4 Docker Setup
27.6.5 Integration into the API Gateway
27.7 Summary

28 Deno
28.1 The Ten Things Ryan Dahl Regrets about
Node.js
28.1.1 Promises
28.1.2 Security
28.1.3 The Generate Your Projects Build System
28.1.4 Package.json
28.1.5 Node_modules
28.1.6 Optional File Extension When Loading Modules
28.1.7 Index.js
28.1.8 What’s Going on Now with Node.js
28.2 Installing Deno
28.2.1 Deno Command-Line Interface
28.3 Execution
28.3.1 Running a TypeScript Application
28.4 Handling Files
28.4.1 The Task: Copying a File
28.4.2 Processing Command-Line Options
28.4.3 Reading Files
28.4.4 Permissions in Deno
28.4.5 readTextFile Function
28.4.6 Writing Files with Deno
28.5 Web Server with Deno
28.6 Module System
28.6.1 Loading External Modules into Deno
28.6.2 deno.land/x
28.6.3 Using Node Package Manager Packages
28.7 Summary
The Author
Index
Service Pages
Legal Notes
Preface

Node.js has been with me for many years now as a server-side


development platform and also in the form of this book, which is now
in its fourth edition in German and debuting with this first edition in
English. Over time, the JavaScript world, and also Node.js itself, has
changed a lot. Node.js has now grown up and is part of the
mainstream. In contrast to the early days, when you had to convince
funders, decision makers, and coworkers to use Node.js, it has
become much easier now. In some cases, Node.js is already used
as the base platform in projects. One aspect that has contributed
decisively to this success story is the flexibility of the platform. You
can use Node.js in small command-line tools, for building rapid
prototypes, and also for large-scale server applications in an
enterprise context. This book is intended to accompany you on your
journey into the world of Node.js, to help you get started developing
applications based on Node.js, and to serve as a reference in your
daily work.

In this book, you'll learn the basics of Node.js, learn more about how
the platform is built, and work with the various interfaces that Node.js
makes available to you.

Note that to work with this book, you should have a solid basic
knowledge of JavaScript. While I do cover some language features
throughout this book, such as destructuring, promises, and the
module system, the focus is on Node.js, and so you should take a
look at the Mozilla Developer Network
(https://developer.mozilla.org/de/), which comprehensively explains
all aspects of JavaScript. I would also like to take this opportunity to
recommend Philip Ackermann’s JavaScript: The Comprehensive
Guide (SAP PRESS, 2022, www.rheinwerk-computing.com/5554).

Server-side JavaScript with Node.js differs in some aspects from


developing client-side applications with HTML, CSS, and JavaScript,
so you usually don’t have direct visual feedback like you are used to
in the browser. The architecture and design patterns you use on the
server side also differ to some extent from those on the client side.
Other patterns and paradigms are the same on both sides. Thus,
Node.js is event-driven in many places, similar to the browser. This
means that you have a lot to do with asynchronous operations
because your application in Node.js usually runs in a single process,
and performance bottlenecks can easily occur here if different
operations block each other.

Node.js uses the same JavaScript engine as the Chrome browser:


the V8 engine. Since the Node.js development team always keeps
the engine up to date, you can develop modern JavaScript with
Node.js and also have access to the latest language features. In
addition to the engine, Node.js provides you with an extensive
collection of core modules that you can use to solve your problems
relatively close to the system level. However, you’ll usually use
external packages because, for most problems, there are already
established solutions that you only need to adapt for your
application. The module system of Node.js takes a prominent
position here. A lot has happened in this area in recent years, and
the platform has taken a big step forward in adapting the
ECMAScript module system. Throughout this book, you’ll learn more
about the different layers of the module system and how you can use
it to build your application.
As already mentioned, Node.js has been with me for a few years
now in my development work. I started with web development under
PHP, and like most web developers, I couldn’t escape the influence
of JavaScript. In addition to the aspect of implementing application
logic in the frontend, I’ve also been primarily concerned with quality
assurance in the area of JavaScript. The Node.js platform, along
with the possibility to use JavaScript on the server as well, piqued
my interest quite early. Like so many other developers, I was faced
with the question: Can Node.js already be used productively in
applications? I approached the answer to this question step by step
in the past. Initially, the focus was on implementations of various
sample applications in Node.js and testing out the toolset available
for Node.js. Tooling requirements for Node.js range from the
availability of a development environment to tools such as
debuggers and platforms for continuous integration. In the first
project, I used Node.js in combination with other programming
languages. Node.js took care of the real-time communication in this
case. After it had been shown over a longer period of time that
Node.js can be used stably in such an environment, nothing stood in
the way of its further use in other projects as well, so now I use
Node.js on quite a few projects.

Nearly all examples in this book use the ECMAScript module


system, which significantly modernizes the source code as a whole.
Due to the new features of JavaScript, but also of Node.js, the
source code has become more compact and also more readable
than in the past. However, don’t be put off by the new features and
the multitude of packages. When working with JavaScript, it’s
important to learn about patterns and architectures so that you can
evaluate new paradigms and packages and then deploy them with a
manageable learning curve. Many of the patterns and best practices
you’re currently working with have been in place in a similar form
since the earliest versions of Node.js. When working with Node.js,
understanding the core of the platform is essential, and you acquire
this best by experimenting with the platform. I invite you to follow the
examples in the course of this book, to extend them, and to try out
different tactics. In this book, you’ll find both extensive connected
examples, such as in Chapter 6 through Chapter 10, in which you
implement a web application based on Express, and small, self-
contained examples, such as in Chapter 17 on RxJS.

Structure of the Book


This book is roughly divided into four sections with thematically-
related chapters.

The first part of the book covers the basics of Node.js and the
general structuring of applications based on Node.js. Here we take a
look at the development history of the platform and the installation.
You’ll also receive a practical introduction to the module system.

Node.js is primarily a platform for web development, which the


second part of this book is devoted to covering. Here you’ll learn how
to implement a secure web server and also how to program
extensive web applications with numerous components and
modules. Numerous frameworks such as Express or libraries and
template engines such as Pug offer assistance. The connection of
various databases should also not be missing at this point. Here,
with Node.js, you have a flexible and versatile platform as the basis
for your application. The strength of a Node.js application is the
combination of many small specialized individual parts. You’ll learn
different aspects of web development, including implementation with
Node.js using practical examples and developing different types of
web applications. You’ll also learn about GraphQL, an alternative to
the widely used REST interfaces. With Nest, you'll explore another
framework for web backends that puts even more emphasis on
structure and architecture than Express does.

JavaScript and asynchronicity go hand in hand. The third part of the


book deals with different approaches to asynchronous programming.
You’ll learn both how to handle promises and child processes and
how to use data streams in development. In this context, you won’t
be limited to your local system but can also communicate between
different systems via TCP and UDP.

The last part of the book deals with problems beyond pure
programming and is intended to give you important tips for dealing
with Node.js in everyday life as a developer. This concerns topics
that take place directly in the course of development, such as
dealing with Node Package Manager (npm) as a package manager
and handling quality assurance of applications by implementing
tests, and also code analysis and debugging. Another very important
topic is application security. In a separate chapter, you’ll learn more
about attack possibilities and how you can counter them to protect
yourself and the users of your application. The following chapters are
dedicated to the deployment and scalability of Node.js applications,
in which you’ll learn more about the performance of applications as
well as the use of Node.js in a microservice architecture. The last
chapter introduces you to Deno, the biggest competitor with Node.js.
In that chapter, you’ll also learn why it’s still worth your while to get
involved with Node.js, despite the competition.

Downloading the Code Samples


All code samples used in this book are available for download from
the website at www.rheinwerk-computing.com/5556.
If you have any problems with the implementation or if I’ve
overlooked an error despite careful checking, please feel free to
contact me at node@sebastian-springer.com.

Acknowledgments
Finally, I would like to thank all the people involved in this book,
especially Philip Ackermann, who contributed many valuable
comments and tips.

I would also like to thank Sibylle Feldmann for proofreading and fine-
tuning the language of my book.

A big thank you also goes to the entire team at Rheinwerk Verlag,
especially Patricia Schiewald.

Finally, I would like to express my heartfelt thanks to my wife


Alexandra and my daughter Emma for their patience and support.

Sebastian Springer
Aßling, Germany
1 Basic Principles

All beginnings are difficult.


–Ovid

Bringing more dynamics into web pages was the original idea behind
JavaScript. The scripting language was intended to compensate for
the weaknesses of HTML when it came to responding to user input.
The history of JavaScript dates back to 1995 when it was developed
under the code name Mocha by Brendan Eich, a developer at
Netscape. One of the most remarkable facts about JavaScript is that
the first prototype of this successful and globally used language was
developed in just 10 days. Still in the year of its creation, Mocha was
renamed to LiveScript and finally to JavaScript in a cooperation
between Netscape and Sun. This was mainly for marketing
purposes, as at that time it was assumed that Java would become
the leading language in client-side web development.

Figure 1.1 Support for JavaScript Features in Node.js (http://node.green)

Convinced by the success of JavaScript, Microsoft also integrated a


scripting language into Internet Explorer 3 in 1996. This was the birth
of JScript, which was mostly compatible with JavaScript, but with
additional features added.
Today, the mutual vying of the two companies is known as the
“browser wars.” The development ensured that the two JavaScript
engines steadily improved in both feature set and performance,
which is the primary reason for JavaScript’s success today.

In 1997, the first draft of the language standard was created at Ecma
International. The entire language core of the script language is
recorded under the cryptic designation ECMA-262 or ISO/IEC
16262. The current standard can be found at www.ecma-
international.org/publications/standards/Ecma-262.htm. Due to this
standardization, vendor-independent JavaScript is also referred to as
ECMAScript. Until a few years ago, the ECMAScript standard was
versioned in integers starting at 1. Since version 6, the versions are
also provided with year numbers. ECMAScript in version 8 is
therefore referred to as ECMAScript 2017. As a rule, you can
assume that the manufacturers support the older versions of the
standard quite well. You must either enable newer features by
configuration flags in the browser or simulate them via polyfills (that
is, recreating the features in JavaScript). A good overview of the
currently supported features is provided by kangax’s compatibility
table, which can be found at http://kangax.github.io/compat-
table/es6/. A version adapted for Node.js can be reached at
http://node.green/.

Figure 1.2 Top Languages in GitHub Based on Pull Requests (octoverse.github.com)

JavaScript is lightweight, is relatively easy to learn, and has a huge


ecosystem of frameworks and libraries. For these reasons,
JavaScript is one of the most successful programming languages in
the world. This success can be backed up by numbers: Since 2008,
JavaScript has been in the top two spots in GitHub’s language
trends. In 2021, JavaScript was passed by Python in the number one
spot and is now in second place in language trends.
Node.js is based on this successful scripting language and has had
a meteoric rise itself. This chapter will serve as an introduction to the
world of Node.js, showing you how the platform is built, and where
and how you can use Node.js.

1.1 The Story of Node.js


To help you better understand what Node.js is and how some of the
development decisions came about, let's explore the history of the
platform.

1.1.1 Origins
Node.js was originally developed by Ryan Dahl, a PhD student in
mathematics who thought better of it, abandoned his efforts, and
instead preferred to travel to South America with a one-way ticket
and very little money in his pocket. There, he kept his head above
water by teaching English. During this time, he got in touch with PHP
as well as Ruby and discovered his affection for web development.
The problem with working with the Ruby framework, called Rails,
was that it couldn’t deal with concurrent requests without any
workaround. The applications were too slow and utilized the CPU
entirely. Dahl found a solution to his problems with Mongrel, a web
server for applications based on Ruby.

Unlike traditional web servers, Mongrel responds to user requests


and generates responses dynamically, where otherwise only static
HTML pages are delivered.

The task that actually led to the creation of Node.js is quite trivial
from today’s point of view. In 2005, Dahl was looking for an elegant
way to implement a progress bar for file uploads. However, the
technologies available at the time only allowed unsatisfactory
solutions. Regarding file transfers, HTTP was used for relatively
small files, and File Transfer Protocol (FTP) was used for larger files.
The status of the upload was queried using long polling, which is a
technique where the client sends long-lived requests to the server,
and the server uses the open channel for replies. Dahl’s first attempt
to implement a progress bar took place in Mongrel. After sending the
file to the server, it checked the status of the upload using a large
number of Asynchronous JavaScript and XML (AJAX) requests and
displayed it graphically in a progress bar. However, the downside of
this implementation was Ruby’s single-threaded approach and the
large number of requests that were required.

Another promising approach involved an implementation in C. Here,


Dahl’s options weren’t limited to one thread. However, C as a
programming language for the web has a decisive disadvantage:
only a small number of developers are enthusiastic about this field of
application. Dahl was also confronted with this problem and
discarded this approach after a short time.

The search for a suitable programming language to solve his


problem continued and led him to functional programming languages
such as Haskell. Haskell’s approach is built on nonblocking
input/output (I/O), which means that all read and write operations are
asynchronous and don’t block the execution of a program. This
allows the language to remain single-threaded at its core and doesn’t
introduce the problems that arise from parallel programming. Among
other things, no resources have to be synchronized, and no
problems are caused by the runtime of parallel threads. However,
Dahl still wasn’t fully satisfied with this solution and was looking for
other options.
1.1.2 Birth of Node.js
Dahl then found the solution he was finally satisfied with—
JavaScript. He realized that this scripting language could meet all his
requirements. JavaScript had already been established on the web
for years, so there were powerful engines and a large number of
developers. In January 2009, he began working on his
implementation for server-side JavaScript, which can be regarded as
the birth of Node.js. Another reason for implementing the solution in
JavaScript, according to Dahl, was the fact that the developers of
JavaScript didn’t envision this area of use. At that time, no native
web server existed in JavaScript, it couldn’t handle files in a file
system, and there was no implementation of sockets to
communicate with other applications or systems. All these points
spoke in favor of JavaScript as the basis for a platform for interactive
web applications because no determinations had yet been made in
this area, and, consequently, no mistakes had yet been made either.
The architecture of JavaScript also argued for such an
implementation. The approach of top-level functions (i.e., functions
that aren’t linked to any object, are freely available, and can be
assigned to variables) offers a high degree of flexibility in
development and enables functional approaches to solutions.

Thus, Dahl selected other libraries in addition to the JavaScript


engine, which is responsible for interpreting the JavaScript source
code, and put them together in one platform.

In September 2009, Isaac Schlueter started working on a package


manager for Node.js, the Node Package Manager (npm).
1.1.3 Breakthrough of Node.js
After Dahl integrated all the components and created the first
executable examples on the new Node.js platform, he needed a way
to introduce Node.js to the public. This also became necessary
because his financial resources shrank considerably due to the
development of Node.js, and he would have had to stop working on
Node.js if he didn’t find any sponsors. He chose the JavaScript
conference JSConf EU in November 2009 in Berlin as his
presentation platform. Dahl put all his eggs in one basket. If the
presentation was a success and he found sponsors to support his
work on Node.js, he could continue his involvement; if not, almost a
year’s work would have been in vain. In a rousing talk, he introduced
Node.js to the audience and showed how to create a fully functional
web server with just a few lines of JavaScript code. As another
example, he introduced an implementation of an Internet Relay Chat
(IRC) chat server. The source code for this demonstration comprised
about 400 lines. Using this example, he demonstrated the
architecture and thus the strengths of Node.js while making it
tangible for the audience. The recording of this presentation can be
found at www.youtube.com/watch?v=EeYvFl7li9E. The presentation
didn’t miss its mark and led to Joyent stepping in as a sponsor for
Node.js. Joyent is a San Francisco-based software and services
provider offering hosting solutions and cloud infrastructure. With its
commitment, Joyent included the open-source software Node.js in its
product portfolio and made Node.js available to its customers as part
of its hosting offerings. Dahl was hired by Joyent and became a full-
time maintainer for Node.js from that point on.
Random documents with unrelated
content Scribd suggests to you:
which He shall speak unto His people, and to His saints, that they
turn not again.
“Secondly, He chose that His side should be opened, because to
the Redeemer it was not enough that His whole body was bloody
with the rods, that His hands and feet were purpled by the nails, but
He desired to shed forth, by the spear, as token of His unbounded
love, that blood which still lingered about the heart, and which
neither thorns nor scourge had extracted. Wherefore He was
wounded, not so much by the spear, as by love, or if you prefer it,
by both the lance and love. Whence it is said twice, Thou hast
wounded My heart, My sister, My spouse; thou hast wounded My
heart! And do thou reply, ‘Wound Thou my heart, my Bridegroom;
wound Thou my heart! wound it with compassion, wound it with
love; with these twin arrows from Thy bow pierce through my heart.
Twice did Moses smite the rock, twice do Thou smite this stony
heart, that from it may stream, if not blood, yet bitter tears.’
“Thirdly, He chose to show us the place of our regeneration.
Hence there flowed forth both water and blood, signs of Baptism
and the Eucharist, which regenerate us to God. And thus is it said,
Thy daughters shall be nursed at Thy side (Isa. lx. 4), O Christ! for
Thou regeneratest us by the blood and water streaming from Thy
side.
“Fourthly, consider that, although the lance gave no pain to the
Saviour, yet was it keen, for it wounded with cruel pang the heart of
the Mother. For her heart was bound up with the heart of her Son;
and to this the prophet seems to refer when he says, Supra dolorem
vulnerum meorum addiderunt. (Ps. lxix. 27.) But in conclusion, I
repeat—Arise, O dove! enter in, O love! for here is the door by which
thou shalt pass to the marriage-feast of thy Bridegroom; for here is
the window of love which desires to enkindle thee also; for here is
the furnace streaming forth with mercy. Gathering together all thy
evil affections, thy sins, thy negligences, cast them into that furnace
of love, that there they may be consumed. There exclaim with
Thomas, My Lord, and my God! and with the Psalmist, This shall be
my rest for ever; here will I dwell, for I have a delight therein. For
there is the place to live, there is the place to die.”
In like manner does Marchant exclaim: “Spare, O cruel nails, O
spare those sacred feet, which have never walked in the way of
sinners. Come rather and pierce my heart; pierce my hard heart with
the piercing of penitence, that ye may draw from it the salty tears of
contrition; for, from the time when ye were sprinkled with the
Saviour’s blood, ye have had power to heal the wounds of the mind.
“Yet would not the Saviour spare Himself these nails, that He
might make satisfaction for all offences committed by our feet
walking in the way of sinners, when we went astray like the lost
sheep; and that He might merit by this price and these pangs to
guide our feet into the way of peace.
“It was not sufficient for Him to have endured so much labour,
sweat, and weariness, whilst seeking His wandering sheep; but He
desired also that His feet should at length be pierced, not with the
thorns only, but also with the nails.”
On the words, He stood in the midst of them, he remarks: “There
then were the disciples gathered in terror, in error, all had lost their
faith, all wavered, doubting of the resurrection. All, the Virgin
excepted, had lost the light of faith, as is represented by the Church
in her Office for Holy Week (i. e. Tenebræ), when fifteen candles are
extinguished, one alone being excepted and allowed to remain
alight. This indicates the eleven Apostles with the three women
losing the light of faith, which remained in the Virgin alone, of whom
it might truly be said, Her candle goeth not out by night. These,
then, being gathered together, Christ was present in the midst,
though the doors were shut; for just as He issued from the Virgin’s
womb leaving her still virgin, as He passed through the unmoved
stone of the sepulchre, so now did He enter to His disciples without
impediment, for nothing can hinder the transit of a glorious body:
He stood in the midst of them! Stood as a pastor in the midst of his
flock, gathering them to him; as a leader in the midst of his soldiers,
encouraging them; as the sun in the midst of the stars, illumining
them; as the heart in the midst of the body, vivifying it; as the tree
of life in the midst of Paradise amongst the elect trees; as the
candlestick in the midst of the house, lighting it and dispelling its
gloom; as the column in the midst of the building, sustaining it.
“And this word stood has its special significance, denoting the
resurrection. For before the resurrection, when He bore the burden
of our sins, He is described as at one time lying in the manger, at
another as seated weary by the well, and then as prostrate with His
face to the earth praying, upon the mountain, or as bowed down
and crying to the Father in the garden, or again as stooping under
the weight of the cross as He ascended Calvary, whilst on the cross
itself He is spoken of as bowing His head to give up the ghost. All
which attitudes of the body denote the weight of our sins with which
He was burdened. But now, that burden is shaken off in His
resurrection, for He has drowned it in the abyss of His blood, and so
rightly is He spoken of as standing in the midst.”
Jacques Marchant thus paraphrases the 110th Psalm: “At the
ascension it was said unto Him, Sit Thou on My right hand, until I
make Thine enemies Thy footstool. That is, Do Thou, who art
exalted above all creatures, share with Me My kingdom until all
Thine enemies are subjected unto Thee, till the kingdom of the
predestinate is filled, and Thy victory has attained to its perfection.
And here by the fulfilling of the kingdom of predestination, and the
conquering of foes, and the extension of empire, this is signified,
that in the consummation of the age, He will return again into the
world, that the subjection of every thing to Him may be made
manifest in all the world. Wherefore the Psalmist adds, The Lord
shall send the rod of Thy power out of Sion: be Thou ruler, even in
the midst among Thine enemies. That is, the sceptre of Thy royal
power, the sceptre of strength, shalt Thou begin to extend and pass
on from the city and mount of Sion, even unto the ends of the earth,
by Thy Apostolic messengers; so that Thou mayest rule even in the
midst of Thy enemies and false brethren, Jews, heathen, and
heretics. In the end of the age, however, Thy kingdom will be
exalted perfectly over Thine enemies, when Thou shalt send forth
the sceptre of virtue, the banner of Thy cross out of the Heavenly
Sion, that Thy foes may be entirely subjected beneath Thy feet.
Then he adds: In the day of Thy power shall the people offer Thee
freewill offerings with an holy worship, when the kingdom will be
Thine, and Thine the only principality.” The Vulgate varies so much
from our English Version in this third verse, that Marchant’s
paraphrase cannot apply to it, and I shall therefore pass on to the
fifth verse: “The Lord upon Thy right hand shall wound even kings in
the day of His wrath. Christ our Lord sitting at Thy right hand shall
break all the power of kings who have persecuted the Church. Then
shall the Neroes, Maximinians, and Deciuses be thrust down into
hell. He shall judge among the heathen; He shall fill the places with
the dead bodies: He shall then exercise judgment over all nations,
and, having condemned the wicked, shall perfect and consummate
their last extermination. Then shall the places of hell be filled with
impious men, and with devils thrust down thither and there
enclosed; and that because He shall smite in sunder the heads over
divers countries, breaking down the proud, and bringing them into
confusion before all the world.
“And would you know why He is given such power to judge the
nations and trample upon kings and haughty men? He shall drink of
the brook in the way: therefore shall He lift up His head. Because,
forsooth, in this way and mortal life, which glides by as a brook, He
drank the turbid water, bearing our infirmities, by His Passion
descending into the very depths of the stream; therefore, because of
this so great humility, hath God highly exalted Him, making Him the
Judge of all.
“If indeed in His first Advent it was cried, Blessed is He that
cometh in the name of the Lord; Hosanna in the highest! how much
more in that His second triumphal coming will it be cried by angels,
by the elect, by kings, by priests, by people, by children, ay! by all
creatures, Let the Heavens rejoice, and let the earth be glad: let the
sea make a noise, and all that therein is. Let the field be joyful, and
all that is in it; then shall all the trees of the wood rejoice before the
Lord, for He cometh, for He cometh, to judge the earth.
“We too, considering that time of triumph, shall exclaim to our
King and Saviour with glad accord, ‘Reign even in the midst among
Thine enemies! Reign, Thou Son of David, setting up Thy throne
above all monarchs! Reign, Thou peaceful King, trampling under foot
all the kingdom of Satan! Reign, Thou Son of Mary, in the midst of
heretics and blasphemers! Reign, Thou Galilæan, in the midst of
infidels once rebels! Reign, Thou Nazarene, in the midst of Julians
and persecutors! Reign, Thou innocent Lamb, in the midst of
ravening wolves! Reign, Thou Lamb which was slain, in the midst of
angels and all the elect!’ I heard the voice of many angels round
about the throne and the beasts and the elders, saying with a loud
voice, Worthy is the Lamb that was slain to receive power, and
riches, and wisdom, and strength, and honour, and glory, and
blessing. And every creature which is in Heaven, and on earth, and
under the earth, and such as are in the sea, and all that are in them,
heard I saying, Blessing, and honour, and glory, and power, be unto
Him that sitteth upon the throne, and unto the Lamb for ever and
ever.”
JOHN OSORIUS.
John Osorius, a Spaniard of the diocese of Burgos, entered the
novitiate of the Society of Jesus in 1558, at the early age of sixteen.
He taught moral theology, but gave himself up more especially to
preaching, his talents in that line soon manifesting themselves. He
preached often before the Court, and was selected to deliver
orations on various public occasions. For instance, he preached twice
at the fitting out of the Armada, and again on its discomfiture. His
three sermons, entitled Cum nostri redirent ab Anglia re infecta, will
be found in the fourth volume of his collected sermons. He was
select preacher on the anniversary of the death of St. Ignatius
Loyola, the founder of his order, and also on the occasion of the
death of the king. He died at Medina, aged fifty-two, in the year
1594.
His sermons have been published several times.
Concionum Joannes Osorii; Antverpiæ, 1594-5, 3 vols. 8vo. Ibid.,
5 vols., 1597, 8vo.
Concionum J. Osorii; Colon. Hierat. 1600, 12mo., 5 vols.; Lugduni,
Pillehotte, 1601, 8vo.; Venetiis, 1601, fol.; Parisiis, M. Sonnium,
1601, 8vo., 5 vols.; Venetiis, 1604, 4to., 5 vols.; Monast.
Westphaliæ, 1622, 8vo. 5 vols.
R. P. Osorii Concionum Epitome; Colon., 1602, 8vo., 3 vols.; De
Sanctis, ibid., 1613, 8vo.
John Osorius was a preacher of a high order. He was eminently
Scriptural, and thoroughly practical. He neither wasted his efforts on
the discussion of profitless school questions, nor wearied his hearers
by abstruse disquisitions on points of Canon law. His matter is
always solid, and his method sound and clear. A man of refined taste
and lively imagination, he could render his discourses attractive to
both educated and uneducated. He seldom breaks into a torrent of
eloquence, like De Barzia, but his style is polished and graceful. He
had none of the fire of the Bishop of Cadiz, but in his heart burned
the pure flame of a tempered zeal, not raging forth as a furnace,
dazzling and scorching all around, but calmly glowing in unruffled
peace, unnoticed perhaps in the glare of day, but steadily beaming
as a guiding star to the wanderer in the night.
In one point he certainly resembles his countryman De Barzia, viz.
in his accurate Biblical knowledge. But the use he made of Scripture
was different to that made by the Bishop, as his audience was very
different from that to which the Prelate addressed his Mission
Sermons. Holy Scripture was the spiritual food of this Jesuit
preacher, and his discourses prove his intimate acquaintance with
every portion of God’s Word. His discourses do not contain, as do so
many modern sermons, crude and undigested lumps of Scripture,
clumsily pieced and awkwardly inserted to distend the dull oration to
its conventional limits, but the words of Inspiration float lightly and
fragrantly on the stream of simple eloquence, as strands of new-
mown grass and cut meadow flowers on the calm brook which softly
glides past the field where the mowers mow the hay.
If De Barzia roused long-dead consciences, waking them from
their sepulchres with note like a trumpet, bringing them forth bound
hand and foot in the corpse-clothes of evil habits, and delivering
them over to the confessors to be loosed and let go, Osorius
quickened the consciences but just dead, with still small voice,
taking them as it were by the hand and lifting them up with
tenderness, that he might restore them to their parents—to their
God, who was to them a Father, to the Church, which was to them a
Mother.
But with all these rare merits, Osorius had his defects. His
sermons are wanting in arrangement and in unity of design. He
preached on the Gospel for the day, and aimed rather at giving a
running commentary on the selected passage of Scripture, than at
elaborating one text and concentrating his powers upon its
application. Hence, each of his sermons, which are very long, may
well be broken into six or eight short discourses with separate
points, but when preached in their entirety the effect is that of a
surfeit. Nothing can be better than the food he provides, but it is in
too great abundance, and it is too varied; briefly, in his sermons
there is what the French call an embarras de richesses.
There is this excuse to be made for Osorius, that he did but follow
in the wake of the Patristic and Mediæval preachers, whose public
orations consisted almost invariably of Scripture expositions,
partaking more of the character of our modern Bible-class lectures
than our set sermons; and it was only bold men like De Barzia, who
set all conventionalities at defiance, that originated the class of
sermon now recognized as the normal type of a pulpit discourse.
Osorius, however, could divest himself of the trammels of custom
when he chose, and he has left some notable specimens of sermons
which have but one point and subject, in his fourth volume; and I
very much question whether any more noble and more vigorous
have ever been composed than those written by John Osorius, the
Jesuit, on the Four Last Things, the Three Foes of Man, and the
Seven Last Words.
Osorius seldom relates anecdotes, and his sermons are almost
entirely free from those stories which preachers of his age delighted
in introducing to illustrate their subjects; but, in their place, he
brings forward similes to an extraordinary extent. His sermons are
studded with them, and his similes are almost invariably graceful and
neat. It may be questioned whether he does not somewhat overdo
it, when one sermon contains fifteen similes. Yet these are so
beautiful that we could ill spare one. Perhaps we are too critical in
requiring all sermons to be cut to the same shape; perhaps the
beauty of the wood hyacinth may consist in the multitude of its
azure bells, and the splendour of the tulip would be lost if it grew in
a bunch.
But the reader shall judge for himself. I will give him a string of
similes from the Trinity sermons of Osorius.
“Aristotle says that as the sun, most visible in itself, cannot be
contemplated without difficulty by our eyes, on account of their
weakness; so God, of supreme entity and perfection, can hardly be
grasped by us, through the imperfection of our intellect.”
“When my father and mother forsake me, the Lord taketh me up,
says the Psalmist; and Israel exclaimed, Make us gods to go before
us. For without God we have not power to advance. What will he say
to this, who enters on a state of life without God to lead him, who
undertakes hard matters forgetful of God? As the ivy trails along the
earth when it finds not a tree, to which it may cling and by which it
may ascend, so does the soul lie prostrate till it has found God, to
whom it may cling as to its beloved; and having found Him, by Him
ascend, going on from grace to grace.”
“The Heavens declare the glory of God, and the firmament
showeth His handiwork: they all point wondrously to their Creator,
showing themselves to be creatures fashioned by His hands.
“Cicero observes: If when travelling you came suddenly in a desert
upon some magnificent palace, such as that of Solomon, and were
to ask how it came thither, and the answer were made that a
mountain had fallen, and that its ruins had shaped themselves,
somehow, into this great mansion, you would laugh them to scorn
who asserted this, for the house shows plainly the handiwork of an
artificer—and that he was a famous artificer to boot—who thus
ranged all in such perfect order, and this, you would say, was self-
evident. So, too, he who considers the workmanship of this world
with attention,—the garden of earth, the abyss of sea, the heavens
wondrously adorned, the variety of stars, their varied and yet
harmonious motions,—he will say that it is manifest that some
master artificer has arranged them, and that their conjunction
cannot be fortuitous.”
“Look first at the beauteous image of the soul, and gather from it
that it has a divine artificer. If you saw a boy holding a charming
image in his hand, and you asked him, Whose is this image? who
fashioned it? if he were to reply, I made it; you would at once say,
That is not true, for it is a masterpiece of art. So, too, the wondrous
power of our souls, and their wondrous perfection, point to a
Heavenly artificer.”
“Who, then, is God? He is One and Three: one in nature, one in
wisdom, one in goodness; but three in Person: Three Persons but
One God, one wise, one powerful, one good.
“How then three Persons and not three Gods? I and thou are two
persons, but one in nature and species.
“How two persons with one nature? Because in me there is that
which is not in thee, and this constitutes difference in personality.
“But thou sayest, What is there in the Father which is not in the
Son?
“That thou mayest understand, take this illustration.
“I have invented a science, entirely of myself; this science I teach
thee; thou and I communicate it to a third. The same science is in all
three; one of us knows nothing which the other knows not; one
knows as much as all the three. Yet is there this difference between
us, I have the knowledge of myself, having received it of none; in
thee it is derived from me; in the third it proceeds from thee and
me. Now suppose that, instead of a science, this were my nature
which I gave to thee, and which we two communicated to the third;
then should we three be one in nature, and yet with the diversity I
have specified.
“Thus, as I have said, is it with our God, in whom it is the same to
be, to know, to be able, &c. This wisdom and nature is in the Father
self-derived, received of none. It is in the Son also, the same, but
received by intelligence from the Father. It is in the Holy Ghost, but
proceeding from the Father and the Son by love: therefore the
Persons are three, but there are not three Gods nor three Lords, for
the nature, and the wisdom, and the power, and the goodness are
one, but in three Persons; therefore there is but one God, one Lord,
one Wise.”
“God is the abyss of being, as signifies His name Jehovah; in Him
are all perfections, of which perfections each is infinite, all are One.
What then is my God? Ask every creature, and let them show you
their God, and tell you what He is; not that each can declare Him
perfectly, but each in part. Does it not happen to you sometimes, as
you walk abroad, that you light upon a brook, and say, I will trace it
to its source, and see whence this streamlet flows? Do you now act
thus, and you will attain to your God. Mark what is good in the
creatures you behold, in the song of birds, in the beauty of flowers,
in the wealth of metals, in the sweetness of meats; these are but
rills proceeding from God the abounding Fount; all these utter the
things which are in God; for all creatures are but voices manifesting
Him.”
Yet we must not rest in them. “It has happened that painters have
pictured fruit with such accuracy that birds have come out of the sky
thinking them real, in order to feed upon them; but finding them to
be painted, and that there is no food in them, they fly away to seek
their true sustenance. The Divine painter has traced with His brush
in His creatures the beauties which live in Himself, and in them they
seem to live. Yet are they but figures, not verities, for the fashion of
this world passeth away. Would you know how to act, knowing that
these are but pictures and not realities? Act as the bird, which
finding no food in the painting seeks its real meat elsewhere. Mark
this, you will find in creation no true food, no satiety, no repose;
mark this and fly away to your God, He is very good, He is true food,
in Him alone is repose.”
“When you hear sweet harmony, you say, I hear musicians,
though you see them not; so seeing the harmony of creation,
acknowledge God its source. In God are all perfections. Take the
opal. Look at it fixedly from one point; it is white as snow, and you
see nought save whiteness in it. Turn a little aside; it flashes out in
flames as a carbuncle. Look from another point, it glows a rich
crimson as the ruby; again, from another point it is all green as the
emerald. Lo! you have an image of God, that most precious gem, to
win which we must sell all we have. He is one, yet manifold. Moses
beheld God, and He was to him like to the carbuncle, a burning fire:
The Lord thy God is a consuming fire. That same God did David
behold: The Lord is full of compassion and mercy: long-suffering and
of great goodness. To him then was He not all white? Isaiah beheld
him: Wherefore art Thou red in Thine apparel? and seeing Him
executing vengeance, He was like to the ruby. John beheld Him, and
a rainbow round about the throne, in sight like unto an emerald. Lo!
what variety, and yet what unity!”
One of the most curious ideas of Osorius is the following. He says
that as he lies in bed he hears the stroke, stroke, of his heart; and it
sounds to him as though within were two wood-cutters engaged
night and day in hewing down a tree. Nor am I wrong in thinking so,
he continues, for Flux and Reflux are engaged every hour in laying
their axes to the root of the tree of life. In another sermon he
speaks of men fretting over the loss of worldly goods and neglecting
their eternal inheritance as resembling the little boy who has built a
mud castle, and who weeps when a passer-by overthrows it with his
foot, though he cares nothing that a lawsuit is going on at the time
by which a large inheritance is being wrested from him.
The following is singularly beautiful, to my mind. Osorius is
speaking of the dower Christ has given to His Church. He says, that
as when a traveller marries a wife in a far country he gives her a few
presents, but says to her, O my beloved, when we come home to my
own country, where all my wealth and property are, then you shall
have ten thousand times better presents; so does Christ act with His
Church. Here, in the far country of this earth, He gives her a few
gifts and graces, but when He leads her home to His heavenly
habitation, He will crown her with endless glory.
On the subject of the Ascension, he observes, very gracefully, that
when a fleet is tossing on the sea, if one vessel enters the port in
safety, the others pluck up courage to follow. When the soldiers see
their leader mount the wall of the besieged city, they, though below,
are stirred to press onward too.
And again, speaking of Christ resuming His seat in Heaven, he
says that when a costly gem is given to a king, he sets it in a golden
ring, which is exquisitely wrought, and which seemed a miracle of
perfection before the insertion of the gem. But when the jewel is
set, its glory eclipses all the graving of the ring. So was Heaven
beauteous without Christ, beauteous as the setting, but now the
precious gem, for whom all was made, is again in His place, and
eclipses all other glories in His own effulgent beauty.
“The joy of Heaven must have been great, and the cause of the
joy is manifest. Heaven has received its sun, enlightening it more
than all its stars. It has gotten its precious gem adorning that ring of
eternity more than its fine gold, more than all the comely forms
thereon engraved. But, earth, how canst thou rejoice this day,
deprived of the sun which late illumined thee? When the sun shines
in this hemisphere, all things rejoice receiving light from it; but when
it retires to the other hemisphere, those things which are in it begin
their rejoicing, whilst those which are in ours are veiled in darkness,
and droop in gloom and tears. When the ark of God was brought to
Bethshemesh, that is, the house of the sun, the calves of the cows
which drew it were shut up at home, and they lowed because the
mothers which gave them milk were away. This day is the ark of
God, which has been held captive in the house of this world, brought
back into Heaven, the true house of the sun. And we, as the calves,
remaining shut up in this world’s tabernacle, without our
nourishment from the breast and wounds of Christ, how shall we do
otherwise than low and lament?”
This beautiful and quaint passage will show how Osorius finds
illustration in Scripture. I translate a few more specimens of his
style.
“Behold how He loved him. St. Thomas explains this passage
admirably when he says, quoting the wise man, Nothing doth
countervail a faithful friend, and his excellency is invaluable, for a
faithful friend is worthy of love: and yet, a faithful man who can
find? He is a faithful friend who is stable in friendship; not forgetting
a first friend when a new one arrives, nor when exalted in prosperity
forgetful of the friend in poverty, nor despising the friend who is cast
down.
“God will be found the most faithful friend, in that He never
forgets former friends for the sake of new ones; but those whom He
chose before time was, these will He love in eternity, when time is
no more. Neither does the addition of new friends make the former
less the friends of God, but rather the more grateful is it to Him that
many should love Him. Nor is Christ like the chief butler, who, when
things went well with him, forgot Joseph; but though the Lord be
high, yet hath He respect unto the lowly. Christ, when mortal, chose
men to be His friends; when made immortal, He called them His
brethren. Go to My brethren, and say unto them, &c. (John xx. 17).
Nor is the friendship of Christ capable of change through loss of the
friend, as is evident from the eleventh chapter of St. John. Now
Jesus loved Martha, and her sister, and Lazarus, when they were
hale and sound. But what will He do when Lazarus is sick? Lord,
behold he whom Thou lovest is sick; He ceases not to love because
His friend is sick. Lazarus dies, the misery increases, but friendship
does not decrease; for He says, Our friend Lazarus sleepeth. Lazarus
is not called friend because that he loves, but because he is still
beloved. Now Lazarus stinketh, and still Christ is his friend, for He
weepeth because of him. Behold, they say, how He loved him! Ill, O
multitude, do you speak! to Him love is present, therefore rather say,
Behold how He loveth him! O most faithful Friend, Thou art He who
sayest, I have loved thee with an everlasting love!
“Far otherwise are we toward Christ. He is in bonds, and lo! Peter
swears that he knows Him not. O man! if you seek a true friend,
seek first Christ, who changeth not. What think you is the friendship
of the world? What the friendship of the flesh? You have three
friends. You are in peril, for you are summoned before the king to be
tried, and sentenced for high treason. You go to your first friend,
and tell him your danger, and ask of him assistance. He replies that
he will accompany you as far as the judgment hall, and leave you
there. ‘Do you settle your affair with the king; I can do no more for
you.’ Seeing that there is no help to be gotten from this friend, you
turn to the second, and ask of him succour. He replies, ‘When you
are executed, I will wrap your body in some old and cast-off linen,
for a shroud.’ You go to the third, and he says, ‘I will be your
advocate. I will assist you, and will liberate you. I will pacify the
king, and, if need be, I will die in your room.’ Is not this a faithful
friend? Now those who enter into compact of friendship with their
flesh, which of these friends have they got? The first, which will
accompany you only to the gate of death. Cherish the flesh, love it,
and it will be a Delilah to you, handing you over to your enemies,
leaving your soul before the Judge, without accompanying it. The
world resembles the second friend, to please which you must torture
yourself, but all it will give you in the end will be the shroud to
enwrap your dead body. But Christ is the third friend, the faithful
one, our advocate, who, to liberate us, endured death for us; He
who accompanies us to the judgment, who frees us, who protects
us! Let Him be our friend who truly loves us. We love God because
He first loved us.”
I conclude with the following striking passage:—
“Are ye able to drink of the cup that I shall drink of? Being
desirous of alluring His disciples to drink of the cup, He expounds to
them its sweetness, when He says that He will drink of it first. And,
in sooth, if we were faithful to God, this reason would be sufficient
to make us drink it readily. But, as says the wise man, most men will
proclaim every one his own goodness: but a faithful man who can
find? There is not a son, there is not a servant, who acts as
faithlessly with his father or his master as we act towards God.
Would you know that of a certainty? I tell you be loth to sin, be
ready to die rather than sin.
“Ah! but you say, I like to sin. I ask you, Upon what grounds do
you persist in sinning? Well, you say, God is so good; He loves me,
He is ready to pardon. So this is the reason why you continue in sin!
And what though you know this for certain, where is your fidelity?
where is your Christian honour? Does a wife act in this manner with
her husband? a son with his father? a servant with his lord? I pray
you bid your wife act in this manner towards you. Say to her, ‘Be
chaste.’ She will say, ‘That is no concern of mine. I know full well
that you are good, that you love me, and that if I were an adulteress
you would pardon me.’ And if it were so, would this answer of your
wife gratify you? Why! where would be the honour of a good
woman? where her fidelity? Would it be deemed sufficient by you, if
she were an adulteress and were reconciled to her husband? Does
any minister act thus? You say to the royal minister, ‘Beware lest
thou plot treason against your master.’ He replies, ‘He is an excellent
king; he loves me, he will most certainly pardon me even if I do turn
traitor.’ O vilest of men! O man truly without honour! where is the
fidelity which you owe to your monarch?
“Vilest Christian of the household of Faith, unfaithful and destitute
of honour! how continue to sin? how do you still commit adultery
against God? how are you so traitorous to your King? You say: He
will pardon me. Be it so. Yet where is your fidelity? where your
honour? Is it sufficient to be reconciled, to be a pardoned traitor? Is
it not far better to be able to say, I never was a traitor?
“Now let us turn to the subject. If we are faithful servants of God,
enough for us that He has said, The cup that I shall drink of, to
make us thirst for that cup. He drank thereof before thee; wilt thou
not quaff of it out of love for Him? Is there a faithful soldier who
would see his sovereign enter the battle, and fight amongst the foe,
and withdraw himself, leaving his king alone, and betake himself to
his sports? Hear what Uriah said, The ark, and Israel, and Judah,
abide in tents; and my lord Joab, and the servants of my lord, are
encamped in the open fields; shall I then go into mine house? How
different also she who said, My Beloved is mine, and I am His.
Bernard says, ‘In no other way can man respond to his God in these
same words, except by love, and by drinking of the cup.’ God gives
thee gifts; thou canst give Him nothing. I will take no bullock out of
thine house. God beatifies thee; thou canst not beatify Him, except
by love and suffering. God loves thee; love Him thou canst. He
suffered for thee; suffer for Him thou canst. Thus mayest thou
render unto Him what thou hast received of Him, and return, as it
were, like for like to thy God.”
MAXIMILIAN DEZA.
Maximilian Deza, an Italian, was born in 1610, and joined the
Congregation of the Mother of God, in which he soon became
famous as a preacher. He seems to have been a man of fervent piety
and Apostolic zeal. He had acquired a good knowledge of the Latin
classics in his early years, and this he was fond of exhibiting, with
some pedantry, in his discourses. But such was the taste of the
times, when classic literature and art were deluging Europe, and
producing a revulsion in all the laws of taste which had regulated the
mediævals. This affectation of classic learning was the bane of
Deza’s oratory, and it is constantly obtruding itself on the reader, in a
marked and offensive manner, though nowhere perhaps so
prominently as in his sermon at the marriage of the Queen of Poland
with the Duke of Lorraine, in the Cathedral of Neustadt in Austria, in
which sermon, for instance, he enumerates celebrated marriages, as
those of Cadmus and Harmonia, Jupiter and Juno, David and Michal,
Isaac and Rebecca, and that at Cana—all in one breath.
As soon as his fame was established, he was in request
throughout his native land, and we find him preaching at Bonona,
Turin, and Milan. In 1664 he preached before the Doge at Genoa; in
1666 he was in Malta. We have sermons of his delivered at Rome in
1672, and at Venice in 1686. There is extant a sermon by Deza on
the birth of the Prince of Wales, the so-called “Pretender,” son of
James II., and an oration preached at Venice on the occasion of the
exhibition of the Blessed Sacrament for obtaining success against
the Turks, with whom the Republic was then at war. Maximilian Deza
was sent for by Leopold I. to preach before him at Vienna, and there
the old man died peacefully in his seventy-seventh year, a.d. 1687.
His sermons were published in Italian, “Prediche dell’ Avvento del
P. Massimiliano Deza, Lucchese della Congregatione della Madre di
Dio,” by Nicolo Pezzana, Venice, 1709.
There is also a Latin edition, translated by Cassimir Moll, a
Benedictine, published by Veith, Vienna, 1726, and dedicated to
John Julius de Moll, Archbishop of Salzburg.
The sermons extant form three series; the first consists of
sermons from the First Sunday in Advent to the Sunday after
Christmas, together with two discourses on the parable of the
Prodigal Son, in all nine, forming one volume. The second contains
thirty-eight sermons preached during Lent; and the third part, which
is immeasurably inferior to the other two, consists of orations on
divers saints, such as St. Catharine of Bologna, St. Peter of
Alcantara, St. Rosa of Lima, together with sermons on state
occasions.
Maximilian Deza just escaped being a really great orator, like
Segneri, whom he much resembles in his vehemence, zeal, fine
word-painting, and brilliant transitions. There is nothing heavy or
dull about his sermons; they are calculated to rivet the attention of
an audience, and they appeal earnestly to the conscience. They are
not sermons to be read in measured tones from the pulpit, but to be
declaimed with flashing eye, modulated voice, and vehement
gesture. To modern readers Deza seems to play with an idea in a
manner unsuitable to our nineteenth century ideas of pulpit
proprieties; but it must be borne in mind that his discourses are
long, lasting sometimes two hours, and the mind of the hearer
would need rest, it would only be fatigued if kept constantly on the
stretch. Viewed thus, it will be seen that Deza handles his matter
with great skill; he works one point of his subject to a climax,—you
hold your breath even in reading him—and then he gently drops the
point, and gives time for relaxation of the attention till he deems it
fit to produce another effect, just as in a drama the sensational
scenes are separated from each other by the talkee-talkee scenes in
the front groove. But these intermediate portions of Deza’s sermons
are by no means dull; they are light and pleasant trifles with which
he toys, but which lead on insensibly to his point, just as the small
beads of a rosary draw the fingers on to the larger ones.
Take his sermon for Ash-Wednesday as an example. He is
preaching on the words, “Remember, O man, that thou art dust, and
that into dust thou shalt return,” which occur in the Roman Office for
the day.
He begins with the lessons drawn from the ashes sprinkled every
where; and he bids his hearers look on these ashes, and remember
that they shall one day be like them. He then draws with skill a
picture of man’s forlorn condition, with the prospect of death before
him, and no possibility afforded him of escape. He laughs to scorn
the thoughts of immortality connected with name and title; he tells
the story of Empedocles seeking an immortal name by jumping into
the crater of Ætna; and then he warns his hearers most solemnly to
keep death ever before their eyes. Remember, he cries, that you
have sucked in with your mother’s milk the seeds of death.
Remember that all beasts were created alive, but Adam was created
a lifeless frame, till God breathed into his nostrils the breath of life.
Remember that from the moment of birth, the moment of death
began to creep nearer. Then suddenly pointing to the hour-glass he
exclaims, Look! this hour is stealing away in grains of dust, warning
you to remember what you too ere long will become. And having
worked this out with great solemnity, he suddenly breaks off into a
description of glass and its manufacture. He says it is made of sand
and ash, it is fused with heat, it is formed by the breath.
Is not that like man? he asks; man made of dust, kindled by the
glow of life, vivified by the Divine breath?
Well! you will say that glass is a very brittle affair; it somewhat
resembles ice, and is just as fragile; one little fall, and it is shivered
into countless fragments; it is made by a puff, it is clouded by a
breath, it is broken by a touch.
You consider it very fragile.—I tell you, on the authority of St.
Augustine, that man is far more fragile.
Glass carefully preserved may become an heirloom, but man can
never last out more than a generation.
Glass is only shattered by accident, but man is perishable by his
nature.
Glass is broken by external force, but man bears about within him
the seeds of dissolution.
Glass is snapped by a touch, but man untouched will crumble into
his grave.
Glass once broken may be restored, not so man.
Glass though broken does not decay, but man’s flesh becomes
corrupt.
Having thus amused and rested his hearers, Deza begins another
earnest appeal to them; he explains that the soul of man does not
descend to the grave, and he solves a difficulty in the text, Genesis
iii. 19, Dust thou art, and unto dust shalt thou return.
Having done this, it is proper that the congregation should be
given a little breathing-time, and so the preacher takes the
sentence, Dust thou art, and plays with it, by giving a description of
dust agitated by the wind. Oh, into what fantastic shapes does the
wind whirl the dust! how the dust-cloud runs along, rushes forward
madly, stops and spins awhile, and tosses itself up, up, till it seems
verily to fly; it ascends higher and higher, it is carried above the tree-
tops, it will reach the clouds of Heaven. Stay!—the wind drops.
Where is the dust? It falls, it obscures the landscape, it is scattered
every where, it parches the tongue, it blinds the eyes, it clogs the
throat; and that which just now dulled the air and obscured the sun,
has returned to itself again; dust it was, and nothing more, and unto
dust has it returned.
Is not this a picture of man? asks the preacher; man, poor dust
carried up and hurried forward by the winds of his vain fancies?
Ambition puffs him up on high, only to fling him to earth again;
passion drives him forward, and then drops him a helpless atom to
his native soil.
Look how high those giddy particles are flung—Thou takest away
their breath, they die, and are turned again to their dust.
Yes, toss yourselves in pride, rush on in the storm of passion,
eddy up in the struggle of life, spin in the giddiness of pleasure,
penetrate every where in the eagerness of curiosity—Thou takest
away their breath, they die, and are turned again to their dust.
Deza then examines the words of Solomon, There is a time to be
born and a time to die, and he asks why the King did not say there
is a time to live. Having answered this question to his own
satisfaction, by showing that Solomon spoke of definite moments of
time, but that life was not a point of time, but a fleeting succession
of moments, he enters on the subject of the shortness of time, and
quotes Wisdom v. 10. The life of man, says Solomon, is as a ship
that passeth over the waves of the water, and leaves no trace—no
trace but the foam-bubbles; and those foam-bubbles are like the life
of man, now appearing in the wake of the vessel, and then brushed
away by the next wave,—and this wave is like the life of man,
sweeping on resistlessly to the rock on which it will be shivered with
a roar—a roar like the life of man, loud and fierce for the moment,
and then carried off on the wind—the wind like the life of man
sinking into a lull and lost.
And so throughout the sermon.
I will now give an analysis of one of Maximilian Deza’s most
characteristic and striking discourses, with a translation of a portion
of it as a specimen of his style of oratory.
The sermon I have selected is that for the First Sunday in Advent,
with which the Feast of St. Andrew coincided. The lessons from each
holiday are very happily blended.
Maximilian Deza takes two texts, the first from the twenty-first
chapter of St. Luke, Then shall they see the Son of Man coming in a
cloud with power and great glory; and the second from the Office for
St. Andrew’s Day, “Blessed Andrew prayed, saying, Hail, good Cross!
may He receive me by thee, Who by thee redeemed me.”
Introduction.
On this coincidence of holidays two points of
consideration are presented to us; the Cross the
sign of terror and destruction to the guilty, and
the Cross the sign of joy and salvation to the just.
I. The love of the Cross is the characteristic of the
elect; whilst the hatred of the Cross is the sign of
the reprobate.
α. The Lord knoweth those that are His—by
their love of His Cross of suffering. If
any man will come after Me, let him
deny himself, and take up his cross,
and follow Me.
β. But the wicked are called the enemies of
the Cross of Christ, whose end is
destruction.
The day will come, the great and terrible day of
the Lord, when He will call the heavens from
above, and the earth, that He may judge His
people; when the Cross, the sign of the Son of
Man, will appear in the clouds of Heaven.
II. Then God will judge the world with fire, and the
Cross alone will be the standard by which all will
be tried.
God will judge the world with fire.—How with
fire? When a palace is destroyed by the flames,
every thing in it is reduced to cinder; the rags of
the beggar, the gorgeous robes of the prince, the
statue of the king, and the image of the ape. So
every man will be tried with fire, and all difference
between man and man as now existing will be
rendered indistinguishable. King and subject,
master and slave, will stand shivering in
nakedness beside each other; there is no respect
of persons with God, they will be but as a heap of
cinders, which are equally hideous, though some
may be the ashes of costly articles, others of vile
materials.
One alone distinguishing mark will be left, the
love of the Cross, by which to judge them.
III. By the Cross will the saints be recognized, as in
Ezekiel ix. the prophet saw in vision the
destruction of the last day, when God’s command
was, Slay utterly old and young, both maids, and
little children, and women: but come not near any
man upon whom is the mark Tau.
This Tau, Deza observes, is the Cross, the mark
on the brow by which the faithful shall be known.
Tau is the last letter of the Hebrew alphabet, and
it is the last sign which shall appear in Heaven.
The preacher then goes through the list of those
slain, old and young, maids, and little children,
and women, and shows how that wisdom of grey
hairs, or innocency of childhood, or purity of
virgins, are of no avail to stand the fire of trial
unless the Cross be the source of those graces.
The Cross is the banner of the King in His army
on earth. It is the tree of life in the Paradise of His
Church.
IV. The Cross, as sign of safety to some and of
destruction to others, was prefigured in the Old
Testament—
α. By the rod of Moses, which opened the
sea for the passage of the Israelites,
and which brought it back again to
overwhelm the Egyptians.
β. By the ark of Noah.
γ. By the blood-marks on the lintel and
door-post when the destroying angel
passed through Egypt.
V. A contrast is drawn between St. Peter and the
penitent thief. The former feared the Cross, and
when our Lord spoke of His approaching
crucifixion, the Apostle said, Be it far from Thee;
and was therefore suffered to fall. But the thief
who sought Christ through the Cross found
acceptance.
VI. Deza shows that people may now become enemies
of the Cross of Christ—
α. By gluttony and drunkenness.
β. By debauchery and frivolity.
γ. By injustice and dishonesty.
δ. By falsehood and calumnies.
ε. By hypocrisy.
He draws a very solemn and awful picture of the
dawning of the great day, and the flashing of the
sign of the Son of Man upon the enemies of the
Cross of Christ, and then—
VII. He comments on the sentences pronounced on
the good and on the bad. This is the passage I
translate.
Part II.
VIII. Maximilian Deza now shows how St. Andrew is a
blessed child of the Cross. He shows how that to
him the Cross was as a second mother, guiding
him through life, sustaining him and embracing
him in death.
IX. The love of Christ’s Cross regenerates us, assures
us of our sonship, and is an earnest of our
inheritance.
At our birth into this world we are placed in
divers positions by the will of God and by no
appointment of our own. So some are born to be
kings, some to be slaves, some to be
philosophers, others to be fools.
But at the regeneration it will not be so. Our
position then will be regulated by our own selves,
for we shall be nearer to, or more remote from,
Christ; be princes or subjects according to our
love for the Cross of Christ during our earthly
existence, according to the closeness of our walk
in the bloody footprints of our Master, bearing our
crosses after Him, in the season of our probation.
And in conclusion, Deza makes an eloquent and earnest appeal to
his hearers to redeem the time because the days are evil.

The following is a translation of the seventh section of this most


striking sermon, which exhibits at the same time his power and his
weakness, his merits and his defects:—
“Behold!” will say the Judge, with threatening voice, to that great
throng of accused; “behold! on this Cross I poured forth all the
treasures of My love—producing blood for your welfare; to you
though was that most precious stream counted but as dung,
squandered recklessly for some fleeting vanity. From this My Cross
with last and dying voice, with tears breathing nought but piety, I
called you to penitence, but as deaf adders you stopped your ears
and hardened your hearts to the sweet incantations of love. On this
Cross, full of sorrows and of confusion, painfully I suffered death,
that I might recover eternal life for your souls; and you, meanwhile,
before the countenance of God dying for you, did laugh with the
scribes, mock with the Pharisees, sport with the soldiers. This My
Cross was a noble pulpit from which I, the Master of humility, of
patience, and of charity, taught you the love of your enemies,
praying to the Father for My foes and My persecutors. But you! what
did you take in, what did you learn? Answer, what? The implacable
madness and rage of a Saul, the boastings of a Goliath, the
impieties, and crimes, and vengeance of a Cain, a Joab, or an
Absalom. And what! were your hopes too rash to calculate on finding
safety in that Cross? Ah, wretched ones! Are ye not those to whom
the withering roses of this world were more acceptable than My
thorns? Are ye not those who sucked in the sweet poison from the
cup of Babylon, but rejected the chalice of My passion? Are ye not
those who, fleeing the embrace of My Cross, rushed into the arms of
lust which polluted you, of the world which betrayed you, of Satan
who erects his trophies upon your ruin? These, these were your
lovers, these the idols of your heart, these the deities ye idolatrously
worshipped—commend yourselves now to them, let them arise and
help you. In Me remains no hope for you, no more bowels of
mercies,—Depart from Me, ye cursed! This Cross is your
condemnation; this gallows-tree is your scourge, this wood will rack
and consume you more fiercely than the flames of hell. Depart from
Me, ye cursed, into everlasting fire.”
But oh, happy elect! to whom on the contrary the holy Cross has
been the bow of peace eternal, the ladder of Heaven, the pledge of
glory, the unfading palm of lasting triumph. “Come, ye blessed of My
Father!” Oh, sweet words! best-loved invitation! most pleasant
reception, long-looked-for glimpse of Paradise so near! “Come, ye
blessed of My Father. Ye innocents by your sweat, ye penitents by
your tears, ye martyrs by your blood, did water the tree of My Cross;
come now, gather the fruits of safety, life, and happy immortality.
Come, ye blessed of My Father. Ye who followed My blood-stained
traces up the hill of Calvary, even ye shall ascend with Me to the
topmost height of the heavenly Sion, where this Cross is exalted to
be the trophy of your victories. Come, inherit the kingdom prepared
for you from the foundation of the world. By nature were ye My
subjects, but by grace My sons; and as sons of a reigning Father My
kingdom shall be your patrimony, and My Cross the sceptre of a
deathless realm. My charity bore it, out of love for you; your
gratitude bore it, out of love for Me; now has come the season for
both Me and you, that to patient love should succeed love beatifying.
As long as I am God, that is, for eternity, ye shall also be happy,
shall be likewise glorious, triumphant, princes of Heaven with starred
diadem on your brows, and monarchs of the universe.”
FRANCIS COSTER.
The subject of this memoir was born at Malines in the year 1531;
he was one of the first to join the new Society of Jesus, and at the
age of twenty-one was received into it by the illustrious founder
himself.
St. Ignatius soon discovered the remarkable talents and the deep
spirituality of the young man, and he stationed him at Cologne,
placing him in the van of the army of the Church, and in the thick of
the fight then waging between Catholics and Protestants. He was
admirably adapted for his position, and fully justified the confidence
placed in him by Loyola. The Lutherans and Calvinists found in him
an enemy of no ordinary power, and quite invulnerable to their
blows. His knowledge of Scripture was as thorough as, and was
sounder than, their own. Their arguments were dissected, and the
fallacies exposed, by Coster, in a manner so clear and so conclusive
that he stung them to madness.
Volume after volume passed through the press from his pen, many
of them composed in the vernacular, so as to be read by the vulgar.
He is said to have brought back multitudes to the Church who had
fallen away at the first blush of Protestantism, and to have
strengthened numerous souls which wavered in doubt.
He taught astronomy and lectured on the Holy Scriptures in
Cologne. He was afterwards Rector of several Colleges, thrice
Provincial, and present at three General Congregations of the Order.
After a life of controversy, yet with a soul full of peace and
goodwill to men, Francis Coster entered into his rest in 1619, aged
eighty-eight years; of which he had spent sixty-seven in the Society
of Jesus. He died at Brussels.
His works are too numerous for me to give a list of them here. A
complete catalogue will be found in the Bibliothèque des Écrivains de
la Compagnée de Jésus, par Aug. et Alois Backer, vol. i. pp. 218-
224. I mention the sermons alone.
R. P. Costeri Conciones in Evangelia Dominicalia a Dom. Adventus
usque ad initium Quadr.; Coloniæ, Ant. Hierat. 1608, 4to. Conciones
ab initio Quadr. usque ad Domin. SS. Trinitates; ibid. id., 1608, 4to.
Conciones a Domin. post Fest. SS. Trinit. usque ad Adventum; ibid.
id., 1608, 4to.
R. P. Fr. Costeri Conciones in Evangelia; ibid. id., 1613, 4to.; 1626,
8vo., 3 part., 4 vol. This last the best edition.
Vyftien Catholiicke Sermoonen op t’Epistelen end Evangelien;
Antwerp, 1617, fol., 4 vols.
Catholiicke Sermoonen op alle de heylichdaghen des jaers;
Antwerp, 1616, fol., 2 vols.
Sermoonen op d’Epistelen van de Sendaghen,—met twee octaven;
Antwerp, 1616, fol.
Francis Coster differs in style from all the other preachers whom I
have quoted. He is neither eloquent nor impressive as a speaker, he
is immensely long, and must have been desperately tedious in the
pulpit; and yet I question whether a priest could possess a more
valuable promptuarium for sermon composition or catechetical
lecture than Coster’s volumes. Coster is rather an expositor of
Scripture than a preacher; his insight into the significance of the
sacred utterances is perfectly marvellous.
Coster relates numerous stories of different merit and point. He
seldom indulges in simile. He says sharp and piquant things in a
quiet unassuming manner; and unless the reader is quite on the
alert, he may miss some very happy remark couched in a few
pregnant words. For instance: he says on the subject of Profession
not Practice, that Christ lived thirty-three years on earth, and He did
many great works; but we know of only one sermon that He
preached. The arms are long, the tongue is short; the hands are
free, the tongue confined behind the prison bars of the teeth; to
teach us that we should work freely, but talk little. Those who
profess great things and practise little what they profess are in a bad
spiritual condition; the clock whose hand stands at one whilst the
clapper goes twelve, is wrong in the works.
The stories Coster tells are very unequal. There is one delightful
mediæval tale reproduced by him which I shall venture to relate, as
it is full of beauty, and inculcates a wholesome lesson. There is a
ballad in German on the subject, to be found in Pocci and Göres’
Fest Kalender, which has been translated into English and published
in some Roman children’s books.
The story was, I believe, originated by Anthony of Sienna, who
relates it in his Chronicle of the Dominican Order; and it was from
him that the preachers and writers of the Middle Ages drew the
incident. With the reader’s permission I will tell the story in my own
words, instead of giving the stiff and dry record found in Coster.
There was once a good priest who served a church in Lusitania;
and he had two pupils, little boys, who came to him daily to learn
their letters, and to be instructed in the Latin tongue.
Now these children were wont to come early from home, and to
assist at mass, before ever they ate their breakfast or said their
lessons. And thus was each day sanctified to them, and each day
saw them grow in grace and in favour with God and man.
These little ones were taught to serve at the Holy Sacrifice, and
they performed their parts with care and reverence. They knelt and
responded, they raised the priest’s chasuble and kissed its hem, they
rang the bell at the sanctus and the elevation; and all they did, they
did right well.
And when mass was over, they extinguished the altar lights, and
then taking their little loaf and can of milk, retired to a side chapel
for their breakfast.
One day the elder lad said to his master—
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like