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
52
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
54
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
100
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
72
Multi-container applications with Docker Compose
pferretti
0
130
Multi container applications with Docker Compose
pferretti
1
420
API data stubbing done right
pferretti
0
52
Open source and free software
pferretti
0
44
Other Decks in Programming
See All in Programming
初めての模倣学習とVLA
natsutan
0
210
Go 1.27からのGODEBUG / Go 1.27 リリースパーティ #go127party
mazrean
0
170
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
510
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
350
AIと壁打ちしながら進めるコスト管理
fufuhu
2
1.6k
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
230
「人を評価する AI」の設計と実装
ryoyanara
0
230
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
430
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
430
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
Featured
See All Featured
The SEO identity crisis: Don't let AI make you average
varn
0
530
Navigating Weather and Climate Data
rabernat
0
490
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Are puppies a ranking factor?
jonoalderson
2
3.8k
The browser strikes back
jonoalderson
0
1.5k
The Cost Of JavaScript in 2023
addyosmani
55
10k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
The SEO Collaboration Effect
kristinabergwall1
1
530
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
870
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
Designing Experiences People Love
moore
143
24k
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