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
37
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
39
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
71
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
25
Multi-container applications with Docker Compose
pferretti
0
120
Multi container applications with Docker Compose
pferretti
1
300
API data stubbing done right
pferretti
0
37
Open source and free software
pferretti
0
29
Other Decks in Programming
See All in Programming
Temporalを取り巻く仕様を整理する
sajikix
0
110
入社1ヶ月でここまでやった!Findy Toolsインフラ支援の最適化
rvirus0817
6
1.4k
AWSでゲームサーバーを運用! Amazon GameLiftのお話
iriikeita
0
200
AWS CDKにおける「再利用性」を考える / aws-cdk-reusability
gotok365
6
1.3k
Rustのweb開発を助ける 便利なツール紹介
yuki0418
1
190
Exploring the Gradually Lost Technical Skills in the Cloud Native Era
hwchiu
2
3.9k
Jetpack for KMP
fornewid
1
290
Architectures with Lightweight Stores: New Rules and Options
manfredsteyer
PRO
0
100
Product Management LT会_クアンド新家
shinshin
0
210
OpenAI/Gemini APIを使って EPUBを翻訳するCLIツールをつくってみた
tomiyan
0
790
今こそ始める、CDKコンストラクトライブラリ開発 ― 入門から実践まで
tmokmss
1
930
小さな開発会社を作った理由
polidog
0
1.9k
Featured
See All Featured
How GitHub Uses GitHub to Build GitHub
holman
471
290k
The Pragmatic Product Professional
lauravandoore
29
6.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
228
16k
Producing Creativity
orderedlist
PRO
340
39k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
325
21k
How to Ace a Technical Interview
jacobian
274
23k
The Brand Is Dead. Long Live the Brand.
mthomps
52
36k
The Art of Programming - Codeland 2020
erikaheidi
48
13k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
353
29k
10 Git Anti Patterns You Should be Aware of
lemiorhan
652
58k
Practical Orchestrator
shlominoach
185
10k
Teambox: Starting and Learning
jrom
130
8.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