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
46
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
44
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
AI巻き込み型コードレビューのススメ
nealle
2
390
Architectural Extensions
denyspoltorak
0
290
CSC307 Lecture 06
javiergs
PRO
0
690
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
710
並行開発のためのコードレビュー
miyukiw
0
250
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
130
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
組織で育むオブザーバビリティ
ryota_hnk
0
180
MUSUBIXとは
nahisaho
0
140
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
200
CSC307 Lecture 02
javiergs
PRO
1
780
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
140
Featured
See All Featured
Thoughts on Productivity
jonyablonski
74
5k
GraphQLとの向き合い方2022年版
quramy
50
14k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
340
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
94
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
130
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
200
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Producing Creativity
orderedlist
PRO
348
40k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
100
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