Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Introduction to Basejump
Search
Ryan Paul
March 14, 2016
Programming
1.5k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Basejump
Build REST APIs on RethinkDB without writing code
Ryan Paul
March 14, 2016
Transcript
28 slides
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
More Decks by Ryan Paul
See All by Ryan Paul
Using Async Iterators in Node.js
segphault
0
1.2k
Realtime data visualization with RethinkDB and Epoch
segphault
1
830
Realtime web apps with RethinkDB and full-stack Ruby
segphault
2
370
Jupyter and RethinkDB
segphault
1
820
Using RethinkDB with Tornado & EventMachine
segphault
0
790
RethinkDB Training Course
segphault
3
510
RethinkDB Cluster Monitoring
segphault
0
860
Composing frontend Web applications with MontageJS
segphault
4
1.5k
Intro to MontageJS
segphault
1
250
Other Decks in Programming
See All in Programming
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
270
SONY CISC-NEWS NWS-1750 + NWB-225 ハードウェアメンテとフレームバッファカラー対応 / KOF2026
tsutsui
0
120
Proxmox x Talos Linux x Terraform で実現するなんかいい感じの Kubernetes クラスタ / A Sleek Kubernetes Cluster Powered by Proxmox, Talos Linux, and Terraform
nnaka2992
0
280
Claude Code ハーネスDeep Dive – 君はどこまで制御する? -
takateeen_knj
6
6.2k
あなたはMCPの機能を、まだ知らない。
4geru
1
700
SODA - FACT BOOK(EN)
sodainc
1
270
[DroidKnights 2026] Workflow AX 적용기 — 자동 정책 정리부터 E2E까지
dayeon
0
120
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
950
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
180
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
120
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
140
GraphQL の onError と Nullability のこれから
quramy
0
220
Featured
See All Featured
Speed Design
sergeychernyshev
33
2.2k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
620
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Practical Orchestrator
shlominoach
192
12k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
YesSQL, Process and Tooling at Scale
rocio
174
15k
Marketing to machines
jonoalderson
1
6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.7k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.8k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
320
Believing is Seeing
oripsolob
1
290
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
570