►
Description
Fastify is a web framework for Node.js that has a great satisfaction across developers with a 89% rating in the last state of javascript. Fastify combines an amazing developer experience with top of the class performance, with minimal reduction on top of Node.js core. In this talk, we will go through the fundamentals of the framework as well as a live coded example.
A
Hi
everyone-
I
am
mateo
kolina
and
today
I'm
going
to
talk
to
you
about
fastify.
You
know,
fastify
is
a
project
that
I
started
a
few
years
back
with
with
thomas
and
it
has
been
one
of
the
most
amazing.
You
know
journey
of
my
life.
To
be
honest,
so
I
hope
you
would
like
this
this
intro
and
you
would,
you
know,
give
it
a
shot
and
try
it
out
in
your
next
project.
So
let's
start
first
of
all
take
a
moment
to
follow
me
on
twitter
at
mateo
kolina.
A
I
tweet
about
a
lot
of
things.
So
hey
molly,
mainly
javascript,
so
I
also
work
for
a
company
called
near
form.
So
if
you
are
interested,
please
check
us
out.
We
are
a
professional
services
company
based
in
ireland,
but
working
worldwide
to
that
can
help
you
in
any
sort
of
problems.
Anyway,
let's
get
started
on
on
fastify
and
why
it
matters
so
pestify
is
you
can
find
everything
for
rated
to
falsify
on
www.fastify.org
it's
our
main
er,
it's
our
main
domain.
A
You
can
find
all
the
docs
there,
it's
pretty
good
and
it's
you
know
it
should
be
a
lot
of
docks.
As
usual,
everything
can
be
improved,
so
please,
please,
please
check
it
out,
and
if
you
see
something
that
it
does
not,
you
know
that
you
don't
find
clear,
please
open
an
issue
and
maybe
send
out
a
pr
to
improve
it
anyway,
and
this
is
actually
a
good
segue
for
the
very
first
important
part
of
this
talk,
which
is
you
know,
a
genetic
principle
that
is
based
that
underpins
all
of
opengs
project.
A
But
you
know
specifically
fastified
an
open
source
project
is
as
good
as
this
community.
Is
this
it's
extremely
important,
so
in
fact,
festival?
We
believe
that
you
know
building
and
maintaining
a
web
framework
for
node.js
is
too
much
of
a
work
for
a
single
individual
or
even
a
single
company
to
some
extent,
and
we
you
know,
we
encourage
everybody,
everybody
that
is
using
fastify,
that
is
finding
values
fastify
to
contribute
back.
A
Also.
First,
if
I
was
born
when
I
met
thomas-
and
I
tried
to
convince
him
to
to
help
me
to
convince
somebody
helping
in
this
journey-
and
you
know
I
I
found
thomas-
and
you
know
we
started
working
on
this
together.
So
it's
quite
a
nice
story.
I
thought
that
I'll
talk
about
it
in
the
latest
in
last
year,
open
js,
so
check
it
out
anyway.
A
Fastified
firstify
is
one
of
the
fastest
web
framework
for
node.js,
and
you
can
you
can
just
you
know,
require
it
or
import.
It
does
work
both
ways
and
you
can
call
it
with
a
logger
or
other
options,
and
then
you
can
declare
your
routes
and
you
know
async
await.
You
can
use
a
sync
away
to
just
return
an
object.
It
will
convert
to
a
json
very
simple.
A
Now
fastify
has
been
under
massive
growth
in
the
last
year
in
the
last
few
years.
It
has
now
reached
900
000
downloads
per
month,
and
it's
probably
on
the
track
to
reach
a
million
downloads
per
month
at
the
end
of
the
year,
so
finger
crossed
and
it
has
now.
It
has
15
collaborators
working
on
it
and
it
has
reached
version
3.
and
it
has
a
very
big
ecosystem
of
185
plugins.
A
We
are
going
to
ship
v4
soon,
so
we
are
going
to
to
storm
with
a
lot
of
with
a
lot
of
news
about
it.
As
I
said,
the
core
values
as
fastify
are
all
about
open
collaboration
and
collaboration
across
multiple
individuals.
We
always
welcome
first-time
contributors.
So
if
you're
using
fastify,
there's
a
very
good
chance
that
you
are
that
we
will
be
asked
a
very,
very
simple
question:
would
you
like
to
send
up
a
request
to
fix
your
bug,
your
issue
or
implement
a
new
feature?
A
It's
always
important
that
you
contribute
back
in
this
ecosystem.
We
don't
that's
what
we
do
here.
Okay,
it's
it's
too
complex
to
build
this
thing
alone,
so
we
ask
everybody
to
contribute
back.
We
also
seek
open
government.
We
also
approach
with
an
open
governance
in
a
fashion,
which
means
that
we
ask
if
people
objects
and
if
not,
we
are
lending
them.
Typically,
if
there
are
ties
or
things
that
are
too
complex
or
that
require
that
the
community
is
unsure.
A
A
The
the
fund,
as
I
said,
the
key
part
of
fastify
was
built.
Fastify
was
a
community
of
two
people
before
it
was
before
any
code
was
committed,
so
you
know
the
the
fact
that
it's
a
meld
of
different
companies,
different
people,
different
individuals,
working
together.
It's
it's
a
key,
a
fundamental
issue,
part
of
fastify,
it's
the
problem
that
we
have
seen.
Why
is
this?
Well?
A
The
reason
is
because
we
have
seen
that,
especially
in
other
frameworks
and
other
initiatives,
that
it's
very
hard
to
for
a
single
company
or
person
justify
the
investment
that
is
needed
to
build
and
maintain
a
web
framework
for
node.js,
and
what
we
have
chosen
is
to
the
route
that
we
have
chosen
is
to
spread
this
effort
across
the
companies
using
it.
A
So
you
know
the
typical
request
that
I
ask
everybody
that
we
ask
everybody
is
when
there
is
a
bug
I
said,
would
you
like
to
send
a
pr
and
remember
to
add
unit
tests?
So
fastify
is
pretty
unique
in
that
sense
and
we
create
this
culture
of
ownership.
That
is
a
key
fundamental
part
of
the
fastify
experience
you
can
check
it
out.
A
We
also
have
a
nice
governance
document,
so
please
check
it
out
to
see
how
our
community
works
by
the
way
we
just
can
make
we,
if
you
contribute
to,
if
you
contribute
to
fastify,
it's
very
likely
that
you
will
get
the
commitment.
So
please,
you
know
if
you
do
sustainable,
sustainable
and
valuable
contributions.
A
Let's
go
into
tech
because
you
know
still
fastify
is
a
web
framework
right
for
node.js.
So
it's
it's
attack.
We
need
to
talk
about
tech.
The
first
principle
is
about
overhead.
We
don't
want
to
add
additional
overhead
in
production,
why
that
is
not
truly
possible.
So
it's
aspirational
and
we
want
to
reduce
the
overhead
that
the
web
framework
have.
A
We
want
to
provide
a
good
developer
experience,
that's
a
key
fundamental
part
of
it,
and
it
needs
to
work
great
for
both
small
and
big
projects,
so
it
needs
to
work
for
a
very
simple
hello
world,
but
also
should
also
work
well
for
a
company
that
is
a
hundred
developers
working
on
several
microservices
and
some
big
distributor
system,
and
so
on
so
forth.
It's
not
simple
to
build
something
to
to
design
a
web
framework
that
can
easily
grow
and
an
increasingly
amount
of
complexity.
A
Because
of
this
we
wanted
to
be
able
to
migrate
to
microservices
and
serverless
and
and
back
it
needs
to
have
a
very
good
security
and,
more
importantly,
data
validation.
A
It
has
a
plug-in
system
again,
we
don't
believe
to
scope
creep
so
to
avoid
scope
creep,
we
created
a
plug-in
system,
so
if
something
could
be
a
plug-in,
it
likely
should
it
needs
to
be
testable
and
we
do
not
want
to
monkey
patch
core.
To
be
honest,
this
was
one
of
the
parts
that
one
of
the
critical
part
the
node
core.
So
this
one
a
critical
part
that
led
me
to
create
fastify
in
the
first
place,
because
a
lot
of
the
other
frameworks
actually
had
a
huge
focus
on
monkey
patching
note
core.
A
Also,
we
want
to
follow
semantic,
versioning
and
long
term
support
so
more
or
less
we
ship
one
new
major
version
per
year
and
last
but
not
least,
http
1.1
spec
adherence.
So
we
want
to
follow
http
one.
A
So
one
of
the
very
nice
bits-
and
one
nice
thing
to
chat
about
is
how
fast
is
fastify,
because
it's
one
of
you
know
it's
called
in
this
way
and
it's
I
wanted
to
clarify
that
fastify
is
fast
enough,
so
it
does
not
provide
a
significant
slowdown
compared
to
not
core
in
certain
cases,
actually
slightly
faster
than
not
core,
because
it
can
avoid
certain.
A
You
know,
paths
that
are
not
great,
it's
probably
faster
than
whatever
you
are
using
and
at
this
level
it's
you
know
comparable
to
you
just
to
use
note
core.
This
is
critical
because
we
don't
want
a
significant
drop
in
throughput
and
performance.
So
if
there
is
a
significant
drop
in
throughput
and
performance,
we
are
you.
You
know
you
you
don't
want
your
web
framework
should
not
be
your
main
bottleneck
right.
It
I'll
talk
a
little
bit
more
about
later
on.
Why
this
is
fast?
A
Why
it's
it's
it's
fast,
so
fastify
is
also
very
much
loved
by
devs,
and
you
know
it
was
part
of
the
latest
state
of
js
which
might
not
be
representative,
but
it's
still
a
good
number
that
you
know
a
few
people
are
loving
fastified,
so
pretty
good
right.
I
am
pretty
pretty
happy
about
about
this
result,
so
it's
it's
pretty
good
anyway,
and
fastifies
also
have
another
library
called
mercurius
that
you
can
use
on
top.
A
It
provides
support
for
graphql
on
top
of
it,
and
it's
also
as
it's
as
well
very
fast.
As
it
said,
one
of
the
key
part
of
of
fastify
is
its
plugins
and
we
have
both
core
plugins
and
ecosystem
plugins.
What
is
the
difference?
Well,
the
difference
is
that
core
plugins
are
maintained
by
the
fastify
organization,
so
we
typically
guarantee
that
they
work
on
every
new
major,
so
we
typically
update
all
of
them
when
we
do
assembler
major
now
consider
it.
A
We
are
releasing
essentially
to
december
major
fastify,
where
probably
this
is
40
45
modules,
so
it's
quite
a
big
deal
that
typically
spans
across
in
a
couple
of
days.
So
when
that
happens,
it's
a
little
bit
of
a
shift
in
in
virgin
major
versions.
Anyway,
they
also
tend
to
solve
the
problem
in
the
most
idiomatic
way.
So
there's
a
few
examples
like
fastified
to
load,
fastify
static
and
the
under
pressure
module.
The
projects
in
the
ecosystem
are
maintained
by
members
of
the
community,
for
example.
A
I
wrote
some
of
them
that
are
very
opinionated
and
things
that
I
would
not
want
to
include
in
in
in
the
org.
So
it's
you
know
there
are
plenty
so
hey
and
we
have
a
few.
We
have
141
of
those,
so
you
can
just
write
one.
To
be
honest,
there
is
a
good
guide
on
the
website.
So
what
is
the
target
architecture
of
a
fastify
application?
Well,
historically,
you
have.
We
have
been
deploying
ojs
in
a
with
mvc
pattern.
A
Mvc,
however,
as
a
as
a
signal
as
a
significant
problem,
you
know
once
the
complexity
or
application
grows
over
time.
You
are
either
moving
you're
either.
Putting
the
complexity
in
in
the
models,
the
views
or
the
controllers,
so
that's
quite
of
a
big
quite
of
a
big
problem.
For
me,
at
least
because
you
know
it's
it's
very
hard
to
to
scale.
So
how
can
we
improve
this?
Well,
oh
yay!
Here
we
go
so
how
can
we?
How
can
we
improve
this?
A
Well,
what
we
can
do
is,
we
can,
you
know,
start
structuring
our
application
instead
of
using
the
mvc
concept
using
just
horizontal
models
that
are,
you
know,
aligned
with
the
features
of
your
app.
A
So
instead
of
having
like
these
big
three
boxes,
where
you
need
to
fit
everything,
you
can
have
just
a
few
independent
modules
as
many
as
the
domain
of
your
application
are,
and
this
system
actually
scale
very
way
better
in
complexity,
because
the
moment
you
start
doing
this,
you
can
you
know
you
can
have
you
have
segregated
the
complexity
into
and
tracking
the
pieces
that
you
need
to
reuse
in
some
other
model,
etc.
So
you
you
can
now
track
what
is
the
interrelationship
between
the
things?
A
In
fact,
it's
also
the
stepping
stone
for
moving
into
a
microservice
into
a
microservice
architecture.
Microservices
are
actually
a
fundamental
part
of
how
we
develop
system
as
well
as
lambdas
and
so
on,
but
the
key
part
is
that
with
fastify
you
could
essentially
move
from
a
monolith
to
a
micro
service
board
very
easily
because
it's
all
built
on
the
console
of
plugins.
So
you
will
see
that
in
a
moment,
but
it's
like
super
easy.
So
so,
let's
go
a
little
bit
in
depth,
so
fastify
is
built
on
on
various
levels.
A
So
at
the
at
the
bottom
of
it
we
have
two
libraries
avio,
which
is
the
loader
of
fastify
and
provide
also
provide
the
plugin
system
and
pino,
which
is
the
fastest
logger
for
node.js.
I'm
not
going
to
talk
about
pino,
so
you
know,
go
google
it
up,
pinot,
logger
node.js
or
something
there's
a
lot
of
talks.
One
of
my
favorite
one
is
the
cost
of
login.
It
has
been
around
for
a
while.
A
A
That
is
needed
by
by
your
app
a
vo
guarantee
us
to
have
the
plug-in
system,
the
hook
system
and
the
decorators,
so
it's
essentially
provide
the
basics
in
which
all
these
other
features
are
built
upon.
On
top
of
that,
we
have
like
the
router,
which
is
find
my
way
ajv,
which
is
the
validation,
validator
and
fast
json
signify,
which
is
the
serializer
we'll
talk
about
those
in
a
second,
so
the
plug-in
system.
This
is
a
key
part
of
fastify
with
the
plug-in
system.
A
You
have
an
entry
point
at
the
top
at
the
very
top,
and
it's
then
the
entry
point
can
you
know,
load
plugins
and
plugins
can
load
other
plugins
re-enter
in
a
re-entrant
way.
Now
each
one
of
those
plugins
creates
an
encapsulation
context,
so
essentially
whatever
they
do,
you
want
to
influence
it.
It
won't
influence
like
sibling,
plugins,
early
descendants.
A
This
is
critical
because
then
we
can
say,
for
example,
we
can
pack
an
app
and
reuse.
It
we'll
see
how
to
do
that,
in
fact,
when,
if
I
want
to
expose
a
functionality
from
one
plugin
to
the
other,
I
can
use
the
concept
of
decoration.
So
I
can
decorate
the
request
response
or
the
server
to
expose
some
things
to
the
my
the
schenden
plugins.
Now
this
is
really
nice,
because
you
know
it's
a
a
simple
way
of
providing
dependence.
Injection
or
I
don't
know,
inversion
of
control
if
you
want
to
call
it
whatever.
A
Sorry,
you
can
also
break
the
encounter
encapsulation
if
you
want,
because
you
can
use
an
utility
called
fastify
plug-in
so
that
you
can
actually
may
expose
the
declaration
to
your
parent
as
well
as
the
ending
and
your
siblings.
This
allows
us
to
build.
I
don't
know
reusable
modules,
so
we
can
use
this
utility
to
build
reusable
models.
A
The
request
lifecycle
of
a
fastify
is
different
than
the
one
of
express,
for
example,
with
the
other
stuff
with
other
express
or
koa.
You
have
middlewares
that
are
run
everywhere
with
fastify.
You
have
a
predefined
lifecycle
that
clearly
defines
that
you
can
clearly
use
to
specify
when
things
are
run,
and
this
is
key
because
in
this
way
we
can
actually,
you
know,
avoid
monkey
patching,
not
core,
so
we
have
all
sort
of
hooks.
So
typically,
the
most
important
ones
are
the
request
hook,
that's
the
first
one
that
is
executed.
A
We
have
pre-handler,
which
is
executed
before
the
user
handler,
and
then
we
and
we
have
onsend,
which
is
executed
before
sending
the
actual
response
out.
A
We
also
provide
a
recommended
project
structure
which
drive
an
app.js
file
that
contains
your
app
a
plugins
folder.
For
reusable
behavior
a
routes
folder
for
all
your
routes
with
a
nested
pattern,
we'll
see
how
to
do
that
and
then
a
test
folder
with
your
fastify,
provides
this
concept
of
encapsulation,
as
we
have
seen
now,
with
fastify
you've
seen
the
target
architecture
on
the
left,
and
you
know
it's,
let
me
actually
put
it.
A
Let
me
actually
put
it
big
here,
you
go
so
it's
with
fastify
you
have.
You
can
see
that
you
have
your
target
architecture
on
the
on
the
left
and
this
architecture
provides
you.
You
know
you
tells
you
to
structure
your
systems
in
modules.
Now
you
can
actually
part
this
to
fastify
very
easily
because
you
can
have
you
know
your
major
application
that
is
composed
your
major
app
that
is
composed
of
three
sub-apps
or
four
or
five,
or
how
many
you
want,
which
have
their
own
plugins
and
dependencies
and
everything.
So
it's
completely.
A
A
As
I
said,
logging,
it's
one
of
the
key
part
of
fastify
and
you
can
just
use
a
pinot,
so
it's
probably
the
fastest
logger
for
furnitures.
So
take
a
look
at
the
take
a
look
at
pino.
It
is
great,
so
it's
we're
virtually
on
version.
Seven.
How
do
you
use
it?
Well,
you
just
call
logger
dot
info,
pretty
neat
as
everything
you
would.
A
You
will
use
in
the
past
some
more
important
bits
fast
if
I
provide
out-of-the-box
cellularization,
so
it
allows
you
to
specify
the
type
the
schema
of
the
object
going
out.
This
is
pretty
important
because
then
we
can
create
a
faster
than
json.stringify
method
function
that
you
know
can
give
you
a
nice
speed
bump.
A
We
also
written
this
utility
called
fluent.json
schema
to
help
you
writing
json
schema
in
a
nicer
syntax.
I
like
it
a
lot.
I
never
use
this
schema
by
the
way
we
also
use
ajv,
which
is,
and
by
the
way
this
is
the
plugin
system
syntax.
So
you
need
to
export
a
function
with
app
and
ops
and
ajv
is
a
the
one
of
the
fastest
validator
for
node.js.
So
it's
pretty
great
also
for
embedding.
A
So
that's
why
we
use
it
and
hey
it's
also
another
openjs
project,
so
testing
fastify
embed
an
inject
method
for
fast
testing.
It's
really
fast!
Even
this
method,
and
in
fact
that
method
is
so
fast
that
it
at
the
basis
of
the
integration
for
aws
lambda.
So
you
can,
with
this
utility
at
ws,
lambda
fastify.
You
can
just
create
a
very
simple
proxy
for
your
fastify
app,
which
is
essentially
just
the
app
as
you
would
normally
use,
and
it
just
works.
A
A
Okay,
so
I
just
want
to
thank
you
for
your
time
before
we
go
into
the
we
do
a
little
bit
of
a
live
coding
example
and
see
how
it
is
so,
I'm
going
to
switch
to
my
to
my
terminal
that
you
can
all
see.
So
you
know
we
can
start
developing
things
on
fastify,
so
we
can
do
e
app.js
and
we
can
do
import
fastify
from
fastify,
and
what
we
do
is
that
we
do
cost
app.
A
A
And
we
are
calling
it
and
you
see
it's,
it's
not
found
so
hey,
not
super
nice
right,
but
we
can
add
it
out
and
we
add
a
route
and
function
wreck.
I
don't
need
anything
here,
so
I'm
just
doing
return
hello
world.
A
Running
my
app
as
you
see
now,
it's
returning
a
lowered
cool.
Oh!
I
can
also
see
that
if
there
are
all
the
http
headers
that
I
would
expect-
and
they
are
all
there-
okay,
so
pretty
nice
okay,
what
do
we
do
next?
Well,
this
app
is
not
really
really
reusable.
So
what
we
want
to
do
is
we
want
to
make
well.
This
is
refresh
okay.
Let's,
let's
do
this?
Okay,
so
we
want
to
create
a
another
server.
Another
file
called
server.js.
A
A
A
It's
still
working
as
as
expected,
cool,
okay,
pretty
neat,
so
this
is
actually
pretty
nice.
I
can
also
use,
for
example,
pass
in
some
opts
here,
and
you
know
include
them
here
and
then
in
server.
I
can
say,
for
example,
logger
true,
so
I
can
do
node
server
and
then
I
can
curl.
A
A
In
if,
if
I
want
a
some
nicer
output
for
development,
I
can
use
pinopretty
and,
as
you
can
see,
I
can
see
the
request
coming
in
and
the
request
that
is
completed
out
and
we
can
see
some
usual
things
about
response
time
and
so
on
and
so
forth.
So
here
we
go
pretty
neat
cool
okay,
so
this
is
some
some
good
example.
However,
this
is
not
really
scalable,
as
we
saw
so
we
can
use
the
routes.
We
can
create
a
routes
folder
and
in
routes
I
can
create
a
load.js
in
a
load.js.
A
What
I
am
doing
is
that
I'm
going
to
copy
this-
and
here
I'm
doing
to
export
default,
async
function,
app,
opts
and.
A
A
Works,
okay,
so
it
it
did
load
and
then
it's
it's
still
working
cool
okay.
So
now
one
of
the
things
that
I
want
to
use
is:
instead,
I
don't
want
to
load
all
the
files
manually.
So
what
I'm
going
to
do
is
I'm
going
to
use
autoload
the
autoload
module
so
called
fastify
autoload,
and
I'm
going
to
use
this
with
this
utility
called
dsm
and
the
reason
for
this.
It's
because,
unfortunately,
you
know
in
esm,
you
don't
have
understand
the
score,
the
name
or
the
standard
code
file
name.
A
So
you
need
a
little
bit.
You
need
to
work
with
file
urls
and
that's
a
bit
convoluted.
So
I
don't
really.
I
make
mistakes
all
the
time,
especially
stuff
that
doesn't
work
on
windows,
so
I
I
tend
to
prefer
to
use
my
utility
that
has
the
thing
called
that,
so
you
do
you
specify
your
directory
and
then
you
say:
import
meta
url,
which
is
the
current
file
and
you
put
and
then
you
say
routes,
so
you,
basically
you
tell
load
everything
that
is
defined
into
that
folder.
A
So
you
would
then
now
run
this
and
then
I
can
curl
it
as
you
can
see,
it
still
worked
as
expected
as
before,
pretty
pretty
nice,
pretty
pretty
nice,
indeed
cool
folks,
oh
one
of
the
nicest
things
that
I
can
actually
create
a
folder
nested
structure,
so
I
can
say
a
nested
and
then
say
route.yes
and
then
I
can
copy
this
and
put
it
in
here
and
says
alone.
A
Nested
note
that
I
still
use
slash
here
to
define
this,
that
the
pattern
is
defined
in
the
in
the
in
the
folder,
and
so
let's
see
if,
if
I
can
launch
this
stuff.
A
So
this
is
still
working,
okay,
cool
and
then,
if
I
do
slash,
nested
is
still
it
goes
into
the
nested
folder,
so
yeah.
I
just
wanted
to
say
to
conclude
to
conclude
this
by
by
saying
thank
you
and
if
you
have
any
question,
please
reach
out
to
me
at
matocolina
on
twitter
or
via
email.
There
is
also
an
addfastfijs
account,
so
thank
you.
Thank
you
very
much
and
bye,
bye.