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
39
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
44
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
78
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
30
Multi-container applications with Docker Compose
pferretti
0
120
Multi container applications with Docker Compose
pferretti
1
360
API data stubbing done right
pferretti
0
40
Open source and free software
pferretti
0
33
Other Decks in Programming
See All in Programming
趣味全開のAITuber開発
kokushin
0
180
小さく段階的リリースすることで深夜メンテを回避する
mkmk884
2
160
Code smarter, not harder - How AI Coding Tools Boost Your Productivity | Webinar 2025
danielsogl
0
110
custom_lintで始めるチームルール管理
akaboshinit
0
200
新しいPHP拡張モジュールインストール方法「PHP Installer for Extensions (PIE)」を使ってみよう!
cocoeyes02
0
230
S3静的ホスティング+Next.js静的エクスポート で格安webアプリ構築
iharuoru
0
220
Devinのメモリ活用の学びを自社サービスにどう組み込むか?
itarutomy
0
2k
新卒から4年間、20年もののWebサービスと 向き合って学んだソフトウェア考古学
oguri
8
7.2k
データベースエンジニアの仕事を楽にする。PgAssistantの紹介
nnaka2992
9
4.5k
Empowering Developers with HTML-Aware ERB Tooling @ RubyKaigi 2025, Matsuyama, Ehime
marcoroth
1
140
Chrome Extension Techniques from Hell
moznion
1
160
リアクティブシステムの変遷から理解するalien-signals / Learning alien-signals from the evolution of reactive systems
yamanoku
3
1.2k
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Optimizing for Happiness
mojombo
377
70k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Typedesign – Prime Four
hannesfritz
41
2.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.1k
Fireside Chat
paigeccino
37
3.4k
Why Our Code Smells
bkeepers
PRO
336
57k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
29
2k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
4
510
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.6k
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