100% found this document useful (1 vote)
20 views

The Definitive Guide to AdonisJs: Building Node.js Applications with JavaScript Christopher Pitt - The ebook is available for online reading or easy download

The document promotes the ebook collection available at textbookfull.com, featuring titles such as 'The Definitive Guide to AdonisJs' by Christopher Pitt and 'JavaScript: The Definitive Guide' by David Flanagan. It provides links to various programming and web development resources, encouraging users to download ebooks in multiple formats. Additionally, it includes information about the structure and content of the 'Definitive Guide to AdonisJs', outlining chapters that cover installation, routing, views, and more.

Uploaded by

ngilekeka
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
100% found this document useful (1 vote)
20 views

The Definitive Guide to AdonisJs: Building Node.js Applications with JavaScript Christopher Pitt - The ebook is available for online reading or easy download

The document promotes the ebook collection available at textbookfull.com, featuring titles such as 'The Definitive Guide to AdonisJs' by Christopher Pitt and 'JavaScript: The Definitive Guide' by David Flanagan. It provides links to various programming and web development resources, encouraging users to download ebooks in multiple formats. Additionally, it includes information about the structure and content of the 'Definitive Guide to AdonisJs', outlining chapters that cover installation, routing, views, and more.

Uploaded by

ngilekeka
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/ 61

Explore the full ebook collection and download it now at textbookfull.

com

The Definitive Guide to AdonisJs: Building Node.js


Applications with JavaScript Christopher Pitt

https://textbookfull.com/product/the-definitive-guide-to-
adonisjs-building-node-js-applications-with-javascript-
christopher-pitt/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

The Definitive Guide to JSF in Java EE 8: Building Web


Applications with JavaServer Faces Bauke Scholtz

https://textbookfull.com/product/the-definitive-guide-to-jsf-in-java-
ee-8-building-web-applications-with-javaserver-faces-bauke-scholtz/

textbookfull.com

Ultimate Node.js for Cross-Platform App Development: Learn


to Build Robust, Scalable, and Performant Server-Side
JavaScript Applications with Node.js (English Edition)
Kumar
https://textbookfull.com/product/ultimate-node-js-for-cross-platform-
app-development-learn-to-build-robust-scalable-and-performant-server-
side-javascript-applications-with-node-js-english-edition-kumar/
textbookfull.com

JavaScript The Definitive Guide 7th Edition David Flanagan

https://textbookfull.com/product/javascript-the-definitive-guide-7th-
edition-david-flanagan/

textbookfull.com

Building web and mobile ArcGIS Server applications with


JavaScript Lewin

https://textbookfull.com/product/building-web-and-mobile-arcgis-
server-applications-with-javascript-lewin/

textbookfull.com
Guide to Scientific Computing in C Pitt-Francis

https://textbookfull.com/product/guide-to-scientific-computing-in-c-
pitt-francis/

textbookfull.com

Understanding ECMAScript 6 The definitive guide for


Javascript developers 1st Edition Nicholas C. Zakas

https://textbookfull.com/product/understanding-ecmascript-6-the-
definitive-guide-for-javascript-developers-1st-edition-nicholas-c-
zakas/
textbookfull.com

Practical Bot Development: Designing and Building Bots


with Node.js and Microsoft Bot Framework Szymon Rozga

https://textbookfull.com/product/practical-bot-development-designing-
and-building-bots-with-node-js-and-microsoft-bot-framework-szymon-
rozga/
textbookfull.com

Pentesting Azure Applications The Definitive Guide to


Testing and Securing Deployments 1st Edition Matt Burrough

https://textbookfull.com/product/pentesting-azure-applications-the-
definitive-guide-to-testing-and-securing-deployments-1st-edition-matt-
burrough/
textbookfull.com

Guide to Scientific Computing in C 2nd Edition Joe Pitt-


Francis

https://textbookfull.com/product/guide-to-scientific-computing-
in-c-2nd-edition-joe-pitt-francis/

textbookfull.com
The Definitive
Guide to AdonisJs
Building Node.js Applications with JavaScript

Christopher Pitt
The Definitive Guide to
AdonisJs
Building Node.js Applications
with JavaScript

Christopher Pitt
The Definitive Guide to AdonisJs: Building Node.js Applications with JavaScript
Christopher Pitt
Cape Town, Western Cape, South Africa

ISBN-13 (pbk): 978-1-4842-3389-4 ISBN-13 (electronic): 978-1-4842-3390-0


https://doi.org/10.1007/978-1-4842-3390-0
Library of Congress Control Number: 2018937100

Copyright © 2018 by Christopher Pitt


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image, we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
[email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and
the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM
Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected]; for reprint, paperback, or audio rights,
please email [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484233894. For more
detailed information, please visit www.apress.com/source-code.
Printed on acid-free paper
Table of Contents
About the Author����������������������������������������������������������������������������������������������������� ix

Acknowledgments��������������������������������������������������������������������������������������������������� xi
Introduction����������������������������������������������������������������������������������������������������������� xiii

Chapter 1: Getting Started���������������������������������������������������������������������������������������� 1


Installing Node.js��������������������������������������������������������������������������������������������������������������������������� 1
Installing the AdonisJs Command-Line Tool��������������������������������������������������������������������������������� 3
Creating a New Application����������������������������������������������������������������������������������������������������������� 3
Serving the Application����������������������������������������������������������������������������������������������������������������� 4
Exploring the Code������������������������������������������������������������������������������������������������������������������������ 5
Summary������������������������������������������������������������������������������������������������������������������������������������ 10

Chapter 2: Routing�������������������������������������������������������������������������������������������������� 11
What Are Routes?������������������������������������������������������������������������������������������������������������������������ 11
Planning Routes�������������������������������������������������������������������������������������������������������������������������� 12
Defining Routes��������������������������������������������������������������������������������������������������������������������������� 14
Testing Routes���������������������������������������������������������������������������������������������������������������������������� 15
Defining Route Parameters��������������������������������������������������������������������������������������������������������� 20
Summary������������������������������������������������������������������������������������������������������������������������������������ 26

Chapter 3: Views���������������������������������������������������������������������������������������������������� 27
Creating Views���������������������������������������������������������������������������������������������������������������������������� 27
Registering the View Provider����������������������������������������������������������������������������������������������� 28
Creating Layouts������������������������������������������������������������������������������������������������������������������������� 29
Learning Template Syntax����������������������������������������������������������������������������������������������������������� 34
Interpolation�������������������������������������������������������������������������������������������������������������������������� 35

iii
Table of Contents

Conditionals��������������������������������������������������������������������������������������������������������������������������� 36
Loops������������������������������������������������������������������������������������������������������������������������������������� 37
Partials���������������������������������������������������������������������������������������������������������������������������������� 38
Yield��������������������������������������������������������������������������������������������������������������������������������������� 38
Functions������������������������������������������������������������������������������������������������������������������������������� 39
Summary������������������������������������������������������������������������������������������������������������������������������������ 40

Chapter 4: Requests����������������������������������������������������������������������������������������������� 41
Updating Tests����������������������������������������������������������������������������������������������������������������������������� 41
Understanding Requests������������������������������������������������������������������������������������������������������������� 47
Getting Parameters���������������������������������������������������������������������������������������������������������������� 49
Getting Headers and Cookies������������������������������������������������������������������������������������������������ 50
Getting “accepts” and “language”���������������������������������������������������������������������������������������� 50
Finding Out More������������������������������������������������������������������������������������������������������������������� 51
Responding to POST, PUT, PATCH, and DELETE���������������������������������������������������������������������� 51
Summary������������������������������������������������������������������������������������������������������������������������������� 59

Chapter 5: Responses��������������������������������������������������������������������������������������������� 61
Sending Simple Responses�������������������������������������������������������������������������������������������������������� 61
Sending JSON Responses����������������������������������������������������������������������������������������������������������� 62
Working with Cookies����������������������������������������������������������������������������������������������������������������� 64
Redirecting Users������������������������������������������������������������������������������������������������������������������������ 64
Responding with Attachments���������������������������������������������������������������������������������������������������� 66
Extending with Macros��������������������������������������������������������������������������������������������������������������� 66
Summary������������������������������������������������������������������������������������������������������������������������������������ 70

Chapter 6: Generators��������������������������������������������������������������������������������������������� 71
Arrays: Where It All Began����������������������������������������������������������������������������������������������������������� 71
Then Came Iterators�������������������������������������������������������������������������������������������������������������������� 72
Generators���������������������������������������������������������������������������������������������������������������������������������� 75
Cooperative Multitasking������������������������������������������������������������������������������������������������������������ 76
Summary������������������������������������������������������������������������������������������������������������������������������������ 79

iv
Table of Contents

Chapter 7: Promises����������������������������������������������������������������������������������������������� 81
Reacting to Events���������������������������������������������������������������������������������������������������������������������� 81
Entering Callback Hell����������������������������������������������������������������������������������������������������������������� 82
Understanding Promises������������������������������������������������������������������������������������������������������������� 83
Using Promises with Coroutines������������������������������������������������������������������������������������������������� 84
Making Promises������������������������������������������������������������������������������������������������������������������������ 86
Bringing It Back to AdonisJs������������������������������������������������������������������������������������������������������� 88
Summary������������������������������������������������������������������������������������������������������������������������������������ 89

Chapter 8: Controllers and Middleware������������������������������������������������������������������ 91


Making Controllers���������������������������������������������������������������������������������������������������������������������� 91
Reusing Code������������������������������������������������������������������������������������������������������������������������������ 96
Using Middleware����������������������������������������������������������������������������������������������������������������������� 97
Summary���������������������������������������������������������������������������������������������������������������������������������� 101

Chapter 9: Databases������������������������������������������������������������������������������������������� 103


Installing Lucid�������������������������������������������������������������������������������������������������������������������������� 103
Making Migrations�������������������������������������������������������������������������������������������������������������������� 107
Seeding the Database��������������������������������������������������������������������������������������������������������������� 111
Working with Routes and the Database������������������������������������������������������������������������������������ 115
Showing Products��������������������������������������������������������������������������������������������������������������������� 116
Making Models�������������������������������������������������������������������������������������������������������������������������� 118
Registering Customers�������������������������������������������������������������������������������������������������������������� 121
Authenticating Customers��������������������������������������������������������������������������������������������������������� 125
Summary���������������������������������������������������������������������������������������������������������������������������������� 127

Chapter 10: Validation and Errors������������������������������������������������������������������������ 129


Installing Validation������������������������������������������������������������������������������������������������������������������� 129
Reusing Validation��������������������������������������������������������������������������������������������������������������������� 133
Displaying Custom Error Pages������������������������������������������������������������������������������������������������� 140
Creating Custom Exceptions����������������������������������������������������������������������������������������������������� 144
Summary���������������������������������������������������������������������������������������������������������������������������������� 146

v
Table of Contents

Chapter 11: Sessions�������������������������������������������������������������������������������������������� 147


Making the Dashboard�������������������������������������������������������������������������������������������������������������� 147
Creating the Customer Session������������������������������������������������������������������������������������������������� 154
Logging Customers Out������������������������������������������������������������������������������������������������������������� 158
Summary���������������������������������������������������������������������������������������������������������������������������������� 161

Chapter 12: Security��������������������������������������������������������������������������������������������� 163


Recap���������������������������������������������������������������������������������������������������������������������������������������� 163
Creating More Middleware�������������������������������������������������������������������������������������������������������� 164
Securing Forms������������������������������������������������������������������������������������������������������������������������� 168
Encrypting Values��������������������������������������������������������������������������������������������������������������������� 171
Summary���������������������������������������������������������������������������������������������������������������������������������� 172

Chapter 13: Front-End Tools��������������������������������������������������������������������������������� 173


Installing Mix����������������������������������������������������������������������������������������������������������������������������� 173
Installing Bootstrap (Sass)�������������������������������������������������������������������������������������������������������� 177
Installing React������������������������������������������������������������������������������������������������������������������������� 179
Summary���������������������������������������������������������������������������������������������������������������������������������� 182

Chapter 14: WebSockets��������������������������������������������������������������������������������������� 183


Installing Socket.io�������������������������������������������������������������������������������������������������������������������� 183
Building a React Shopping Cart������������������������������������������������������������������������������������������������ 189
Connecting the UI���������������������������������������������������������������������������������������������������������������������� 197
Creating Orders������������������������������������������������������������������������������������������������������������������������� 201
Summary���������������������������������������������������������������������������������������������������������������������������������� 205

Chapter 15: Deployment�������������������������������������������������������������������������������������� 207


Setting Up DigitalOcean������������������������������������������������������������������������������������������������������������ 208
Setting Up Forge����������������������������������������������������������������������������������������������������������������������� 209
Getting a Domain���������������������������������������������������������������������������������������������������������������������� 211
Adding the Domain Name in Forge������������������������������������������������������������������������������������������� 213
Setting Up DNS Servers������������������������������������������������������������������������������������������������������������ 215
Adding a Server Daemon���������������������������������������������������������������������������������������������������������� 216

vi
Table of Contents

Serving on Port 80�������������������������������������������������������������������������������������������������������������������� 220


Setting Up an SSL Certificate���������������������������������������������������������������������������������������������������� 221
Summary���������������������������������������������������������������������������������������������������������������������������������� 222

Chapter 16: Finishing Touches����������������������������������������������������������������������������� 223


Sending E-mail�������������������������������������������������������������������������������������������������������������������������� 223
Connecting to Stripe����������������������������������������������������������������������������������������������������������������� 230
Enabling CORS Requests���������������������������������������������������������������������������������������������������������� 238
Summary���������������������������������������������������������������������������������������������������������������������������������� 243

Index��������������������������������������������������������������������������������������������������������������������� 245

vii
About the Author
Christopher Pitt is a developer and writer working at Over. He usually works on
application architecture, though sometimes you’ll find him building compilers or robots.
He is also the author of several web development books and is a contributor on various
open source projects such as AdonisJs.

ix
Acknowledgments
Many people helped to make this book a reality. I’d like to thank them, in no
particular order.
Harminder and the rest of the core team have written some beautiful software.
I am continually amazed by how beautiful AdonisJs code can look. I enjoy JavaScript,
and it seems particularly suited to a framework like this. Harminder also gave insightful
technical feedback for this book.
Taylor began a wonder with Laravel. It’s clear that much of AdonisJs is inspired by
Laravel, and with good reason. Laravel kept me engaged in PHP, and AdonisJs will keep
me engaged in server-side JavaScript.
Mark, the coordinating editor, was fantastic to work with. He never got in the way
and was always helpful. That’s uncommon in his line of work. Matt, the development
editor, was similarly helpful and let me set the vision for this project, unencumbered.
These folks are a credit to Apress.
Matt, the writer, is an inspiration to me. He wrote what I consider to be the best
Laravel book on the market. Throughout this book, I sought to emulate his wisdom and
skill.
Bruno, Christian, and Wayne are good friends and supporters of my work. I miss
writing for Bruno. I miss having coffee with Christian. I will miss taking walks with
Wayne.
Liz, my love, has given me space and coffee in abundance. She is the inspiration
for the sample application, and though she finds me altogether strange, she loves me
effortlessly.

xi
Introduction
This book is designed to teach you how to use AdonisJs. To get the most out of it, you
should have a firm grasp of modern JavaScript and some knowledge of how to work with
relational databases and the command line.
I explain new and interesting bits of syntax, but this book isn’t primarily about
teaching you how to use JavaScript. It’s about teaching you how to build real applications
by using AdonisJs.
The application we’re going to build is called Threadbear. It’s a play on words,
meant to conjure up thoughts of patchy, knitted teddy bears. We’re going to make an
application through which sellers can register and upload their knitted patterns and
products. Customers will then be able to register and purchase these things.
We’re not going to focus much on design. Instead, we’re going to focus on the
mechanics of commerce applications. Beyond adding a CSS framework, everything is as
the good browser vendors intended. That said, I welcome you to add your own style to
the application
We’ll create a secure registration and login system. We’ll add profile and product
management. We’ll connect the front end to the back end by using WebSockets and
the Fetch API. We’ll design a shopping cart in React and we’ll package static files with a
custom build chain. Finally, we’ll learn how to deploy the application to a virtual server,
and install custom domains and SSL certificates.
It is my hope that by the time you are finished reading this book, you’ll know all you
need to know in order to build your online business.

xiii
CHAPTER 1

Getting Started
Deciding where to start is often the hardest part, don’t you find? In this chapter, we’re
going to get our development tools set up. We’re also going to create a new AdonisJs
application. We’ll finish up by taking a look at the folders of our application and making
a few small customizations.

Note Complex and exhaustive installation instructions are one of the easiest
ways to age a book. I’m not going to belabor the steps for every operating system
and configuration. I’m guessing you know enough about Google to find the help
you need. If you get stuck, ask me for help on Twitter (https://twitter.com/
assertchris) or e-mail ([email protected]).

I nstalling Node.js
As the name implies, AdonisJs is a JavaScript framework. There have been a few
runtimes for JavaScript on the server, but the clear winner is Node.js (https://nodejs.
org/en). You can see what the Node.js web site looks like in Figure 1-1. The latest version
of AdonisJs requires Node 8.0 or newer. That’s because it uses new language features to
make writing code easier and more expressive. We’ll learn about those later.
Node.js is relatively painless to install, despite its size and intricacy. On macOS, you
can run the following:

brew install node

And on Debian or Ubuntu, you can run this:

apt-get install node

1
© Christopher Pitt 2018
C. Pitt, The Definitive Guide to AdonisJs, https://doi.org/10.1007/978-1-4842-3390-0_1
Chapter 1 Getting Started

Note Alternatively, you can install Node.js from a binary at https://nodejs.


org/en/download. There are installers for Windows, so you don’t have to use
macOS or Debian if you don’t want to.

You can check that Node.js is correctly installed by running the following:

node -v
npm -v

Figure 1-1. The Node.js web site

2
Chapter 1 Getting Started

Installing the AdonisJs Command-Line Tool


Setting up a new AdonisJs application requires quite a few steps. Fortunately, there’s a
tool to perform all of those steps for us. We need to install that tool, which also will help
us to create all future AdonisJs applications:

npm install --global @adonisjs/cli

This installs the command-line tool globally, which means we’ll be able to use it
from anywhere on our system. Similarly to the way we check Node.js, we can check to
see whether this tool has been successfully installed by running the following:

adonis --help

This also gives as a sneak peek at the kinds of things we can start to do to an
application. Various commands are available, from creating and running applications to
adding new functionality in existing applications.
For now, we’re just going to create a new AdonisJs application.

Creating a New Application


If you read through the output of that help command, you may have noticed the new
command. It’s what we’re going to use to create a new application:

adonis new threadbear

It’ll take a minute or two to fully install and configure the new application. The
only step I want to talk about for the moment is “generated unique APP_KEY.” AdonisJs
applications have an .env configuration file, which we can use to store sensitive
configuration variables. One of these is called APP_KEY, which is a private key unique to
the application.
Whenever text is encrypted or hashed, this value is used to seed the operation. The
same password, when hashed in two applications (with different APP_KEY values), will
result in different hashes. This is important to know because at times you might need to
compare hashes or decrypt values that have been generated using a different APP_KEY
than the one the command-line tool just made for you.

3
Chapter 1 Getting Started

Note It’s possible to reuse an APP_KEY in multiple applications, but it’s definitely
not recommended. Sharing an APP_KEY should be done only in exceptional
situations and for a limited amount of time. If you reuse keys, you’re increasing the
likelihood that all the applications reusing the key are compromised at the same time.

S
 erving the Application
Now that we’ve created an application, we need a way to view it in the browser. Some
server-side languages use third-party web servers (such as Nginx or Apache) as a kind of
load balancer. PHP and Perl are examples of this.
Things work a bit differently with server-side JavaScript. The foundational example
of how to use Node.js (https://nodejs.org/en/docs/guides/getting-started-guide)
demonstrates how we can make our own HTTP server:

const http = require("http")

const hostname = "127.0.0.1"


const port = 3333

const server = http.createServer((req, res) => {


    res.statusCode = 200
    res.setHeader("Content-Type", "text/plain")
    res.end("hello world")
})

server.listen(port, hostname, () => {


    // server is now running
})

This is quite similar to what AdonisJs does under the hood. This means our server(s)
need to keep the Node.js HTTP script running as what is usually referred to as a daemon.
We’ll unpack that later, but for now we’ll need to make sure adonis serve is running
while we code.
As the message when we run adonis serve --dev says, we can see the new application
by loading 127.0.0.1:3333 in a web browser. We can see what this looks like in Figure 1-2.

4
Chapter 1 Getting Started

Figure 1-2. A new AdonisJs application

E xploring the Code


New AdonisJs applications are as slim as the repository’s name on which they are based.1
They look something like this:

threadbear
↳ node_modules
↳ public
↳ start
↳ .env
↳ .env.example
↳ .gitignore

1
https://github.com/adonisjs/adonis-slim-app

5
Chapter 1 Getting Started

↳ ace
↳ package.json
↳ server.js

As usual, NPM (or Node Package Manager) dependencies are stored in the node_
modules folder. When we run adonis serve --dev, it’s doing little more than running
node server.js.
Static files, such as client-side stylesheets and scripts, are usually placed in the
public folder. More complex applications tend to have build chains, which take source
stylesheets and scripts and combine/compress them into smaller production versions.
AdonisJs favors convention over configuration. This means that it is designed to be
useful out of the box. Sometimes we might need to deviate from the standard configuration.
In new applications, we can do that by customizing the files in the start folder.
Let’s make a few customizations to the application. We’re going to learn about routes
in a while, but we’ll add one in the meantime. The starting routes file resembles Listing 1-1.

Listing 1-1. This is from threadbear/start/routes.js

"use strict"

const Route = use("Route")

Route.get("/", ({ request }) => {


    return "...some html"
})

See that Route.get? We’re going to add another, as shown in Listing 1-2.

Listing 1-2. This is from threadbear/start/routes.js

Route.get("/register", () => {
    return "...form for customers to make new profiles"
})

For now, restart the serve command and go to the address you see in the terminal
window. We can see the text we entered: text that we’re returning from the route, matching
the /register path we specified.
Larger applications require more files than just the ones we have currently. You may
remember that the adonis --help command suggested quite a few make commands.

6
Chapter 1 Getting Started

We can use these to create any number of project files. Though we’re also going to learn
about them later, let’s create a controller:

adonis make:controller PageController

This creates a nested folder structure: app ➤ Controllers ➤ Http ➤


PageController.js.
Similarly, the other make commands usually put the files they create in the app folder,
and create more nested folders if they don’t already exist. There’s quite a rich structure
built up as needed. The pattern is always the same, leading back to the convention-over-­
configuration paradigm.

Note The command-line tools create files in a predictable location. That’s not
to say that we couldn’t change the position and name of these files—just that by
default, they will always be in a predictable configuration.

Let’s make a new command so we can explore more of the starter configuration:

adonis make:command SendReminderCommand

This command creates a new command-line command class, located in app ➤


Commands ➤ SendReminder.js. It automatically strips the Command suffix and gives some
help for how to add the command to Ace.
Ace is a local version of the adonis global command-line helper. We can run it with
the following:

node ace

The output is similar to (though much less than) that of adonis --help. These
commands are similarly built, but the global adonis command has more subcommands
registered within it. ace has only the commands registered for your app.
Sometimes it’s easier not to have to specify that you want to run the command by
using node. In that case, we can make the Ace script executable:

chmod +x ace

7
Chapter 1 Getting Started

We also need to add a hash-bang (#!) to the top of the Ace script, as in Listing 1-3.

Listing 1-3. This is from threadbear/ace

#!/usr/bin/env node

"use strict"

// ...other code

Now we can run Ace by using the following:

./ace

It’s not a huge improvement, but it is an interesting technique to be aware of. Hash-­
bang directives (like this one) can be useful for hiding unnecessary details, such as the
binary we need to run a script, so that these kinds of stand-alone scripts are easier for
others to use.
We’re going to use this trick later, when we work out how to restart the server with
a new routing configuration. In the meantime, let’s follow the advice we received when
we created the command. Let’s change start/app.js to include the new command, as
shown in Listing 1-4.

Listing 1-4. This is from threadbear/start/app.js

// ...other code

const commands = [
    "App/Commands/SendReminder"
]

module.exports = {
    providers, aceProviders, aliases, commands
}

The command code Ace generated resembles Listing 1-5.

Listing 1-5. This is from threadbear/app/Commands/SendReminder.js


"use strict"

const { Command } = require("@adonisjs/ace")

8
Chapter 1 Getting Started

class SendReminder extends Command {


    static get signature() {
        return "send:reminder"
    }

    static get description() {


        return "..."
    }

    async handle(args, options) {


        this.info("...")
    }
}

module.exports = SendReminder

SendReminder extends the built-in Command class. Command does most of the heavy
lifting, but it does require a few properties/getters to be defined:
signature is the name by which the command will be called, but also the arguments
and extra parameters the command accepts.
description is useful when we run ./ace --help. It shows what the command does
and describes what the arguments and parameters are for.
handle is where we put all the code this command needs to use. We’re going to use it
to send reminder e-mails to our customers, but for now it can log text to the console.
We can see the results of this code in Figure 1-3.

Figure 1-3. The output of ./ace send:reminder

9
Chapter 1 Getting Started

Summary
In this chapter, we installed all the requirements for AdonisJs. We created a new
application, and learned how routes and shared code (such as Ace commands) can be
configured in the files within the start folder.
We’ve touched lightly on a few parts of the AdonisJs application structure. In the next
chapter, we’re going to learn far more about defining application routes.

10
CHAPTER 2

Routing
In the previous chapter, we set up our environment and got our first look at the structure
of an AdonisJs application. Now it’s time to add HTTP endpoints to the application. This
is done by adding routes. We’ll learn about all the ways to customize routes, use the data
they hold, and respond to any request.

What Are Routes?


Routes are like glue between the HTTP requests your browser makes and the server code
meant for each request. This isn’t the first time we’re seeing them, either. In the previous
chapter, we created a /registration route (though we didn’t do any meaningful work
through it).
Routes are an essential part of every application, because every application has at
least one of them. In fact, applications can have many routes, and you’re not limited in
the length, complexity, or number of them your application can have.
The Web is built on top of a communications protocol called HTTP. It has quite a lengthy
definition, but the important bits describe how browsers (and other clients) can make text-
based requests to servers. Those requests include details such as the type of request being
made (the request method) and the server address to which the requests should be sent.
Let’s take another look at the route we defined in the previous chapter, in Listing 2-1.

Listing 2-1. This is from threadbear/start/routes.js

Route.get("/register", () => {
  return "...form to make new profiles"
})

11
© Christopher Pitt 2018
C. Pitt, The Definitive Guide to AdonisJs, https://doi.org/10.1007/978-1-4842-3390-0_2
Chapter 2 Routing

We can tell a couple of things about this route, even if we remove all the code inside
() => {...}. The first is that this route responds to GET requests. There are other kinds
of requests, such as POST, PUT, DELETE, and HEAD. The second thing we can tell is that the
request should go to /register.
Routes can also have values embedded in the path, as we’ll see in this chapter.

Planning Routes
We’re going to define a few more customer routes alongside the /registration route we
already defined. Customers will need these to manage their accounts and gain access to
protected profile and product information:

• GET /login: GET is the most common request method on the


Internet. It’s the go-to method for fetching information in a read-only
way. Similarly to the way we used GET to show the registration form,
we’re using it here to show the login form.

• POST /login: POST is more common than GET when it comes to


creating things. In this case, we’d be creating new customer sessions
(and getting back security tokens). It’s not crucial to understand how
we do that right now. All you need to know is that we want to use
POST because we’re making something.

• PUT /logout: PUT is similar to POST in that it’s used for a write
operation. However, whereas POST is often used to indicate that a
whole new thing is being created, PUT is often used to indicate that a
change is being made to something. As you’ll see, we use PUT when
we want to update something that has already been created.

• POST /register: We already have a route for showing the


registration, but this one is for creating a new customer profile.
Notice that we use the POST method, as we’re creating a whole new
customer account.

• GET /forgot-password: When customers forget or lose their


passwords, we need a way for them to request to set a new one. The
only practical way for us to allow this is to send an e-mail to their
address on record, which contains a link (and security token) they can
click. This endpoint should show users a form with which to do that.
12
Chapter 2 Routing

• POST /forgot-password: After the customer has entered their e-mail


address, the form should be posted to this endpoint. The server code
running here will then send them the e-mail. You should start to see
a pattern here: we use GET to show forms, and POST to create new
things from those forms.

• GET /reset-password/{token}: Similarly to the way the customer


requests to set a new password, this endpoint shows the form they
can use to enter a new password. It has an added {token} parameter,
which we’ll learn about shortly.

• PUT /reset-password/{token}: After the customer has entered a


new password, the form can be posted to this endpoint. Because the
customer’s profile already exists (and we want to make an update to
it), we use the PUT request method.

• GET /{user-name}: After the customer has a profile, we want them


to be able to see what information is visible on it. This is where the
customer will see their protected information, and where other
customers will be able to see details marked as open to the public.

• PUT /{user-name}: Should the customer wish to change details


about their account, they would be able to do so through forms that
send their data to this endpoint. Because it’s a partial update, we use
the PUT method.

• DELETE /{user-name}: Customers should also be able to delete


their profiles, which is a good opportunity for us to use the DELETE
method. It acts a lot like the GET method, except that it is not read-­
only. Deletes are serious business, so we should confirm whether the
customer initiated the process by accident or on purpose.

• GET /{user-name}/products: In our design, customers are also


sellers. They’ll be able to create new products (which is an entirely
optional part of their experience), and those products will be
accessible through this endpoint.

• POST /{user-name}/products: Should the customer want to create


a new product, they’ll be able to do so via this endpoint. Because
they’re creating a whole new product, we use the POST method.

13
Chapter 2 Routing

• GET /{user-name}/{product-name}: If a customer wants to find out


more details about a specific product, they will be able to do so by
using this product-specific, customer-specific endpoint.

• PUT /{user-name}/{product-name}: Similarly, if a customer wants


to update the details of a product, they should be able to do so via a
PUT request to the same endpoint. It’s a partial update, or else we’d
use the POST method.

• DELETE /{user-name}/{product-name}: Finally, if a customer wants


to delete a product, they should use the DELETE request method on
this endpoint.

Note There’s a fine line between respecting a seller’s desire for privacy and
other customers’ right to access content they’ve purchased. It is right for us to
immediately delete products and customer profiles at the will of the customer. It’s
also important for us to preserve the ability to download purchased content after
a profile has been deleted or a product removed from sale. We’ll cross this bridge
when we get to it, but it’s important to remember these rights and responsibilities
when we design the application.

D
 efining Routes
Now that we’ve planned the routes we’ll begin our application with, it’s time to define
them in code. We’ll begin with the profile routes, shown in Listing 2-2.

Listing 2-2. This is from threadbear/start/routes.js

Route.get("/login", () => {
  // show login form
  return "GET /login"
})

Route.post("/login", () => {
  // create new customer session

14
Chapter 2 Routing

  return "POST /login"


})

Route.put("/logout", () => {
  // expire current customer session
  return "PUT /logout"
})

Route.get("/register", () => {
  // show registration form
  return "GET /register"
})

Route.post("/register", () => {
  // create new customer profile
  return "POST /register"
})

Route.get("/forgot-password", () => {
  // show forgot password form
  return "GET /forgot-password"
})

Route.post("/forgot-password", () => {
  // create new password reset token and send e-mail
  return "POST /forgot-password"
})

Each of these routes follows the pattern I just described. They will grow to contain
the functionality of the application, but in the meantime they just return strings. This is
immediately useful for testing, covered next.

Testing Routes
We’re going to take a brief detour from our route definitions to testing. This book has no
chapter dedicated to testing, because I believe it’s better to always be asking ourselves
how we plan to test the code we’re writing.

15
Chapter 2 Routing

There are many schools of thought when it comes to testing. I’m not going to dwell
on any of them (because we don’t have the time, and we need to stay focused), but I will
say that no one approach to testing is the best. Having any tests is better than having
none, and thinking about tests early and continuously has caused me to write better
code. I recommend this approach.
The jury is still out on which testing framework is the best. For now, we’re going to
use a framework called Mocha (https://mochajs.org). To install it, we need to run the
following command:

npm install --save-dev mocha

This gives us access to a few tools we can use for testing. Now let’s create a test file to
hold our first test, as shown in Listing 2-3.

Listing 2-3. This is from threadbear/test/routes.js

const assert = require("assert")


const http = require("http")

require("dotenv").config()

const shouldBeOk = (method, path, done) => {


  http
    .request(
      {
        host: process.env.HOST,
        port: process.env.PORT,
        method,
        path,
      },
      response => {
        assert.equal(200, response.statusCode)
        done()
      },
    )
    .end()
}

16
Chapter 2 Routing

const shouldHaveMessage = (
  method,
  path,
  message,
  done,
) => {
  http
    .request(
      {
        host: process.env.HOST,
        port: process.env.PORT,
        method,
        path,
      },
      response => {
        let data = ""

        response.on("data", chunk => {


          data += chunk
        })

        response.on("end", () => {
          assert.equal(message, data)
          done()
        })
      },
    )
    .end()
}

describe("GET /login", () => {


  it("should have the correct status (200)", done => {
    shouldBeOk("GET", "/login", done)
  })

  it("should have the correct message", done => {


    shouldHaveMessage(
      "GET",
17
Chapter 2 Routing

      "/login",
      "GET /login",
      done,
    )
  })
})

We begin by importing the assertions and HTTP libraries via require statements. We
also import the dotenv library and immediately call the config method. This loads all
the environment variables in our .env file so we can build a URL from the HOST and PORT
variables.
We follow this up by creating the shouldBeOk and shouldHaveMessage helper
functions. The first checks whether a request to an address returns a response with a 200
status code. This would indicate that the request returned successfully, which tells us
that the route is defined.
The shouldHaveMessage function tells us whether a request to an address returns a
message we expect. We’ve defined our routes to return simple messages that describe
their method and path, so we can use shouldHaveMessage to make sure the requests
match the messages we expect them to.
We’ve also defined our first set of tests using the describe and it functions. Mocha
provides these for us, so we don’t have to import them. We can duplicate these tests for
each route, as demonstrated in Listing 2-4.

Listing 2-4. This is from threadbear/test/routes.js

describe("POST /login", () => {


  it("should have the correct status (200)", done => {
    shouldBeOk("POST", "/login", done)
  })

  it("should have the correct message", done => {


    shouldHaveMessage(
      "POST",
      "/login",
      "POST /login",
      done,
    )

18
Other documents randomly have
different content
Though the occasions of high heroic daring seldom occur but in
the history of the great, the less obtrusive opportunities for the
exercise of private energy are continually offering themselves. With
these domestic scenes as much abound as does the tented field.
Pain may be as firmly endured in the lonely chamber as amid the din
of arms. Difficulties can be manfully combated, misfortune bravely
sustained, poverty nobly supported, disappointments courageously
encountered. Thus courage diffuses a wide and succoring influence,
and bestows energy apportioned to the trial. It takes from calamity
its dejecting quality, and enables the soul to possess itself under
every vicissitude. It rescues the unhappy from degradation and the
feeble from contempt.
The greater part of the courage that is needed in the world is not
of an heroic kind. There needs the common courage to be honest,
the courage to resist temptation, the courage to speak the truth, the
courage to be what we really are, and not to pretend to be what we
are not, the courage to live honestly within our own means, and not
dishonestly upon the means of others. The courage that dares to
display itself in silent effort and endeavor, that dares to endure all
and suffer all for truth and duty, is more truly heroic than the
achievements of physical valor, which are rewarded by honors and
titles, or by laurels, sometimes steeped in blood. It is moral courage
that characterizes the highest order of manhood and womanhood.
Intellectual intrepidity is one of the vital conditions of independence
and self-reliance of character. A man must have the courage to be
himself, and not the shadow or the echo of another. He must
exercise his own powers, think his own thoughts, and speak his own
sentiments. He must elaborate his own opinions, and form his own
convictions.
It has been said that he who dares not form an opinion must be a
coward; he who will not must be an idler; he who can not must be a
fool. Every enlargement of the domain of knowledge which has
made us better acquainted with the heavens, with the earth, and
with ourselves, has been established by the energy, the devotion,
the self-sacrifice, and the courage of the great spirits of past times,
who, however much they may have been oppressed or reviled by
their contemporaries, now rank among those whom the enlightened
of the human race most delight to honor.
The passive endurance of the man or woman who for conscience'
sake is found ready to suffer and endure in solitude, without so
much as the encouragement of even a single sympathizing voice, is
an exhibition of courage of a far higher kind than that displayed in
the roar of battle, where even the weakest feels encouraged and
inspired by the enthusiasm of sympathy and the power of numbers.
Time would fail to tell of the names of those who through faith in
principles, and in the face of difficulties, dangers, and sufferings,
have fought a good fight in the moral warfare of the world, and
been content to lay down their lives rather than prove false to their
conscientious convictions of the truth.
The patriot who fights an always losing battle, the martyr who
goes to death amid the triumphant shouts of his enemies, the
discoverer, like Columbus, whose heart remains undaunted through
years of failure, are examples of the moral sublime which excites a
profounder interest in the hearts of men than even the most
complete and conspicuous success. By the side of such instances as
these, how small by comparison seem the greatest deeds of valor,
inciting men to rush upon death and die amid the frenzied
excitement of physical warfare.
"The primal duties shine aloft like stars,
The charities that soothe and heal and bless
Lie scattered at the feet of man like flowers."
—Wordsworth.

HARITY, like the dew from heaven, falls gently on the


drooping flowers in the stillness of night. Its refreshing and
revivifying effects are felt, seen, and admired. It flows from a
good heart and looks beyond the skies for approval and reward. It
never opens, but seeks to heal, the wounds inflicted by misfortune.
It never harrows up, but strives to calm, the troubled mind.
Charity is another name for disinterested love—the humane,
sympathetic feeling—that which seeks the good of others; that
which would pour out from the treasures of its munificence gifts of
good things upon all. It is that feeling that gave the world a Howard,
a Fenelon, a Fry. It is that feeling that leads on the reformer, which
inspires the philanthropists, which blesses, and curses not. It is the
good Samaritan of the heart. It is that which thinketh no evil, and is
kind, which hopeth all things, believeth all things, endureth all
things. It is the angel of mercy, which forgives seventy and seven
times, and still is rich in the treasures of pardon. It visits the sick,
soothes the pillow of the dying, drops a tear with the mourner,
buries the dead, cares for the orphan. It delights to do offices of
good to those cast down, to relieve the suffering of the oppressed
and distressed, to proclaim the Gospel to the poor. Its words are
more precious than rubies; its voice is sweeter than honey; its hand
is softer than down; its step as gentle as love.
Whoever would be respected and beloved; whoever would be
useful and remembered with pleasure when life is over, must cherish
this virtue. Whoever would be truly happy and feel the real charms
of goodness must cultivate this affection. It becomes, if possible,
more glorious when we consider the number and extent of its
objects. It is as wide as the world of suffering, deep as the heart of
sorrow, extensive as the wants of creation, and boundless as the
kingdom of need. Its spirit is the messenger of peace, holding out to
quarreling humanity the flag of truce. It is needed every-where, in
all times and places, in all trades, professions, and callings of profit
or honor which men can pursue. In the home life there is too often a
lack of charity; it should be considered as a sacred duty to long and
well cultivate it, to exercise it daily, and to guard well its growth. The
peace and happiness of the world depends greatly upon it. Nothing
gives a sweeter charm to youth than an active charity, a disposition
kind to all. Who can properly estimate the powers and sweetness of
an active charity?
He who carries ever with him the spirit of boundless charity to
man often does good when he knows not of it. An influence seems
to go forth from him which soothes the distressed, encourages the
drooping, stimulates afresh the love of virtue, and begets its own
image and likeness in all beholders. Without the exercise of this
grace it is impossible to make domestic and social life delightful.
Deeds and words of conventional courtesy grown familiar are
comparatively empty forms. The charitable soul carries with it a
charmed atmosphere of peace and love, breathing which all who
come within its benign influence unfold their noblest qualities, and
develop their most amiable traits. Inharmonious influences are
neutralized, the harsh discipline of life is changed to wholesome
training, the crooked places are made straight, and the rough
smooth.
The uncharitable and censorious are generally found among the
narrow and bigoted, and those who have never read the full page of
their own heart or been subject to various and crucial tests. How can
a man whose temper is phlegmatic judge justly of him whose blood
is fiery, whose nature is tropical, and whose passions mount in an
instant, and as quickly subside? How can one in the seclusion of
private life accurately measure the force of the influence those are
subjected to who live and act in the center of vast and powerful civil
and social circles? The more you mix with men the less you will be
disposed to quarrel, and the more charitable and liberal will you
become. The fact that you do not understand another is quite as
likely to be your fault as his. There are many chances in favor of the
conclusion that when you feel a lack of charitable feeling it is
through your own ignorance and illiberality. This will disappear as
your knowledge of men grows more and more complete. Hence
keep your heart open for every body, and be sure that you shall
have your reward. You will find a jewel under the most uncouth
exterior, and associated with comeliest manners and the oddest
ways and the ugliest faces you will find rare virtues, fragrant little
humanities, and inspiring heroisms.
How glorious the thought of the universal triumph of charity! How
grand and comprehensive the theme! The subject commands the
profound attention of good men and of angels. Under the direful
influence of its antagonistic principle man has trampled upon the
rights of fellow-man, and waded through rivers of human blood, to
satisfy his thirst for vengeance. Its footsteps have been marked with
the blood of slaughtered millions. Its power has shivered kingdoms
and destroyed empires. When men shall be brought into subjection
to the law of charity the angel of peace will take up its abode with
the children of men. Wars and rumors of wars will cease. Envy and
revenge will hide their diminished heads. Falsehood and slander will
be unknown. Sectarian walls will crumble to dust. Then this world
will be transformed into a paradise, in which every thing that is
beautiful and lovely shall grow and bloom. Disinterested and
benevolent acts will abound. Sorrow and disappointments will flee
away, and peace, sunshine, and joy will beautify and adorn life.
Death always makes a beautiful appeal to charity. When we look
upon the dead form, so composed and still, the kindness and the
love that are in us all come forth. The grave covers every error,
buries every defect, extinguishes every resentment. From its
peaceful bosom spring none but fond regrets and tender
recollections. Who can look upon the grave even of an enemy and
not feel a compunctious throb that he should ever have warred with
the poor handful of dust that lies moldering before him?
Charity stowed away in the heart, like rose leaves in a drawer,
sweetens all the daily acts of life. Little drops of rain brighten the
meadow; acts of charity brighten the world. We can conceive of
nothing more attractive than the heart when filled with the spirit of
charity. Certainly nothing so embellishes human nature as the
practice of this virtue; a sentiment so genial and so excellent ought
to be emblazoned upon every thought and act of our life. This
principle underlies the whole theory of Christianity, and in no other
person do we find it more happily exemplified than in the life of our
Savior who, while on earth, "went about doing good."
INDNESS is the music of good-will to men, and on this harp
the smallest fingers in the world may play heaven's sweetest
tunes on earth. Kindness is one of the purest traits that find a
place in the human heart. It gives us friends wherever we
may chance to wander. Whether we dwell with the savage tribes of
the forest or with civilized races, kindness is a language understood
by the former as well as the latter. Its influence never ceases.
Started once, it flows onward like the little mountain rivulet in a pure
and increasing stream. To show kindness it is not necessary to give
large sums of money, or to perform some wonderful deed that will
immortalize your name. It is the tear dropped with the mother as
she weeps over the bier of her departed child; it is the word of
sympathy to the discouraged and the disheartened, the cup of cold
water and the slice of bread to the hungry one.
Kindness makes sunshine wherever it goes. It finds its way into
the hidden chambers of the heart, and brings forth golden treasures,
which harshness would have sealed up forever. Kindness makes the
mother's lullaby sweeter than the song of the lark, and renders the
care-worn brow of the father and man of business less severe in its
expression. It is the water of Lethe to the laborer, who straightway
forgets his weariness born of the burden and heat of the day.
Kindness is the real law of life, the link that connects earth with
heaven, the true philosopher's stone, for all it touches it turns into
virgin gold; the true gold, wherewith we purchase contentment,
peace, and love. Would you live in the remembrance of others after
you shall have passed away? Write your name on the tablets of their
hearts by acts of kindness, love, and mercy.
Kindness is an emotion of which we ought never to feel ashamed.
Graceful, especially in youth, is the tear of sympathy and the heart
that melts at the tale of woe. We should not permit ease and
indulgence to contract our affection, and wrap us up in a selfish
enjoyment; but we should accustom ourselves to think of the
distresses of human life and how to relieve them. Think of the
solitary cottage, the dying parent, and the weeping child. A tender-
hearted and compassionate disposition, which inclines men to pity
and to feel the misfortunes of others as its own, is of all dispositions
the most amiable, and though it may not receive much honor, is
worthy of the highest. Kindness is the very principle of love, an
emanation of the heart, which softens and gladdens, and should be
inculcated and encouraged in all our intercourse with our fellow
beings.
Kindness does not consist in gifts, but in gentleness and
generosity of spirit. Men may give their money, which comes from
their purse, and withhold their kindness, which comes from the
heart. The kindness which displays itself in giving money does not
amount to much, and often does quite as much harm as good; but
the kindness of true sympathy, of thoughtful help, is never without
beneficent results. The good temper that displays itself in kindness
must not be confounded with passive goodness. It is not by any
means indifferent, but largely sympathetic. It does not characterize
the lowest, but the highest classes of society.
True kindness cherishes and actively promotes all reasonable
instrumentalities for doing practical good in its own time, and,
looking into futurity, sees the same spirit working on for the eventual
elevation and happiness of the race. It is the kindly disposed men
who are the active men of the world, while the selfish and the
skeptical, who have no love but for themselves, are its idlers. How
easy it is for one benevolent being to diffuse pleasure around him,
and how truly is one fond heart a fountain of gladness, making every
thing in its vicinity to freshen into smiles. Its effect on stern natures
is like the Spring rain, which melts the icy covering of the earth, and
causes it to open to the beams of heaven.
In the intercourse of social life it is by little acts of watchful
kindness recurring daily and hourly—and opportunities of doing
kindness if sought for are constantly starting up—it is by words, by
tones, by gestures, by looks that affection is won and preserved. He
who neglects these trifles, yet boasts that, whenever a great
sacrifice is called for, he shall be ready to make it, will rarely be
loved. The likelihood is he will not make it, and if he does, it will be
much rather for his own sake than for his neighbor's. Life is made
up, not of great sacrifices or duties, but of little things, in which
smiles and kindness and small obligations, given habitually, are what
win and preserve the heart and secure comfort. The little
unremembered acts of kindness and of love are the best portion of a
good man's life. Those little nameless acts which manifest
themselves by tender and affectionate looks and little kind acts of
attention do much to increase the happiness of life.
Little kindnesses are great ones. They drive away sadness, and
cheer up the soul beyond all common appreciation. They are centers
of influence over others, which may accomplish much good. When
such kindnesses are administered in times of need, they are like
"apples of gold in pictures of silver," and will be long remembered. A
word of kindness in a desperate strait is as welcome as the smile of
an angel, and a helpful hand-grasp is worth a hundred-fold its cost,
for it may have rescued for all future the most kingly thing on earth
—the manhood of a man.
It should not discourage us if our kindness is unacknowledged; it
has its influence still. Good and worthy conduct may meet with an
unworthy or ungrateful return; but the absence of gratitude on the
part of the receiver can not destroy the self-approbation which
recompenses the giver. The seeds of courtesy and kindness may be
scattered around with so little trouble and expense that it seems
strange that more do not endeavor to spread them abroad. Could
they but know the inward peace which requites the giver for a kindly
act, even though coldly received by the one to be benefited, they
would not hesitate to let the kindly feelings, latent in us all, have
free expression. Kindly efforts are not lost. Some of them will
inevitably fall on good ground, and grow up into benevolence in the
minds of others, and all of them will bear fruit of happiness in the
bosom whence they spring. It is better never to receive a kindness
than not to bestow one. Not to return a benefit is the greater sin,
but not to confer it is the earlier.
The noblest revenge we can take upon our enemies is to do them
a kindness. To return malice for malice and injury for injury will
afford but a temporary gratification to our evil passions, and our
enemies will only be rendered more and more bitter against us. But
to take the first opportunity of showing how superior we are to them
by doing them a kindness, or by rendering them a service, is not
only the nobler way, but the sting of reproach will enter deeply into
their souls, and while unto us it will be a noble retaliation, our
triumph will not unfrequently be rendered complete, not only by
beating out the malice that had otherwise stood against us, but by
bringing repentant hearts to offer themselves at the shrine of
friendship. A more glorious victory can not be gained over another
man than this, that when the injury began on his part the kindness
should begin on ours.
The tongue of kindness is full of pity, love, and comfort. It speaks
a word of comfort to the desponding, a word of encouragement to
the faint-hearted, of sympathy to the bereaved, of consolation to the
dying. Urged on by a benevolent heart, it loves to cheer, console,
and invigorate the sons and daughters of sorrow. Kind words do not
cost much. They never blister the tongue or lips, and no mental
trouble ever arises therefrom. Be not saving of kind words and
pleasing acts; for such are fragrant gifts, whose perfume will
gladden the heart and sweeten the life of all who hear or receive
them. Words of kindness fitly spoken are indeed both precious and
beautiful; they are worth much and cost little.
Kind words are like the breath of the dew upon the tender plants,
falling gently upon the drooping heart, refreshing its withered
tendrils, and soothing its woes. Bright oases are they in life's great
desert. Who can estimate the pangs they have alleviated, or the
good works they have accomplished? Long after they are uttered do
they reverberate in the soul's inner chamber, and, like low, sweet
strains of music, they serve to quell the memory of bitterness or of
personal wrong, to lead the heart to the sunnier paths of life. And
when the heart is sad, and, like a broken harp, the chords of
pleasure cease to vibrate, how peculiarly acceptable then are kind
words from others!
Who can rightly estimate the ultimate effect of one kind word fitly
spoken? One little word of tenderness gushing in upon the soul will
sweep long-neglected chords and awaken the most pleasant strains.
Kind words are like jewels in the heart, never to be forgotten, but
perhaps to cheer by their memory a long, sad life, while words of
cruelty are like darts in the bosom, wounding and leaving scars that
will be borne to the grave by their victim. Speak kindly in the
morning; it lightens all the cares of the day, and makes the
household and other affairs move along more smoothly. Speak kindly
at night; for it may be that before dawn some loved one may finish
his or her space of life, and it will be too late to ask forgiveness.
Speak kindly at all times; it encourages the downcast, cheers the
sorrowing, and very likely awakens the erring to earnest resolves to
do better, with strength to keep them. Always leave home with kind
words; for they may be the last. Kind words are the bright flowers of
earthly existence; use them, and especially around the fireside circle.
They are jewels beyond price, and powerful to heal the wounded
heart, and make the weighed-down spirit glad.
OING good is the only certain happy action of a man's life.
The very consciousness of well-doing is in itself ample reward
for the trouble we have been put to. The enjoyment of
benevolent acts grows upon reflection. Experience teaches
this so truly, that never did any soul do good but he came
readier to do the same again with more enjoyment. Never was love
or gratitude or bounty practiced but with increasing joy, which made
the practicer more in love with the fair act.
If there be a pleasure on earth which angels can not enjoy, and
which they might almost envy man the possession of, it is the power
of relieving distress. If there be a pain which devils might almost pity
man for enduring, it is the death-bed reflection that we have
possessed the power of doing good, but that we have abused and
perverted it to purposed ill. He who has never denied himself for the
sake of giving has but glanced at the joys of benevolence. We owe
our superfluity, and to be happy in the performance of our duty we
must exceed it. The joy resulting from the diffusion of blessings to
all around us is the purest and sublimest that can ever enter the
human mind, and can be understood only by those who have
experienced it. Next to the consolation of divine grace it is the most
sovereign balm to the miseries of life, both in him who is the object
of it, and in him who exercises it.
In all other human gifts and possessions, though they advance
nature, yet they are subject to excess. For so we see, that by
aspiring to be like God in power, the angels transgressed and fell; by
aspiring to be like God in knowledge man transgressed and fell; but
by aspiring to be like God in goodness or love neither man nor
angels ever did or shall transgress, for unto that imitation we are
called. A life of passionate gratification is not to be compared with a
life of active benevolence. God has so constituted our natures that a
man can not be happy unless he is or thinks he is a means of doing
good. We can not conceive of a picture of more unutterable
wretchedness than is furnished by one who knows that he is wholly
useless in the world.
A man or woman without benevolence is not a perfect being; they
are only a deformed personality of true manhood or womanhood. In
every heart there are many tendencies to selfishness; but the spirit
of benevolence counteracts them all. In a world like this, where we
are all so needy and dependent, where our interests are so
interlocked, where our lives and hearts overlap each other and often
grow together, we can not live without a good degree of
benevolence. We do most for ourselves when we do most for others;
hence our highest interests, even from a purely selfish point of view,
are in the paths of benevolence. And in a moral sense we know "that
it is more blessed to give than to receive." Good deeds double in the
doing, and the larger half comes back to the donor. A large heart of
charity is a noble thing, and the most benevolent soul lives nearest
to God. Selfishness is the root of evil; benevolence is its cure. In no
heart is benevolence more beautiful than in youth; in no heart is
selfishness more ugly. To do good is noble; to be good is more
noble. This should be the aim Of all the young. The poor and the
needy should occupy a large place in their hearts. The sick and
suffering should claim their attention. The sinful and criminal should
awaken their deepest pity. The oppressed and downtrodden should
find a large place in their compassion.
Woman appears in her best estate in the exercise of benevolent
deeds. How sweet are her soothing words to the disconsolate! How
consoling her tears of sympathy to the mourning! How fresh her
spirit of hope to the discouraged! How balmy the breath of her love
to the oppressed! Man, too, appears in his best light and grandest
aspect when he appears as the practical follower of Him who went
about doing good. He who does these works of practical
benevolence is educating his moral powers in the school of earnest
and glorious life. He is laying the foundation for a noble and useful
career. He is planting the seeds of a charity that will grow to bless
and save the sufferings of our fellow-men.
Liberality consists less in giving profusely than in giving judiciously,
for there is nothing that requires so strict an economy as our
benevolence. Liberality, if spread over too large a surface, produces
no crop. If over one too small it exuberates in rankness and in
weeds. And yet it requires care to avoid the other extreme. It is
better to be sometimes mistaken than not to exercise charity at all.
Though we may chance sometimes to bestow our beneficence on
the unworthy it does not take from the merit of the act. It is not the
true spirit of charity which is ever rigid and circumspect, and which
always mistrusts the truth of the necessities laid open to it. Be not
frightened at the hard word, "impostor." "Cast thy bread upon the
waters." Some have unawares entertained angels.
A man should fear when he enjoys only what good he does
publicly, lest it should prove to be the publicity rather than the
charity that he loves. We have more confidence in that benevolence
which begins in the home and diverges into a large humanity than in
the world-wide philanthropy which begins at the outside and
converges into egotism. A man should, indeed, have a generous
feeling for the welfare of the whole world, and should live in the
world as a citizen of the world. But he may have a preference for
that particular part in which he lives. Charity begins at home, but it
may and ought to go abroad; still we have no respect for self-
boasting charity which neglects all objects of commiseration near
and around it, but goes to the end of the world in search of misery
for the sake of talking about it.
Generosity during life is a very different thing from generosity in
the hour of death. One proceeds from genuine liberality and
benevolence; the other from pride or fear. He that will not permit his
wealth to do any good to others while he is living prevents it from
doing any good to himself when he is gone. By an egotism that is
suicidal and has a double edge he cuts himself off from the truest
pleasures here, and the highest pleasures hereafter. To pass a whole
life-time without performing a single generous action till the dying
hour, when death unlocks the grasp upon earthly possessions, is to
live like the Talipat palm-tree of the East, which blossoms not till the
last year of its life. It then suddenly bursts into a mass of flowers,
but emits such an odor that the tree is frequently cut down to be rid
of it. Even such is the life of those who postpone their munificence
until the close of their days, when they exhibit a late efflorescence of
generosity, which lacks the sweet-smelling perfume which good
deeds should possess. And when it appears, like the Talipat flower, it
is a sure sign that death is at hand. They surrender every thing
when they see they can not continue to keep possession, and are at
last liberal when they can no longer be parsimonious. The truly
generous man does not wish to leave enough to build an imposing
monument, since there is so much sorrow and suffering to be
alleviated. They enjoy the pleasure of what they give by giving it
when alive and seeing others benefited thereby.
A conqueror is regarded with awe, the wise man commands our
esteem, but it is the benevolent man who wins our affection. A
beneficent person is like a fountain watering the earth and spreading
fertility; it is, therefore, more delightful and more honorable to give
than to receive. The last, best fruit which comes to late perfection,
even in the kindliest soul, is tenderness towards the hard,
forbearance towards the unforbearant, warmth of heart towards the
cold, philanthropy towards the misanthropic.
ERACITY, or the habitual observance of truth, is a bright and
shining quality on the part of any one who strives to make the
most of life's possibilities. It irradiates all of his surroundings,
making plain the path of duty, and hence the path which
leads to the most enduring success. It is the bond of union and the
basis of human happiness. Without this virtue, there is no reliance
upon language, no confidence in friendship, no security in promises
and oaths.
Truth is always consistent with itself, and needs nothing to help it
out. It is always near at hand, and sits upon our lips, and is ready to
drop out before we are aware; whereas a lie is troublesome, and
sets a man's invention upon the rack; and one trick needs many
more to make it good. It is dangerous to deviate far from the strict
rule of veracity, even on the most trifling occasions. However
guileless may be our intentions, the habit, if indulged, may take root,
and gain on us under the cover of various pretenses, till it usurps a
leading influence. Nothing appears so low and mean as lying and
dissimulation; and it is observable that only weak animals endeavor
to supply by craft the defects of strength which nature has given
them. Dissimulation in youth is the forerunner of perfidy in old age.
Its first appearance is the fatal omen of growing depravity and
future shame. It degrades parts and learning, obscures the luster of
every accomplishment, and sinks us into contempt.
The path of falsehood is a perplexing maze. After the first
departure from sincerity, it is not in our power to stop. One artifice
unavoidably leads on to another, till, as the intricacies of the
labyrinth increase, we are left entangled in our snare. Falsehood is
difficult to be maintained. When the materials of a building are solid
stone, very rude architecture will suffice; but a structure of rotten
materials needs the most careful adjustment to make it stand at all.
The love of truth and right is the grand spring source of integrity.
The study of truth is perpetually joined with the love of virtue. For
there is no virtue which derives not its original from truth; as, on the
contrary, there is no vice which has not its beginning in a lie. Truth is
the foundation of all knowledge and the cement of all society.
Strict veracity requires something more than merely the speaking
of truth. There are lying looks as well as lying words; dissembling
smiles, deceiving signs, and even a lying silence. Not to intend what
you speak is to give your heart the lie with your tongue; and not to
perform what you promise is to give your tongue the lie with your
actions. Deception exhibits itself in many forms—in reticency on the
one hand or exaggeration on the other; in disguise or concealment;
in pretended concurrence in others' opinions; in assuming an
attitude of conformity which is deceptive; in making promises, or in
allowing them to be implied, which are never intended to be
performed; or even in refraining from speaking the truth when to do
so is a duty. There are also those who are all things to all men, who
say one thing and do another. But those who are essentially
insincere fail to evoke confidence, and, in the end discover that they
have only deceived themselves while thinking they were deceiving
others.
Lying is in some cases the offspring of perversity and vice, and in
many others of sheer moral cowardice. Plutarch calls lying the vice
of a slave. There is no vice, says Lord Bacon, that so covers a man
with shame as to be found false and perfidious. Every lie, great or
small, is the brink of a precipice, the depth of which nothing but
Omniscience can fathom. Denying a fault always doubles it. All that
a man can get by lying and dissembling is that he will not be
believed when he speaks the truth. A liar is subject to two
misfortunes, neither to believe nor to be believed. If falsehood, says
Montaigne, like truth, had but one face, we should be upon better
terms; for we should then take the contrary of what the liar says for
certain truth.
We are not called upon to speak all that we know; that would be
folly. But what a man says should be what he thinks; otherwise it is
knavery. No wrong is ever made better, but always worse, by a
falsehood. Even when detection does not follow, suspicion is always
created. Wrong is but falsehood put in practice. The Chinese have a
proverb which says, "A lie has no legs, and can not stand;" but it has
wings and can fly far and wide. You never can unite, though you
may try ever so hard, the antagonistic elements of truth and
falsehood. The man who forgets a great deal that has happened has
a better memory than he who remembers a great deal that never
happened.
After all, the most natural beauty in the world is honesty and
moral truth; for all beauty is truth. True features make the beauty of
a face, and true proportions the beauty of architecture, as true
measure that of harmony and music. In poetry, truth still is the
perfection. Fiction must be governed by truth, and can only please
by its resemblance to truth. The appearance of reality is necessary
to agreeably represent any passion, and to be able to move others
we must be moved ourselves, or at least seem to be so upon some
probable ground. Falsehood itself is never so susceptible as when
she baits her hook with truth, and no opinions so fatally mislead us
as those that are not wholly wrong. No watch so effectually deceives
the wearer as those that are sometimes right.
Such are the imperfections of mankind that the duplicities, the
temptations, and the infirmities that surround us have rendered the
truth, and nothing but the truth, as hazardous and contraband a
commodity as a man can possibly deal in. Colton says that "pure
truth, like pure gold, has been found unfit for circulation;" and
another has said, "It is dangerous to follow truth too near lest she
should kick out your teeth." The trouble consists not in obeying the
behests of strict veracity, but in lack of prudence and ordinary
caution. While all we tell should be the truth, it is not always
necessary to tell all the truth, unless the other one have a right to
know. Silence is always an alternative with truth. Remember that the
silken cords of love must ever be linked with those of truth;
otherwise they will but gall and irritate, instead of guiding into paths
of rectitude.
MAN of honor! What a glorious title is that! Who would not
rather have it than any that kings can bestow? It is worth all
the gold and silver in the world. He who merits it wears a
jewel within his soul and needs none upon his bosom. "His
word is as good as his bond," and if there were no law in the land
one might deal just as safely with him. To take unfair advantage is
not in him. To quibble and guard his speech so that he leads others
to suppose that he means something that he does not mean, even
while they can never prove that it is so, would be impossible to his
frank nature. His speeches are never riddles. He looks you in the eye
and says straight out the things he has to say, and he does unto
others the things he would that they should do to him.
He is a good son and a good brother. Who ever heard him betray
the faults and follies of his near kindred? And with his friends he
proves himself true, and will not betray the trust friendship imposes
on him. And with strangers you do not find him too curious about
the affairs of others, or too eager to impart information accidentally
gleaned by him. Real honor and esteem are not difficult to be
obtained in the world. They are best won by actual worth and merit
rather than by art and intrigue, which runs a long and ruinous race,
and seldom seizes upon the prize at last. Clear and round dealing is
the honor of man's nature, and mixture of falsehood is like alloy in
coin of gold and silver, which may make the metal work the better,
but it embaseth it.
Honor, like reputation and character, displays itself in little acts. It
is of slow growth. Anciently the Romans worshiped virtue and honor
as gods; they built two temples, which were so seated that none
could enter the temple of honor without passing through the temple
of virtue, thus symbolizing the truth that all honor is founded on
virtue. He whose soul is set to do right finds himself more firmly
bound by the principle of honor than by legal restraints—much more
at ease when bound by the law than when bound by his conscience.
He who is actuated by false principles of honor does not feel thus.
True honor is internal, false honor external. The one is founded on
principles, the other on interests. The one does not ostentatiously
proclaim its lofty aims; it prefers that its conduct and actions
demonstrate its purposes. He who is moved by false honor is
constantly worried lest some one should doubt that he was a man of
honor. He is so busily engaged in sustaining his reputation against
fancied attacks on his honor that he finds but little time to devote to
the exercise of those acts which a fine sense of honor would impel
him to do. Such a one may be a libertine, penurious, proud—may
insult his inferiors and defraud his creditors—but it is impossible for
one possessed of true honor to be any of these.
Honor and virtue are not the same, though true honor is always
founded on virtue. Honor may take her tones and texture from the
prevailing manners and customs of those around us; this renders her
vacillating unless allied to virtue, which is the same in both
hemispheres, yesterday as to-day. When honor is not founded on
virtue she becomes essentially selfish in design, and is unworthy of
her name. She is then unstable and seldom the same, for she feeds
upon opinion, and will be as fickle as her food. She builds a lofty
structure on the sandy foundation of the esteem of those who are,
of all beings, the most subject to change. Combined with virtue she
is uniform and fixed, because she looks for approbation only from
Him who is the same at all times. Honor by herself is capricious in
her rewards. She feeds us upon air, and often pulls down our house
to build our monument. She is contracted in her views, inasmuch as
her hopes are rooted on to earth, bounded by time, and terminated
by death. But, when directed by virtue, her hopes become enlarged
and magnified, inasmuch as they extend beyond present things—
even to things eternal. In the storms and tempests of life mere
honor is not to be depended on, because she herself partakes of the
tumult; she also is buffeted by the waves and borne along by the
whirlwind. But virtue is above the storm, and gives to honor a sure
and steadfast anchor, since it is cast into heaven.
HAT is called policy is sometimes spoken of in the same
sense as prudence, but its nature is cunning. It is a thing of
many aspects and of many tongues; it can appear in any form
and speak in any language. It is sometimes called management, but
is not worthy of that good name, inasmuch as it is but a compound
of sagacity and deceit, of duplicity and of meanness. It puts on the
semblance of kindness and concern for your good, but its heart is
treachery and selfishness.
This principle, strange as it may seem, is of very extensive
influence. It is adopted and acted upon by multitudes, who claim to
be respectable and intelligent men, and is not confined to the few or
those of the baser sort. Its devotees may not be aware that this is
their ruling principle of action. They mistake its meaning by giving it
a wrong name. They call it prudence, discretion, wisdom. Alas! it is
not guided by the high principles of integrity, which beautify and
adorn those noble attributes of perfect manhood. Its appropriate
name is policy, the sister of cunning, the child of deception and
duplicity.
This principle of double dealing, of artful accommodation and
management, is eminently characteristic of the present age. It meets
every man on his blind side, and by stratagem makes a tool of him
to accomplish its own wily and selfish purposes. If he is weak, it
deceives him by its artifices; if he is vain, it puffs up his vanity by
flattery; if he is avaricious, it allures him with the prospect of gain; if
he is ambitious, it promises him promotion; if he is timid, it
threatens him. Its leading maxim is, "The end justifies the means,"
and, in pursuing its end, it sticks at nothing that promises success. It
may be traced in all departments of business and through all grades
of society, from the grand councils of the nation to the little town or
parish meeting. Instead of acting in open daylight, pursuing the
direct and straightforward path of rectitude and duty, you see men
extensively putting on false appearances, working in the dark, and
carrying their plans by stratagem and deceit; nothing open, nothing
direct and honest; one thing is said, and another thing is meant.
When you look for a man in one place, you find him in another. With
flattering lips and a double heart do they speak. Their language and
conduct do not proceed from fixed principles and open-hearted
sincerity, but from a spirit of duplicity and selfish policy.
Prudence, caution, and business management are not only a
necessity, but are commended as the price of success in worldly
affairs. They have the sanction of our best judgment, and offend no
moral sense of right. But against mere policy every young man who
has any desire of lasting respectability and influence ought most
carefully be on his guard. Nothing can be more fatal to reputation
and success in life than to acquire the character of an artful intriguer,
one who does all things with the ulterior design of furthering his own
ends. He may succeed for a time; but he will soon be found out, and
when found out will be despised. He who acts on this principle thinks
that nobody knows it; but he is wretchedly mistaken. The thin
disguise that is thrown over the inner man is soon seen through by
every one, and while he prides himself on being very wise and
keeping his designs out of sight, all persons of the least discernment
perfectly understand him, and despise him for thinking he could
make fools of them.
People often mistake policy for discretion. There is a wide
difference between the two traits. Policy is only the mimic of
discretion, but may pass current with the mass in the same manner
as vivacity is often mistaken for wit and gravity for wisdom. Policy
has only private, selfish aims, and stops at nothing which may
render these successful. Discretion has large and extended views,
and, like a well-formed eye, commands a wide horizon. Policy is a
kind of short insight that discovers the minutest objects that are
close at hand, but is not able to discover things at a distance. The
whole power of policy is private; to say nothing and to do nothing is
the utmost of its reach. Yet men thus narrow by nature and mean by
art are sometimes able to rise by the miscarriage of bravery and
openness of integrity, and, watching failures and snatching
opportunities, obtain advantages which belong to higher characters.
The observant man will not calculate any essential difference from
mere appearances. The light laughter that bubbles on the lips, often
mantles over brackish depths of sadness, and the serious look may
be the sober veil that covers a divine peace. The bosom may ache
beneath diamond broaches, or a blithe heart dance under coarse
wool sacks. By a kind of fashionable discipline the eye is taught to
brighten, the lip to smile, and the whole countenance to emanate
the semblance of friendly welcome, while the bosom is unwarmed by
a single spark of genuine kindness and good-will. Grief and anxiety
lie hidden under the golden robes of prosperity, and the gloom of
calamity is often cheered by the secret radiations of hope and
comfort, as in the works of nature the bog is sometimes covered
with flowers and the mine concealed in barren crags. Beware, so
long as you live, of judging men by the outward appearance.
But nothing feigned or violent can last long. Life becomes
manifest. It will declare itself, and at last the worthless disguises are
worn off. Hence, the lesson that the wise man should learn is to
guard against mere appearances in others, but for himself to pursue
the straightforward, open course, and in a world of deceit and
intrigue show himself a man that can be relied on. Thus will his life
be influential for good, and after he is gone his memory will be
revered as that of an upright man.
HERE is one quality which brings to its possessor naught but
ridicule, or, what is still worse, positive dislike: it is sometimes
called self-conceit, but more commonly and more forcibly
expressed by egotism.
Egotism and skepticism are always miserable companions in life,
and are especially unlovable in youth. The egotist is next door to a
fanatic. Constantly occupied with self, he has no thoughts to spare
for others. He refers to himself in all things, thinks of himself, and
studies himself, until his own little self becomes his ruling principle of
action. The pests of society are egotists. There are some men whose
opposition can be reckoned upon against every thing that has not
emanated from themselves. He that falls in love with himself will
have no rivals. The egotist's code is, Every thing for himself, nothing
for others. Hence it is by reason of their selfishness that they find
the world so ugly, because they can only see themselves in it.
An egotist is seldom a man of brilliant parts. A talented or sensible
man is apt to drop out of his narration every allusion to himself. He
is content with putting his theme on its own ground. You shall not
tell me you have learned to know most men. Your saying so
disproves it. You shall not tell me by their titles what books you have
read. You shall not tell me your house is the best and your pictures
the finest. You shall make me feel it. I am not to infer it from your
conversation. It is a false principle, because we are entirely occupied
with ourselves, we must equally occupy the thoughts of others. The
contrary inference is but the fair one. We are such hypocrites that
whatever we talk of ourselves, though our words may sound
humble, our hearts are nearly always proud. When all is summed up,
a man never speaks of himself without loss; his accusation of
himself is always believed, his praises never. This love of talking of
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like