Last active
January 22, 2017 10:22
-
-
Save AlexZeitler/7fd2a1ba8130d306526bf836b46b0813 to your computer and use it in GitHub Desktop.
hypermedia api flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const api = require('./lib') | |
const customer = { | |
companyName1: 'PDMLab' | |
} | |
api | |
.establishContext([ | |
'http://localhost:3000', // customer service root doc based on e.g. Siren | |
'http://localhost:3001' // order service root doc on e.g. Siren | |
]) | |
.then(() => | |
api | |
.new('application/vnd.customer+json', customer) | |
.then(customer => | |
api | |
.new('application/vnd.order+json', { | |
customer: customer, | |
items: ['MBP', 'MBA', 'iPad'] | |
}) | |
.then(order => console.log(order)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ customer: | |
{ companyName1: 'PDMLab', | |
id: '01a5a4c9-6727-401c-8d3a-c05047d3a0f0' }, | |
items: [ 'MBP', 'MBA', 'iPad' ], | |
id: '0fff8964-2e02-4865-b39a-aede0ce7f759' } |
Points 1 + 2 of your suggestions already work in the PoC.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exciting! Here are some abstract bullets to create and consume hypermedia IMHO tastier.
e.g. //localhost:3000 (all following endpoints can be determined by introspection)
nesting is possible