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
48
0
Share
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
More Decks by Paolo Ferretti
See All by Paolo Ferretti
Serverless VS SAM
pferretti
0
52
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
99
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
58
Multi-container applications with Docker Compose
pferretti
0
130
Multi container applications with Docker Compose
pferretti
1
410
API data stubbing done right
pferretti
0
47
Open source and free software
pferretti
0
43
Other Decks in Programming
See All in Programming
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
120
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1k
自動レビューエンジンの実装と運用 ~レビューのない世界へ~
kurukuru1999
2
270
[BalkanRuby 2026] Drop your app/services!
palkan
3
700
Modding RubyKaigi for Myself
yui_knk
0
490
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
900
RTSPクライアントを自作してみた話
simotin13
0
250
OSもどきOS
arkw
0
210
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.2k
Transactional Change Stream Processing With Debezium and Apache Flink
gunnarmorling
1
130
Oxcを導入して開発体験が向上した話
yug1224
4
150
CLIであることを活かしたGitHub Copilot CLI活用術 / GitHub Copilot CLI Pro Tips & Tricks
nao_mk2
1
1.1k
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.6k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
Designing for Timeless Needs
cassininazir
1
230
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
230
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
130
The Language of Interfaces
destraynor
162
26k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
230
Accessibility Awareness
sabderemane
1
130
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