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
42
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
46
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
82
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
32
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
42
Open source and free software
pferretti
0
37
Other Decks in Programming
See All in Programming
CSC305 Lecture 01
javiergs
PRO
1
400
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
180
CSC509 Lecture 01
javiergs
PRO
1
430
プロダクト開発をAI 1stに変革する〜SaaS is dead時代で生き残るために〜 / AI 1st Product Development
kobakei
0
490
After go func(): Goroutines Through a Beginner’s Eye
97vaibhav
0
230
止められない医療アプリ、そっと Swift 6 へ
medley
1
120
CSC305 Lecture 04
javiergs
PRO
0
250
Le côté obscur des IA génératives
pascallemerrer
0
120
クラシルを支える技術と組織
rakutek
0
190
私はどうやって技術力を上げたのか
yusukebe
43
17k
NetworkXとGNNで学ぶグラフデータ分析入門〜複雑な関係性を解き明かすPythonの力〜
mhrtech
3
1k
AIエージェント時代における TypeScriptスキーマ駆動開発の新たな役割
bicstone
4
1.5k
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
53k
Building an army of robots
kneath
306
46k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
We Have a Design System, Now What?
morganepeng
53
7.8k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
20k
Side Projects
sachag
455
43k
Building Adaptive Systems
keathley
43
2.8k
The Pragmatic Product Professional
lauravandoore
36
6.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
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