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
MilanoJS - API data stubbing done right
Search
Paolo Ferretti
May 02, 2017
Programming
0
39
MilanoJS - API data stubbing done right
Flash talk for MilanoJS to explain what is Saray and how to mock API data using it.
Paolo Ferretti
May 02, 2017
Tweet
Share
More Decks by Paolo Ferretti
See All by Paolo Ferretti
Serverless VS SAM
pferretti
0
44
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
78
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
28
Multi-container applications with Docker Compose
pferretti
0
120
Multi container applications with Docker Compose
pferretti
1
350
API data stubbing done right
pferretti
0
38
Open source and free software
pferretti
0
32
Other Decks in Programming
See All in Programming
Immutable ActiveRecord
megane42
0
140
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
170
『GO』アプリ バックエンドサーバのコスト削減
mot_techtalk
0
140
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
47
17k
Amazon S3 TablesとAmazon S3 Metadataを触ってみた / 20250201-jawsug-tochigi-s3tables-s3metadata
kasacchiful
0
170
AWS Organizations で実現する、 マルチ AWS アカウントのルートユーザー管理からの脱却
atpons
0
150
『品質』という言葉が嫌いな理由
korimu
0
160
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
750
2024年のWebフロントエンドのふりかえりと2025年
sakito
3
250
PHP ステートレス VS ステートフル 状態管理と並行性 / php-stateless-stateful
ytake
0
100
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
6
4k
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
Featured
See All Featured
Become a Pro
speakerdeck
PRO
26
5.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
A Tale of Four Properties
chriscoyier
158
23k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
RailsConf 2023
tenderlove
29
1k
Bash Introduction
62gerente
611
210k
BBQ
matthewcrist
87
9.5k
Being A Developer After 40
akosma
89
590k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1k
Transcript
API data stubbing done right With Saray and Node.js
What is a data stubber? It’s a software that permits
to mock data
Why it is important to stub data? • for software
development • consistent data for functional tests • safe environments for product demo
We can stub data with Saray! 'Yet Another Rest API
Stubber'.split(' ').reverse().map(item => item[0].toLowerCase()).join('')
Saray can transform this… /home/paolo/saray/simple.GET.json { “message”: “Hi Milan, I’m
a stubbed API call” } …into this GET http://locahost:8000/simple HTTP/1.1 200 OK X-Powered-By: Express Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization Access-Control-Allow-Credentials: true Saray-Stubbed: true Content-Type: application/json; charset=utf-8 Content-Length: 46 ETag: W/"2e-89E9C8HHkWvwlUiWgeXBGIuHeyw" Date: Sun, 30 Apr 2017 18:14:33 GMT Connection: keep-alive { “message": "Hi Milan, I'm a stubbed API call" }
You can also use JS! module.exports = function(req, res, log,
next) { res.json({key: 'value'}); };
Saray as a proxy GET http://locahost:8000/simple $ saray —path data
—endpoint https://myapi.com https://myapi.com Saray
Saray with dynamic paths GET http://localhost:8081/simple/salutation/hello $ saray —path data
—dynpath=‘_’ simple/_/hello.GET.json GET http://localhost:8081/simple/greeting/hello GET http://localhost:8081/simple/curtsy/hello
Thank you! Saray: https://github.com/contactlab/saray Saray demo: https://github.com/contactlab/saray-demo