►
From YouTube: hyper63 hacking 2/8
Description
Part 1 of adding the bulk api endpoint for the data port
https://github.com/hyper63/hyper63
A
B
You
know
if
it
helps
people
get
an
insight
on
the
project.
Then
that'll
be
cool
cool.
So
what
I'm
gonna
work
on
this
see
how
far
we
get
but
work
on
adding
this
bulk
endpoint
for
the
data
api.
B
B
I
call
it
ports
and
adapters
architecture,
but
but
basically
you
have
you
know
some
sort
of
interface
in
hyper,
63's
internals,
that's
kind
of
the
app
or
the
api,
and
then
you
have
a
core
and
then
you
have
ports
and
those
ports
have
can
have
different
adapters
so
that
that's
kind
of
this
architecture
that
that
hyper
is
really
kind
of
you
know,
make
more
mainstream,
but
because
there's
a
lot
of
benefits
of
having
these
ports
and
adapters
and
being
able
to
swap
them
out.
B
But
but
it's
it's
hard
to
do
when
you're
building
everything
else
so
having
something
that
kind
of
builds
that
for
you.
I
think
can
have
a
lot
of
advantages.
Here's
kind
of
a
view
of
that
in
kind
of
hyperland.
B
So
here
is
the
app
express
package
and
we
have
an
app
graphql,
but
you
could
have
an
app
grpc
or
protobuffers
or
whatever,
but
that's
kind
of
your
entry
point
to
hyper
63
and
then
down
here
you
have
some
middleware
and
hooks
so
with
middleware,
you
can
add
security
or
other
kind
of
features
and
hooks
you
can
get
observability
out
of
hyper-63,
so
you
can
add
a
hook
to
say,
send
all
these
events
to
this
endpoint
or
send
all
these
events
to
console.
B
You
know
those
types
of
things
and
then
you
have
your
core
and
and
your
core
is
just
really
kind
of
the
the
the
keeper
of
the
business
rules
right.
So
so,
basically,
in
nbc
days,
you
could
think
of
this
as
more
as
kind
of
the
controller
in
the
model
kind
of
combined,
and
then
you
have
these
ports
and
a
port.
Basically,
all
it's
responsible
to
do
is
make
sure
that
an
adapter
implements
a
specific
specification.
B
So
if
the
data
features
is
the
ability
to
create,
read,
update
and
delete
right,
then
the
adapter,
regardless
of
what
the
adapter
driver,
is,
needs
to
implement
those
with
specific
function
patterns,
and
you
know,
if
I
throw
an
adapter
on
here,
you
know
mongodb
and
it
doesn't
implement
those
things.
Then
I
need
when,
when
hyper
fires
up,
I
need
hyper
to
yell
at
me
and
say:
you're
trying
to
use
mongodb
and
that
adapter
is
not
is
not
compatible
with
the
data
port.
B
So,
with
this
issue,
we're
gonna
add
a
new
endpoint
called
bulk,
and
this
bulk
endpoint
will
allow
us
to
send
multiple
json
documents
through
the
xpress
app
through
core
and
then
into
an
adapter.
So
we
gotta
kind
of
touch
the
app
core,
the
data
port,
because
it's
a
new
specification
and
then
each
adapter
that's
defined,
and
you
know
again
from
my
standpoint:
you're
gonna
tackle
this
any
kind
of
way,
but
I'm
gonna
kind
of
write.
The
documentation
first,
at
least
enough
to
to
you,
know
suss
out
any
kind
of
issues
right.
B
So
I'm
going
to
write
an
endpoint
documentation
and
then
I'm
going
to
go
in
the
app
express
and
and
build
out
the
input
endpoint
and
then
test
that
in
kind
of
a
unit
test
and
then
go
to
the
data
port
and
build
out
the
spec
and
then
create
some
tests
around
that
and
then
publish
the
data
port,
update
the
core
and
then
go
and
implement
the
pouch
db
adapter
and
the
couchdb
adapter.
B
A
Yeah
definitely
what's
what's
the
use
case,
so
it's
kind
of
like
bulk
loading
either
like
seeding
or
just
getting
the
data
storage
up
to
date.
B
Yeah
yeah,
so
let's
say
you
wanted
to
to
migrate
from
one
one:
implementation:
data
store
to
another
implementation
data
store.
You
could
use
this
bulk
feature,
but
but
basically
just
to
give
you
an
idea
how
it
would
look
is
like
post
data
name
and
then
bulk,
and
then
you
would
just
send
an
array
of
json.
B
Documents
and
again,
if,
if
I
were
building
a
migration,
I
would
probably
like
create
like
a
pagination
stream
right.
So
I'd
grab
like
a
chunk
of
a
thousand
documents
and
then
bulk
upload
those
thousand
and
then
grab
the
next
chunk
of
a
thousand
and
then
bulk
and
just
create
a
stream
between
the
processes
right
and
basically
the
the
bulk
api.
B
If,
if
the
data
doesn't
exist,
then
it's
going
to
create
a
new
one.
If
it
does
exist-
and
you
know-
has
a
valid
id,
then
it
will
merge
what's
in
there
with
what
you
send
and
then
the
other
option
that
I
kind
of
put
in
here
is
maybe,
if
you
send
underscore
delete
true
as
part
of
your
document,
it
could
actually
remove
it.
So
that
kind
of
gives
you
this
full
kind
of
bulk,
read,
update
and
remove
kind
of
flow.
B
So
then,
you
could
literally
send
a
bunch
of
documents
with
just
their
id
and
underscore
delete
equals
true,
and
that
would
be
like
a
batch
delete,
all
right
cool.
So
I'm
going
to
go
into
the
documentation
and
add
a.
B
C
C
B
And
I've
got
parameters.
C
C
B
B
Documentation
is
never
the
funnest
part,
that's
why
I
try
to
do
it
first,
because
if,
if
I
get
compressed
with
time,
I
I
tend
to
pro
cat
procrastinate
it
off,
and
I
know
it's
not
the
most
fun
part
to
watch,
but
if
I
don't
do
it,
I
need
I
need
someone
to
code
review
me.
C
A
B
Okay,
200
successful
and
I
kind
of
have
results,
and
then
that
way,
when
it
is
an
ad,
if
one
of
them
fails
for
some
reason,
you
would
have
you
know
kind
of
each
id.
C
B
To
nine,
maybe
some
other
error
codes
we
can
add
later
and
then
the
the
last
piece
is
the
example.
Look
at
my
format,
so
I
think
I
just
do
a
curl
command.
C
B
A
B
C
C
C
B
C
C
C
B
I'm
not
trying
to
get
it
super
polished,
but
just
get
enough
down
so
that
when
I
step
away,
I
have
something
to
reference
and
then
hopefully
like
by
the
time.
I
finish
this
whole
feature.
I
can
come
back
here
and
you
know
really
put
some
some
good
context
together,
but
does
that
look
good
to
everybody?.
B
Done
so
now
implement
the
app
express
endpoint,
so
I've
pulled
down
the
project
and
I've
got
it
here.
Let
me,
I
think
I
have
to
stop
sharing
and
then
share.
My
other
thing,
so
I
will
share
thanks
ben
saw
your
chat.
B
So
it's
laid
out
in
a
mono
repo.
So
if
I
do
a
list
and
then
there's
got
to
got
to
do
some
cleanup
but
the
most
important
one
is
this
packages
folder,
that's
where
all
the
kind
of
the
code
lives
and
then
the
other
one
is
this
images
folder
and
the
images
folder
actually
contains
different
builds
of
hyper.
So
if
I
go
into
the
images
folder
and
and
see.
B
B
It
will
automatically
be
reflected
in
this,
so
it's
almost
like
just
running
a
local
host
and
then
it
will
pull
all
the
hyper
modules
app
express
and
these
adapters
when
something
changes
which
is
nice
and
that's
using
yarn
workspaces.
B
The
other
thing
of
note
is
the
the
hyper
63
config
file.
If
we
looked
at
that
diagram
again,
this
config
file
is
like
the
code
version
of
that
diagram.
So
for
this
build
I'm
using
express
as
my
app
and
I'm
using
you
know,
memory
as
my
adapter
for
the
cache
port
using
pouch
db
as
my
adapter
for
the
data
port,
I'm
using
mini
search
as
the
adapter
for
my
search
port
and
then
my
middleware.
I've
got
a
jwt
file
for
my
middleware
that
just
creates
a
shared
secret
token
validator.
B
So
that's
images,
but
we
want
to
jump
into
packages
so
we'll
go
into
packages
and
if
we
list
our
packages
we'll
see
app
express,
that's
the
one
we're
going
to
work
on
first
and
then
core
and
then
we'll
see
the
ports
and
all
these
are
npm
packages.
B
B
I
can
see
okay
and
then
in
app
express
it's
just
a
a
simple
express
app.
If
we
look
at
package.json,
it's
got
cores
express
helmet,
mine,
multer
and
there's
dependencies
and
using
tape
as
a
test
framework.
So
the
first
thing
so,
let's
see
if
all
of
our
tests
pass
that'll
be
a
good
check
and
they
do
and
if
we
look
at
index.js,
this
has
all
of
our
kind
of
endpoints,
but
there's
not
a
lot
of
code
behind
them.
It's
just
kind
of
describing
the
the
end
point.
B
So
in
this
case
we
want
to
add
bulk.
So
we'll
just
add
it
up
here,
it'll
be
a
post.
C
B
Underscore
bulk
and
for
hyper,
the
underscores
represent
an
action,
so
they'll
always
be
kind
of
a
post
for
the
most
part,
but
it's
a
an
action.
If
that
looks
weird.
B
C
B
Right
here
and
it's
basically
just
a
little
middleware,
that's
connecting
our
services
to
requests,
so
we
have
access
to
them
and
then
this
data.bulk,
I
think's
coming
from
the
api's
directory.
C
B
So
the
services
are
are
being
injected
in
when
this
function
gets
executed
and
then
the
spine
core
is
the
middleware.
That's
just
connecting
the
services
to
the
request,
object
and
then
up
here
we
have
these
apis
where
we're
actually
storing
the
request
handler
for
express.
B
So
far
so
good,
so
let's
go
into
api
data.
C
B
And
we'll
do
exports
dot
bulk
and
that's
what
we
called
it.
There,
data
dot
bulk,
so
exports
dot
bulk
and
what
we're
going
to
want
to
take
in
and
here
what
I'm
doing
is
destructuring.
The
request
object.
So
we
put
on
the
request,
object
that
data
in
that
bind
core.
B
So
I
can
destructure
it
by
using
the
curly
braces
and
just
grab
data,
and
I
want
to
get
params
because
that'll
have
the
name
of
the
db
and
then
I
want
to
get
body
which
will
be
the
array
of
documents
that
I
want
to
work
on
and
then
I've
got
the
response
object.
So
basically,
that's
just
a
shortcut
for
doing
request.data,
request.params
request.body
and
then
I'm
going
to
call
this
fork
function
and
we'll
talk
about
that
later.
B
But
but
basically
the
fork
function
will
run
everything
and
then
either
an
error
function
will
be
called
or
a
success
function
will
be
called
and
fork
just
handles
that
so
that
all
the
side
effects
are
pushed
at
the
point
of
the
endpoint,
but
basically
the
endpoint
doesn't
have
to
think
about
it.
It's
either
going
to
get
an
error
or
a
success.
B
So
we'll
do
the
fork
and
then
we
want
to
tell
the
fork
what
is
a
successful
status
code
and
since
we're
actually
modifying
data,
we'll
use
201
and
then
we'll
call
data
dot
bulk
and
I'm
going
to
pass
in
the
params.db,
which
will
be
this
parameter
right
here
and
then
we'll
pass
in
the
body
that
and
when
data.bulk
is
called
it's
going
to
return
in
a
sync
data
type
and
that
a
sync
data
type
is
going
to
have
a
fork
function
on
it.
C
B
The
first
argument
will
be
the
error
function
handler
and
the
second
would
be
the
success
function
handler
and
then
what
it's
going
to
do
is
just
if
it's
an
error,
it's
going
to
see
what
the
error
status
is,
if
it's
specified
and
then
set
that
so
in
case
I
want
to
say
this
is
a
401
you're
not
authorized
or
a
404.
What
you're
looking
for
is
not
found.
I
can
specify
that
in
my
error
object
that
I'll
pass
down
the
chain.
If
it
doesn't
have
a
status,
then
it's
just
going
to
say:
500.
B
Sense
cool,
so
this
just
keeps
things
clean
and
just
gives
everything
a
consistent
pattern,
so
I
can
do
really
most
of
the
heavy
lifting
in
the
core.
So
let's
look
at
that
and
let's
write
a
test
for
that.
B
C
B
So
what
we're
going
to
do
is
we're
going
to
run
this
through
like
a
test
server
and
we'll
actually
do
a
post
and
we'll
actually
mock
out
the
services
so
that
it
returns
a
result.
But
then
we
should
get
a
kind
of
just
testing
the
code
that
we
just
added,
we'll
verify
it
that
that
works.
So
let's
create
an
app
and
we
require.
B
And
here
we'll
also
want
to
add
our
data
commands
from
our
our
core,
but
for
now
we'll
do
middleware
and
then
we'll
create
a
test
server,
and
this
just
creates
a
you
know,
really
a
node
server
on
a
random
port
so
that
we
could
actually
run
these
in
parallel
and
they
wouldn't
break
get
our
fetch.
C
C
B
And
I
try
not
to
make
these
tests
too
complicated,
so
I'm
not
really
worried
about
the
data
at
this
point
as
much
as
I'm
just
trying
to
test
the
code
that
I
just
wrote
right
just
to
make
sure
that
the
code
I
wrote
works
and
if
it
doesn't
work
it
yells
at
me,
so
we'll
get
a
response.
We'll
do
away
away
fetch
server.url.
B
C
C
We'll
do
content
type.
C
C
B
Cool
cool,
so
it
ran
it
made
the
post
generated.
An
error
cannot
read
property
bulk
of
undefined,
because
the
service
that
we're
giving
it
data
doesn't
exist.
So
we
need
to
kind
of
create
a
little
mock
of.
C
B
B
Okay,
we
get
an
error,
cannot
read
property
fork
of
null
cool,
so
it
got
the
bulk
and
it
called
it
and
returned
null
and
it's
trying
to
return
fork.
So
we
could
do
a
couple
of
things
one
is:
is
we
could
return
an
object
with
a
method
fork
on
it
and
do
it
that
way
or
we
could
just
use
a
sink
object
either
way.
C
B
C
C
C
C
C
B
So
we've
got
the
endpoint
implemented,
we
created
kind
of
a
happy
test
and
if
we
go
to
our
actions,
hopefully
we
see
just
the
just
the
test:
app
express
github
action
running.
So
it's
running
that
test
and
it's
it's
actually
set
up,
which
is
pretty
cool.
You
create
a
pull
request
and
when
that
pull
request
is
approved,
it
will
actually
publish
that
to
npm,
so
it
will
publish
the
app
express
module
to
npm.
B
It's
just
really
cool.
So
all
everything
passed
I'm
going
to
switch
back
to
the
terminal
because
you
guys
probably
use
this
all
the
time,
but
I
started
using
this
about
six
months
ago.
I
love
it,
but
you
guys
probably
use
it
all.
The
time
check
it.
B
Out
so
I've
got
a
gh
installed
and
I
can
just
do
pr
create
and
added
bulk
endpoint
submit
and
there's
my
pull
request.
B
I
love
that,
so
we
can
go
back
to
github.
You
guys
have
probably
been
using
that
for
years,
but
like
in
my
previous
world,
I
was
with
get
lab
and
they
just
didn't
really
have
tooling
like
that.
They
probably
do
now,
but.
A
B
Bulk
endpoint
added
someone
can
review
that
and
then
once
it's
approved
it
will
ship
that,
of
course
you
know
we're
not
we're
not
feature
complete.
We've
got
to
go
to
the
core
and
I
I've
got
13
minutes
left.
So
I
think
I
can
do
this.
B
Go
to
the
core
or
well
actually
what
I'll
do
is
go
to
the
port,
because
I
think
this
is
really
cool
to
implement
the
port.
So
if
we
go
back
to
our
diagram,
we've
got
this
data
port.
The
data
port
is
the
cop
right.
It's
the
one,
keeping
the
schema
so
really
a
method
can't
exist
in
an
adapter
and
core
can't
obviously
call
a
method
unless
the
port
specifies
it.
B
B
Here
and
what
we'll
do
is
get
check
out
main
and
then
get
check
out,
dashb.
D
Bulk
tom
correct
me,
if
I'm
wrong,
but
those
ports
they're
also
doing
some
sort
of
they're
also
doing
some
validation
on
the
inputs
and
outputs
so
that
anyone
that
wants
to
implement
an
adapter.
They
don't
have
to
do
all
that
boilerplate
sort
of
validation
on
inputs.
They
kind
of
get
all
that
out
of
the
box
with
the
with
the
core
sort
of
validation.
B
Yeah,
that's
one
of
the
coolest
things
about
this.
We're
using
a
library
called
zod,
and
it
actually
not
only
allows
you
to
specify
the
object
shape
but
it'll
actually
validate
the
function.
Call
at
runtime
and
it's
important
for
this
to
validate
at
run
time,
because
when
you're,
putting
an
adapter
that
adapter
may
be
written
by
some
third
party
right
and
when
you
run
your
instance
of
hyper
63,
you
want
those
validations
to
fire
at
run
time,
not
necessarily
at
compile
time
right.
B
So
this
is
the
schema
definition.
It's
really
simple,
you
have
this
z
object
and
then
it's
got
arguments
on
on
there
to
specify
certain
values
and
they
can
chain
together.
So
here
we've
got
this
create
fun
database
as
a
function
and
its
arguments
is
a
string
and
it
returns
a
promise
that
returns
an
object
that
looks
like
this
boolean,
etc.
B
Yeah,
just
bullying.
So
we
want
to
create
a
bulk
function
here,
right
so
I'll
just
add
it
at
the
bottom.
B
C
B
B
So
with
these
I
can
go
in
and
say
you
know
this
db
and
I
can
add,
like
additional
qualifiers
on
it,
like
a
regex
and
then
add
a
regex,
and
it
has
to
match
that
regex
etc
or
I
could
say
optional
and
then
it
doesn't
have
to
be
on
there.
B
I
think
right
now
it's
going
to
be
db
and
docs
right,
which
will
be
an
array
and
inside
that
array
will
be
an
object,
but
we
don't
necessarily
know
the
the
shape
of
those
objects,
so
it
has
an
any
just
like
typescript
and
the
nice
thing
about
zod.
Is
it
kind
of
mimics
the
type
system
of
typescript
and
it
can
actually
generate
typescript
types
from
it
as
well?
So
that's
pretty
cool
and
then.
B
A
I'm
trying
to
remember
in
the
when
you're
writing
up
the
docs,
but
when
you're
writing
up
the
doc,
I
think
you're
returning
the
just
like
an
id
and
like
a
status.
B
Yeah
yeah:
let's,
let's
go
and
look
at
that
this
one
last
thing
before
we
do
it
is
down
here
is
where
we
kind
of
wrap
real
time
and.
B
B
That's
the
adapter
actually
being
passed
in
and
we
just
wrap
that
and
what
that'll
do
is
that'll
validate
all
of
the
arguments
and
the
returns
as
it's
running.
So
it's
acting
like
you
know
what
like
in
react
when
you
use
higher
order,
functions
to
wrap,
wrap
stuff,
that's
that's
what
it's
basically
doing,
yeah
and
let's
go
and
check
our
documentation
and
that's
why
we
write
the
documentation,
so
we
can
go
and
check
it.
B
Sorry
if
this
stop
share
and
share
stuff
is
painful,
I
don't
know
a
better
way
to
do
it
and
if
I
show
my
whole
screen,
you
won't
be
able
to
see
any
kind
of
text
or
whatever
so
yeah.
So
we
pass
an
array
of
objects.
We
don't
necessarily
know
what's
in
here
and
then
when
we
return.
B
We
return
okay,
true
and
results,
and
we've
got
like
an
id
and
an
okay,
so
yeah.
So
we
need
to
specify
that
in
our
return,
shape,
good
good,
good
call.
C
B
Now
I
want
to
spend
a
whole
day
of
like
taking
this
and
really
cleaning
up
the
message
so
that
when
it
comes
out
on
the
api,
it
looks
really
clean.
But
it's
got
all
the
details
in
there.
It's
got.
You
know
the
the
code
that
the
error
fired.
What's
expected
what's
received
and
what's
undefined.
D
A
Vamp,
I
actually
switch.
I
switch
sides
I
like
to
use
them.
Actually
I
switched
over
in
that
little
code
sharing
or
that
shared
space.
It
took
me
a
little
bit
to
get
my
fingers
pre-trained.
B
B
I
just
can't
take
it
anymore,
cool
so
so
so
we've
got
this
error
and
that's
that's
how
I
want
to
get
this
library
is
like,
as
we
do
things,
we've
got
high
signal
when
things
are
broken,
and
so
here
we
we've
added
the
bulk
documents
and
our
test.
You
know
it's
not
doing
a
whole
lot,
but
it's
telling
us
that
you
know:
we've
created
this
fake
adapter
and
that
fake
adapter
is
not
implementing
the
pattern.
B
So
both
documents
and
we'll
take
db,
and
I
think
it
was
docs
oh
find
out,
and
then
here
we're
just
you
know
doing
a
promise
resolve
and
it's
got
to
be
a
object
with
an
okay,
true
and
results,
and
now
we
have
to
specify
those
results.
B
So
I
think
I've
got
that
and
and
then
now
in
our
block
here,
we'll
we'll
call
it
to
to
test
it.
So.
C
C
B
So
we
just
implemented
a
endpoint
on
our
port
and
what's
left
is
we
got
to
go
to
each
adapter
and
implement
that
and
then
go
to
the
core
and
mash
everything
together.
A
B
So
I'm
going
to
just
do
npm
version
patch.
C
B
A
Yeah,
definitely
for
me
seeing
how
the
the
ports
and
adapters
fit
together
so
far,
yeah.
B
Yeah
so
tomorrow
we'll
pick
up
at
4
30
and
work
on
the
adapters,
which
will
be
good
and
then
jump
in
the
core,
and
I
I
don't
know
how
long
it'll
take
for
the
adapter
part,
but
then
once
we
get
that
core
won't
take,
but
a
few
minutes.
So
I
think
we
should
be
able
to
wrap
it
up
tomorrow
or
wednesday
and
then
jump
on
on
security
or
something
fun
like
that.
I
don't
know.
B
Oh
well,
thanks
for
joining
up,
you
guys
have
a
good
afternoon
evening
and
stay
dry
stay
warm.