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
43
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
46
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
82
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
32
Multi-container applications with Docker Compose
pferretti
0
120
Multi container applications with Docker Compose
pferretti
1
390
API data stubbing done right
pferretti
0
42
Open source and free software
pferretti
0
37
Other Decks in Programming
See All in Programming
Domain-centric? Why Hexagonal, Onion, and Clean Architecture Are Answers to the Wrong Question
olivergierke
3
930
Introduce Hono CLI
yusukebe
6
3k
Claude Agent SDK を使ってみよう
hyshu
0
1.3k
組込みだけじゃない!TinyGo で始める無料クラウド開発入門
otakakot
1
340
なぜGoのジェネリクスはこの形なのか? - Featherweight Goが明かす設計の核心
qualiarts
0
210
contribution to astral-sh/uv
shunsock
0
430
スマホから Youtube Shortsを見られないようにする
lemolatoon
27
33k
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
180
CSC509 Lecture 06
javiergs
PRO
0
260
実践Claude Code:20の失敗から学ぶAIペアプログラミング
takedatakashi
16
6.4k
AI Agent 時代的開發者生存指南
eddie
4
2k
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
870
Featured
See All Featured
Scaling GitHub
holman
463
140k
Navigating Team Friction
lara
190
15k
Six Lessons from altMBA
skipperchong
29
4k
Writing Fast Ruby
sferik
629
62k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
RailsConf 2023
tenderlove
30
1.3k
It's Worth the Effort
3n
187
28k
Typedesign – Prime Four
hannesfritz
42
2.8k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
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