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
36
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
33
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
71
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
22
Multi-container applications with Docker Compose
pferretti
0
110
Multi container applications with Docker Compose
pferretti
1
270
API data stubbing done right
pferretti
0
33
Open source and free software
pferretti
0
28
Other Decks in Programming
See All in Programming
HUIT新歓2024「競技プログラミング、やってみませんか?」
slephy2784
1
250
1BRC--Nerd Sniping the Java Community
gunnarmorling
0
300
Folding Cheat Sheet #2
philipschwarz
PRO
0
110
Changed Rules: Architectures with Lightweight Stores
manfredsteyer
PRO
0
230
pixivアプリでマルチモジュールを実現するまで
gatosyocora
1
130
ONE WEDGE_company_guide
1wedge_one
0
380
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
120
本格ローグライク制作にEbitengineを選んでみた
nagainaganawa
0
290
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
3
770
受託開発でGitLab CI を活用していく
xiombatsg
1
270
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
190
SpringBoot+MyBatisで例外が出たときどこを見るか
syukai
0
110
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
225
17k
Building Effective Engineering Teams - LeadDev
addyosmani
27
1.8k
Teambox: Starting and Learning
jrom
128
8.4k
What's in a price? How to price your products and services
michaelherold
237
11k
The Illustrated Children's Guide to Kubernetes
chrisshort
29
46k
Six Lessons from altMBA
skipperchong
20
3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
39
4.4k
Product Roadmaps are Hard
iamctodd
43
9.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
6
990
Navigating Team Friction
lara
177
13k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
240
1.2M
ReactJS: Keep Simple. Everything can be a component!
pedronauck
658
120k
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