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
46
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
49
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
91
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
44
Multi-container applications with Docker Compose
pferretti
0
120
Multi container applications with Docker Compose
pferretti
1
390
API data stubbing done right
pferretti
0
45
Open source and free software
pferretti
0
41
Other Decks in Programming
See All in Programming
Basic Architectures
denyspoltorak
0
680
Data-Centric Kaggle
isax1015
2
780
CSC307 Lecture 05
javiergs
PRO
0
500
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
290
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
5
470
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.6k
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
300
Architectural Extensions
denyspoltorak
0
290
AI巻き込み型コードレビューのススメ
nealle
2
360
CSC307 Lecture 03
javiergs
PRO
1
490
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
200
Featured
See All Featured
Docker and Python
trallard
47
3.7k
How to train your dragon (web standard)
notwaldorf
97
6.5k
The Limits of Empathy - UXLibs8
cassininazir
1
220
Mind Mapping
helmedeiros
PRO
0
87
Designing for humans not robots
tammielis
254
26k
The Spectacular Lies of Maps
axbom
PRO
1
520
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Done Done
chrislema
186
16k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
130
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
590
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
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