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
47
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
45
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
Ruby x Terminal
a_matsuda
7
580
CSC307 Lecture 14
javiergs
PRO
0
450
CopilotKit + AG-UIを学ぶ
nearme_tech
PRO
1
130
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
110
nilとは何か 〜interfaceの構造とnil!=nilから理解する〜
kuro_kurorrr
3
1.6k
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
440
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
300
Windows on Ryzen and I
seosoft
0
110
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
1.6k
Unity6.3 AudioUpdate
cova8bitdots
0
110
Agent Skills Workshop - AIへの頼み方を仕組み化する
gotalab555
14
7.9k
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
920
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
68
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
63
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
A better future with KSS
kneath
240
18k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
290
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
430
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
400
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
140
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