Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to Basejump
Search
Ryan Paul
March 14, 2016
Programming
1
1.4k
Introduction to Basejump
Build REST APIs on RethinkDB without writing code
Ryan Paul
March 14, 2016
Tweet
Share
More Decks by Ryan Paul
See All by Ryan Paul
Using Async Iterators in Node.js
segphault
0
1.1k
Realtime data visualization with RethinkDB and Epoch
segphault
1
770
Realtime web apps with RethinkDB and full-stack Ruby
segphault
2
350
Jupyter and RethinkDB
segphault
1
760
Using RethinkDB with Tornado & EventMachine
segphault
0
730
RethinkDB Training Course
segphault
3
470
RethinkDB Cluster Monitoring
segphault
0
810
Composing frontend Web applications with MontageJS
segphault
4
1.5k
Intro to MontageJS
segphault
1
220
Other Decks in Programming
See All in Programming
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
170
猫の手も借りたい!ので AIエージェント猫を作って社内に放した話 Claude Code × Container Lambda の Slack Bot "DevNeko"
naramomi7
0
210
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
240
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
200
オブザーバビリティ駆動開発って実際どうなの?
yohfee
1
420
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
2k
あなたはユーザーではない #PdENight
kajitack
4
270
Premier Disciplin for Micro Frontends Multi Version/ Framework Scenarios @OOP 2026, Munic
manfredsteyer
PRO
0
190
AI & Enginnering
codelynx
0
140
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
300
今から始めるClaude Code超入門
448jp
8
9.5k
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
410
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
A Tale of Four Properties
chriscoyier
162
24k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
310
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
How to Ace a Technical Interview
jacobian
281
24k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
50k
Technical Leadership for Architectural Decision Making
baasie
2
270
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
Transcript
Basejump Build a REST API on RethinkDB
Ryan Paul RethinkDB Evangelist @segphault
API Anatomy Dissecting an API backend
API Anatomy • Server to parse & handle requests •
Routing to manage endpoints • Validation to sanitize user input • Persistence to store & retrieve data
API Anatomy RethinkDB NodeJS JOI Koa Vue Browser REST API
Koa Router W3C Fetch Real-world RethinkDB stack
API Anatomy Persistence Runtime Validation Server Frontend Framework Browser REST
API Router REST Client Real-world RethinkDB stack
API Anatomy • Lots of layers between persistence and requests
• More boilerplate than business logic • Repetitive code that is difficult to reuse
API Anatomy router.post("/api/event/:id/messages", function*(id) { this.checkBody("message").notEmpty(); if (this.errors) this.throw(400, {success:
false, errors: this.errors}); yield r.table("messages").insert({ created: r.now(), text: this.request.body.message, sender: sender, event: id}); this.body = {success: true}; });
Can we abstract away the boilerplate?
Project Basejump Attach queries to endpoints
Basejump • Visual tool for prototyping API backends • Dynamic
routing middleware for attaching queries to endpoints • Powered by declarative JSON description format
Basejump
{A} 1ST
Basejump Router • Database agnostic routing middleware • Uses Node’s
VM module to execute code • Integrates seamlessly with Koa and Socket.io • Swagger-based format to describe routes and actions
Swagger
Swagger • Standard format for describing APIs — can use
YAML or JSON • Uses JSON Schema for validation • Supported by many tools & frameworks • Extensible via vendor properties
Swagger paths: /test: get: parameters: - {in: query, name: count,
type: number} x-action: > r.table("test") .orderBy(r.desc("time")) .limit(params.count) post: parameters: - in: body name: body schema: $ref: "#/definitions/test" x-action: > r.table("test").insert(params.body)
Embed Basejump • Embed in your own Node app •
Pass custom objects into the execution context • Inherit and override the request handler • Custom pre & post processing on input and output
Embed Basejump const app = require("koa")(); const router = require("basejump-router");
const r = require("rethinkdbdash")(); app.use(require("kcors")()); app.use(require("koa-bodyparser")()); app.use(router.middleware.koa({ swagger: "routes.yaml", context: {r: r} })); app.listen(8000);
Project Basejump Status & Future Plans
Basejump • Not ready for adoption quite yet • API
and data format still subject to change • New features might necessitate additional format churn
Feature Roadmap • Support for embedding in Express • Interactive
Schema editing • Pluggable view system • Route collections and blueprints • Authentication and user management • Live API debugging
Feature Ideas • Generate client libraries for mobile & web
• Use schemas to generate input forms & data dashboard • Support for file uploads & multipart mime • Automatically generate tables and indexes from schemas
How does it compare to Fusion?
How does it compare to Fusion? Horizon?
Basejump vs Horizon • Basejump: backend-first development & REST APIs
• Horizon: frontend-first development & WebSockets
Basejump & Horizon • Embed Basejump and Horizon middleware in
the same Node app • Expose Basejump routes through Horizon custom endpoint • Converge authentication and schema validation?
• RethinkDB website: http://rethinkdb.com • Basejump Router: http://github.com/segphault/ basejump-router •
Follow me on Twitter: @segphault Resources