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
52
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
54
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
100
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
72
Multi-container applications with Docker Compose
pferretti
0
130
Multi container applications with Docker Compose
pferretti
1
420
API data stubbing done right
pferretti
0
52
Open source and free software
pferretti
0
44
Other Decks in Programming
See All in Programming
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
240
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
3
1.8k
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
710
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
200
Flow は今どうなっているか
mizdra
PRO
0
690
Loosening the Reins: Go Generics Get More Flexible
kuro_kurorrr
0
300
プロポーザルを書いてもらう
pvcresin
0
580
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
160
VibeCodingからAgenticWorkflowへ
starfish719
0
800
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
2
110
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
430
Featured
See All Featured
Paper Plane (Part 1)
katiecoart
PRO
1
10k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
280
Writing Fast Ruby
sferik
630
63k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
390
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
So, you think you're a good person
axbom
PRO
2
2.1k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
940
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
The Cult of Friendly URLs
andyhume
79
7k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
500
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
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