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
Data-Centric Kaggle
isax1015
2
750
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.5k
Kotlin Multiplatform Meetup - Compose Multiplatform 외부 의존성 아키텍처 설계부터 운영까지
wisemuji
0
180
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
370
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
150
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
140
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
660
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
5.9k
CSC307 Lecture 09
javiergs
PRO
1
810
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
970
AI時代の認知負荷との向き合い方
optfit
0
130
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
220
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
46
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
120
Scaling GitHub
holman
464
140k
What does AI have to do with Human Rights?
axbom
PRO
0
2k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
47
The Limits of Empathy - UXLibs8
cassininazir
1
210
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
52
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.6k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
420
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
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