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
48
0
Share
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
52
Microservizi serverless estensibili, segmentabili e scalabili
pferretti
0
99
Microservizi serverless scalabili da zero a milioni di messaggi
pferretti
0
58
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
47
Open source and free software
pferretti
0
43
Other Decks in Programming
See All in Programming
GitHub Copilot CLIのいいところ
htkym
2
1.1k
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
220
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
1.7k
新規プロダクトを高速で生み出すハーネスエンジニアリング
seanchas116
6
710
権限チェックの一貫性を型で守る TypeScript による多層防御
mnch
4
850
バックエンドにElysiaJSを採用して気付いた、良い点・悪い点
wanko_it
1
180
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
510
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
770
AI Agent と正しく分析するための環境作り
yoshyum
3
610
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
190
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
250
デフォルト運用のCodeRabbit、1年で何が変わったか / How CodeRabbit Changed Our Code Review in 1 Year
bake0937
1
110
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
340
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Bash Introduction
62gerente
615
210k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
Chasing Engaging Ingredients in Design
codingconduct
0
200
Site-Speed That Sticks
csswizardry
13
1.2k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
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