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
38
Open source and free software
pferretti
0
32
Other Decks in Programming
See All in Programming
令和トラベルにおけるコンテンツ生成AIアプリケーション開発の実践
ippo012
1
240
RecSys2024 参加報告
unonao
1
170
SwiftUIのObservationツールの挙動をテストしてみた
kenshih522
0
110
RCPと宣言型ポリシーについてのお話し
kokitamura
2
130
CIBMTR振り返り+敗北から学ぶコンペの取り組み方反省
takanao
1
490
Devin , 正しい付き合い方と使い方 / Living and Working with Devin
yukinagae
1
480
PsySHから紐解くREPLの仕組み
muno92
PRO
1
410
アーキテクトと美学 / Architecture and Aesthetics
nrslib
11
2.7k
PHPer's Guide to Daemon Crafting Taming and Summoning
uzulla
2
570
技術好きなエンジニアが "リーダーへの進化" によって得たものと失ったもの
pospome
5
1.3k
보일러플레이트 코드가 진짜 나쁜 건가요?
gaeun5744
0
350
AI時代のプログラミング教育 / programming education in ai era
kishida
22
19k
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.2k
Unsuck your backbone
ammeep
669
57k
Being A Developer After 40
akosma
89
590k
Statistics for Hackers
jakevdp
797
220k
Optimizing for Happiness
mojombo
377
70k
A designer walks into a library…
pauljervisheath
205
24k
Typedesign – Prime Four
hannesfritz
41
2.6k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.3k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
176
52k
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