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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Paolo Ferretti
May 02, 2017
Programming
51
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
More Decks by Paolo Ferretti
See All by Paolo Ferretti
Serverless VS SAM
pferretti
0
53
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
100
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
67
Multi-container applications with Docker Compose
pferretti
0
130
Multi container applications with Docker Compose
pferretti
1
410
API data stubbing done right
pferretti
0
50
Open source and free software
pferretti
0
44
Other Decks in Programming
See All in Programming
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.7k
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
350
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
300
Performance Engineering for Everyone
elenatanasoiu
0
270
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
180
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
150
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
210
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
240
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
160
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
300
act1-costs.pdf
sumedhbala
0
210
Featured
See All Featured
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
300
Into the Great Unknown - MozCon
thekraken
41
2.6k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
290
Producing Creativity
orderedlist
PRO
348
40k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
190
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
900
Unsuck your backbone
ammeep
672
58k
Amusing Abliteration
ianozsvald
1
220
Between Models and Reality
mayunak
4
370
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
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