Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
43
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
46
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
82
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
34
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
42
Open source and free software
pferretti
0
38
Other Decks in Programming
See All in Programming
ID管理機能開発の裏側 高速にSaaS連携を実現したチームのAI活用編
atzzcokek
0
210
WebRTC、 綺麗に見るか滑らかに見るか
sublimer
1
160
AIコーディングエージェント(skywork)
kondai24
0
150
ソフトウェア設計の課題・原則・実践技法
masuda220
PRO
26
22k
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
140
Integrating WordPress and Symfony
alexandresalome
0
140
How Software Deployment tools have changed in the past 20 years
geshan
0
28k
Rediscover the Console - SymfonyCon Amsterdam 2025
chalasr
2
160
20 years of Symfony, what's next?
fabpot
2
350
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
1
600
無秩序からの脱却 / Emergence from chaos
nrslib
2
13k
認証・認可の基本を学ぼう後編
kouyuume
0
180
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
970
It's Worth the Effort
3n
187
29k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Scaling GitHub
holman
464
140k
[SF Ruby Conf 2025] Rails X
palkan
0
490
Thoughts on Productivity
jonyablonski
73
5k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
The Invisible Side of Design
smashingmag
302
51k
Site-Speed That Sticks
csswizardry
13
990
Music & Morning Musume
bryan
46
7k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Automating Front-end Workflow
addyosmani
1371
200k
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