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
51
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
95
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
55
Multi-container applications with Docker Compose
pferretti
0
130
Multi container applications with Docker Compose
pferretti
1
400
API data stubbing done right
pferretti
0
47
Open source and free software
pferretti
0
43
Other Decks in Programming
See All in Programming
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
430
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
310
Swift Concurrency Type System
inamiy
1
570
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.2k
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
110
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
340
의존성 주입과 모듈화
fornewid
0
160
GoogleCloudとterraform完全に理解した
terisuke
1
180
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
950
Liberating Ruby's Parser from Lexer Hacks
ydah
2
2.5k
GitHubCopilotCLIをはじめよう.pdf
htkym
0
310
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
330
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
490
A better future with KSS
kneath
240
18k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
450
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Faster Mobile Websites
deanohume
310
31k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
140
Visualization
eitanlees
150
17k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
500
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
280
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