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
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
33
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
PyCon mini 東海 2025「個人ではじめるマルチAIエージェント入門 〜LangChain × LangGraphでアイデアを形にするステップ〜」
komofr
3
1.1k
Microservices Platforms: When Team Topologies Meets Microservices Patterns
cer
PRO
0
210
乱雑なコードの整理から学ぶ設計の初歩
masuda220
PRO
32
14k
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
5
1.9k
Flutterアプリ運用の現場で役立った監視Tips 5選
ostk0069
1
500
Stay Hacker 〜九州で生まれ、Perlに出会い、コミュニティで育つ〜
pyama86
2
2.3k
Duke on CRaC with Jakarta EE
ivargrimstad
0
160
AI時代もSEOを頑張っている話
shirahama_x
0
140
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
1
180
社内オペレーション改善のためのTypeScript / TSKaigi Hokuriku 2025
dachi023
1
110
Vueで学ぶデータ構造入門 リンクリストとキューでリアクティビティを捉える / Vue Data Structures: Linked Lists and Queues for Reactivity
konkarin
1
330
詳細の決定を遅らせつつ実装を早くする
shimabox
1
1.3k
Featured
See All Featured
Fireside Chat
paigeccino
41
3.7k
Code Reviewing Like a Champion
maltzj
527
40k
The Language of Interfaces
destraynor
162
25k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Practical Orchestrator
shlominoach
190
11k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
11
940
KATA
mclloyd
PRO
32
15k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.4k
Faster Mobile Websites
deanohume
310
31k
Building an army of robots
kneath
306
46k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.8k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.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